Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[SR-5043] App crashes when calling method on downcasted object #47619

Closed
swift-ci opened this issue May 29, 2017 · 4 comments
Closed

[SR-5043] App crashes when calling method on downcasted object #47619

swift-ci opened this issue May 29, 2017 · 4 comments
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

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-5043
Radar None
Original Reporter schwarja (JIRA User)
Type Bug
Status Closed
Resolution Duplicate

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
Votes 0
Component/s Compiler
Labels Bug, RunTimeCrash
Assignee schwarja (JIRA)
Priority Medium

md5: 8d25633ba885ee86214c1a433b07e65c

duplicates:

  • SR-4477 Protocol composition results in EXC_BAD_ACCESS

Issue Description:

App defines two protocols and typealias Event that is an union of those two protocols. Then it defines class Subscription that conforms to those two protocols. When an array of Subscription 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"]

@belkadan
Copy link
Contributor

@jckarter, does this sound familiar? Are there problems with dynamic casting and protocol compositions?

@jckarter
Copy link
Member

Yeah, this smells like a dup of SR-4477, which is already fixed in master and the 4.0 branch. schwarja (JIRA User) can you verify that this is fixed in a snapshot toolchain?

@swift-ci
Copy link
Collaborator Author

swift-ci commented Jun 1, 2017

Comment by Jan Schwarz (JIRA)

It looks good when I run it with Swift 4.0 snapshot. Thanks guys.

@jckarter
Copy link
Member

jckarter commented Jun 1, 2017

Thanks!

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@AnthonyLatsis AnthonyLatsis added the crash Bug: A crash, i.e., an abnormal termination of software label Dec 12, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
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
Projects
None yet
Development

No branches or pull requests

4 participants