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-882] Generic protocol and subclassing breaks type safety and crashes at run time #43494

Closed
swift-ci opened this issue Mar 4, 2016 · 2 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 type checker Area → compiler: Semantic analysis

Comments

@swift-ci
Copy link
Collaborator

swift-ci commented Mar 4, 2016

Previous ID SR-882
Radar rdar://problem/25023230
Original Reporter tmpz (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Swift 2.2, Swift 3.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug, RunTimeCrash, TypeChecker
Assignee None
Priority Medium

md5: dce6fe503a38874036b1f49c80d7357d

Issue Description:

Implementing a generic protocol P in a base class B and redefining the same typealias of the generic protocol P both in the base class B and in a subclass S breaks type safety in combination with a genetic function on P.

Attachment "TypeSafety.swift" is an example of broken type safety where It's possible to assign a String to an Int

Attachment "RunTimeCrash.swift" is an example of broken type safety and a run time crash assigning a tuple (Int, Int) to a String

Both attachments reproduce the issue in Swift 2.2 and Swift 3.0

@swift-ci
Copy link
Collaborator Author

swift-ci commented Mar 5, 2016

Comment by Tommaso Piazza (JIRA)

Compiling and running RunTimeCrash.swift gives the following

$ ./swiftc --version
Swift version 3.0-dev (LLVM bb6ab4c0e1, Clang 5a705a66e0, Swift bf13150fa8)
Target: x86_64-apple-macosx10.9
$ ./swiftc -emit-executable RunTimeCrash.swift
$ ./RunTimeCrash
Assertion failed: (newval + quantum >= RC_ONE && "releasing reference with a refcount of zero"), function doDecrementShouldDeallocate, file /Users/blender/Code/lab/swift/include/swift/Runtime/../../../stdlib/public/SwiftShims/RefCount.h, line 207.
Abort trap: 6

@belkadan
Copy link
Contributor

Looks like these are fixed in Swift 3.1.

@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 type checker Area → compiler: Semantic analysis
Projects
None yet
Development

No branches or pull requests

3 participants