EXC_BAD_ACCESS at runtime when overriding a generic func with a non-generic func in a generic subclass
Originator: | fluidsonic | ||
Number: | rdar://21669640 | Date Originated: | 2015-07-03 |
Status: | Open | Resolved: | |
Product: | Developer Tools | Product Version: | Xcode 7 Beta 2 |
Classification: | Crash/Hang/Data Loss | Reproducible: | Always |
Summary: In the attached example calling "test()" dynamically on the base class causes an EXC_BAD_ACCESS at runtime. It worked fine in Swift 1. Steps to Reproduce: 1. Copy the attached code into a Playground. 2. Run the code in the playground. Expected Results: Program should complete without any problems. Actual Results: Playground execution failed: Execution was interrupted, reason: EXC_BAD_ACCESS (code=1, address=0xfffffffffffffff8). * thread #1: tid = 0xb8cd, 0x0000000109cd5750 libswiftCore.dylib`swift_initEnumValueWitnessTableSinglePayload + 16, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0xfffffffffffffff8) * frame #0: 0x0000000109cd5750 libswiftCore.dylib`swift_initEnumValueWitnessTableSinglePayload + 16 frame #1: 0x0000000109c4c2fb libswiftCore.dylib`___lldb_unnamed_function447$$libswiftCore.dylib + 43 frame #2: 0x0000000109ccefa8 libswiftCore.dylib`(anonymous namespace)::GenericCacheEntry* llvm::function_ref<(anonymous namespace)::GenericCacheEntry* ()>::callback_fn<swift::swift_getGenericMetadata::$_0>(long) + 24 frame #3: 0x0000000109cceeb0 libswiftCore.dylib`MetadataCache<(anonymous namespace)::GenericCacheEntry>::addMetadataEntry(EntryRef<(anonymous namespace)::GenericCacheEntry>, ConcurrentList<MetadataCache<(anonymous namespace)::GenericCacheEntry>::EntryPair>&, llvm::function_ref<(anonymous namespace)::GenericCacheEntry* ()>) + 128 frame #4: 0x0000000109ccb698 libswiftCore.dylib`swift_getGenericMetadata + 504 frame #5: 0x0000000109ccb6e5 libswiftCore.dylib`swift_getGenericMetadata1 + 21 frame #6: 0x00000001123e67cb $__lldb_expr93`__lldb_expr_93.ChildClass.test <A where A: __lldb_expr_93.OtherBaseClass> (self=0x00000001123f2040)() -> Swift.Optional<A> + 187 at MyPlayground.playground:18 frame #7: 0x00000001123e61ff $__lldb_expr93`main + 511 at MyPlayground.playground:24 frame #8: 0x000000010789cc00 MyPlayground frame #9: 0x00000001078a0301 MyPlayground`reabstraction thunk helper from @callee_owned () -> (@unowned ()) to @callee_owned (@in ()) -> (@out ()) + 17 frame #10: 0x000000010789f631 MyPlayground`partial apply forwarder for reabstraction thunk helper from @callee_owned () -> (@unowned ()) to @callee_owned (@in ()) -> (@out ()) + 81 frame #11: 0x00000001078a0330 MyPlayground`reabstraction thunk helper from @callee_owned (@in ()) -> (@out ()) to @callee_owned () -> (@unowned ()) + 32 frame #12: 0x00000001078a0367 MyPlayground`reabstraction thunk helper from @callee_owned () -> (@unowned ()) to @callee_unowned @convention(block) () -> (@unowned ()) + 39 frame #13: 0x0000000107eb976c CoreFoundation`__CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK__ + 12 frame #14: 0x0000000107eaf2d5 CoreFoundation`__CFRunLoopDoBlocks + 341 frame #15: 0x0000000107eaea32 CoreFoundation`__CFRunLoopRun + 850 frame #16: 0x0000000107eae458 CoreFoundation`CFRunLoopRunSpecific + 488 frame #17: 0x000000010ea7cbca GraphicsServices`GSEventRunModal + 161 frame #18: 0x000000010833a1c2 UIKit`UIApplicationMain + 171 frame #19: 0x000000010789d049 MyPlayground`main + 1097 frame #20: 0x000000010ae1992d libdyld.dylib`start + 1 Attached file: import Foundation public class OtherBaseClass {} public class OtherChildClass: OtherBaseClass {} class BaseClass { func test<T: OtherBaseClass>() -> T? { fatalError() } } final class ChildClass<T: OtherBaseClass> : BaseClass { override func test() -> T? { return nil } } let instance: BaseClass = ChildClass<OtherChildClass>() instance.test()
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!