]> git.saurik.com Git - apple/objc4.git/blame - test/badSuperclass.m
objc4-818.2.tar.gz
[apple/objc4.git] / test / badSuperclass.m
CommitLineData
13ba007e
A
1// TEST_CRASHES
2/*
3TEST_RUN_OUTPUT
4objc\[\d+\]: Memory corruption in class list\.
5objc\[\d+\]: HALTED
6END
7*/
8
9#include "test.h"
10#include "testroot.i"
11
12@interface Super : TestRoot @end
13@implementation Super @end
14
15@interface Sub : Super @end
16@implementation Sub @end
17
18int main()
19{
20 alarm(10);
21
22 Class supercls = [Super class];
23 Class subcls = [Sub class];
24 id subobj __unused = [Sub alloc];
25
26 // Create a cycle in a superclass chain (Sub->supercls == Sub)
27 // then attempt to walk that chain. Runtime should halt eventually.
28 _objc_flush_caches(supercls);
34d5b5e8 29 ((Class __ptrauth_objc_super_pointer *)(__bridge void *)subcls)[1] = subcls;
13ba007e
A
30#ifdef CACHE_FLUSH
31 _objc_flush_caches(supercls);
32#else
33 [subobj class];
34#endif
35
36 fail("should have crashed");
37}