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-8750] Segmentation Fault 11 when bridging NSSet<id<MyObjCProtocol>> * to swift #51258

Open
swift-ci opened this issue Sep 14, 2018 · 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

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-8750
Radar rdar://problem/44460364
Original Reporter hannesoid (JIRA User)
Type Bug

Attachment: Download

Environment

Xcode 10 GM, Swift 4, Swift 4.2

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

md5: 1e58ba560df7d4fb0d63d2bf82937816

Issue Description:

This code causes a Segmentation Fault 11

@objc class MyObjCObject1: NSObject, MyObjCProtocol {}
@objc class MyObjCObject2: NSObject, MyObjCProtocol {}

// Compiler crash:
let producesSegfault = MyObjCController(set: [MyObjCObject1(), MyObjCObject2()]) 

// MyObjCController initializer is defined in ObjC:
// - (instancetype)initWithSet:(NSSet<id<MyObjCProtocol>> *)selectedObjects
// mapped to swift: init(set selectedObjects: Set<AnyHashable>)

An example project is attached.

@belkadan
Copy link
Contributor

With assertions:

Unhandled coercion
UNREACHABLE executed at /Volumes/Data/swift-public/swift/lib/Sema/CSApply.cpp:6925!

1.  While type-checking declaration 0x7f81dfe2f8a8 at /Users/jrose/Downloads/Segfault11Example/SegmentationFaultExample/SegfaultingSwift.swift:24:1
2.  While type-checking expression at [/Users/jrose/Downloads/Segfault11Example/SegmentationFaultExample/SegfaultingSwift.swift:24:24 - line:24:62] RangeText="MyObjCController(set: [myObj1, myObj2])"

@belkadan
Copy link
Contributor

Weirdly and somewhat worryingly, adding an explicit as Set<AnyHashable> makes the crash go away for me. At least there's a workaround!

@swift-ci create

@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
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
Projects
None yet
Development

No branches or pull requests

3 participants