]> git.saurik.com Git - apple/objc4.git/blob - test/badSuperclass.m
objc4-756.2.tar.gz
[apple/objc4.git] / test / badSuperclass.m
1 // TEST_CRASHES
2 /*
3 TEST_RUN_OUTPUT
4 objc\[\d+\]: Memory corruption in class list\.
5 objc\[\d+\]: HALTED
6 END
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
18 int 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);
29 ((Class *)(__bridge void *)subcls)[1] = subcls;
30 #ifdef CACHE_FLUSH
31 _objc_flush_caches(supercls);
32 #else
33 [subobj class];
34 #endif
35
36 fail("should have crashed");
37 }