[SR-5043] App crashes when calling method on downcasted object #47619
Labels
bug
A deviation from expected or documented behavior. Also: expected but undesirable behavior.
compiler
The Swift compiler in itself
crash
Bug: A crash, i.e., an abnormal termination of software
run-time crash
Bug → crash: Swift code crashed during execution
Attachment: Download
Environment
Xcode Version 8.3.2 (8E2002)
It seems reproducible on any device (even in Simulator), but my case was e.g. iPhone model mn922cn/a iOS 10.3.2 (14F89)
Additional Detail from JIRA
md5: 8d25633ba885ee86214c1a433b07e65c
duplicates:
Issue Description:
App defines two protocols and typealias
Event
that is an union of those two protocols. Then it defines classSubscription
that conforms to those two protocols. When an array ofSubscription
instances is assigned to an array of type[Event]
and then the app loops through that[Event]
array and it calls a protocol method on an object from the array the app crashes with: Thread 1: EXC_BAD_ACCESS (code=1, address=0x0)I noticed that this happens only when protocols and class declarations are in a different file than the code with the assignment and the loop.
Stack trace:
["0 SwiftBug 0x0000000105beb4e3 TFC8SwiftBug14ViewController10bugExamplefT_T + 515", "1 SwiftBug 0x0000000105beb1b2 TFC8SwiftBug14ViewController11viewDidLoadfT_T + 98", "2 SwiftBug 0x0000000105beb222 TToFC8SwiftBug14ViewController11viewDidLoadfT_T + 34", "3 UIKit 0x0000000106839cca -[UIViewController loadViewIfRequired] + 1235", "4 UIKit 0x000000010683a10a -[UIViewController view] + 27", "5 UIKit 0x000000010670263a -[UIWindow addRootViewControllerViewIfPossible] + 65", "6 UIKit 0x0000000106702d20 -[UIWindow _setHidden:forced:] + 294", "7 UIKit 0x0000000106715b6e -[UIWindow makeKeyAndVisible] + 42", "8 UIKit 0x000000010668f31f -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:] + 4346", "9 UIKit 0x0000000106695584 -[UIApplication _runWithMainScene:transitionContext:completion:] + 1709", "10 UIKit 0x0000000106692793 -[UIApplication workspaceDidEndTransaction:] + 182", "11 FrontBoardServices 0x000000010a62d5f6 FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK + 24", "12 FrontBoardServices 0x000000010a62d46d -[FBSSerialQueue _performNext] + 186", "13 FrontBoardServices 0x000000010a62d7f6 -[FBSSerialQueue _performNextFromRunLoopSource] + 45", "14 CoreFoundation 0x0000000108ec3c01 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION + 17", "15 CoreFoundation 0x0000000108ea90cf __CFRunLoopDoSources0 + 527", "16 CoreFoundation 0x0000000108ea85ff __CFRunLoopRun + 911", "17 CoreFoundation 0x0000000108ea8016 CFRunLoopRunSpecific + 406", "18 UIKit 0x000000010669102f -[UIApplication _run] + 468", "19 UIKit 0x00000001066970d4 UIApplicationMain + 159", "20 SwiftBug 0x0000000105bec957 main + 55", "21 libdyld.dylib 0x0000000109ebd65d start + 1"]
The text was updated successfully, but these errors were encountered: