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-10445] EXC_BAD_INSTRUCTION when accessing property compiled with Xcode 10.2 #4575

Closed
swift-ci opened this issue Apr 10, 2019 · 11 comments
Closed
Assignees

Comments

@swift-ci
Copy link

Previous ID SR-10445
Radar rdar://49786768
Original Reporter vineetshah (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Xcode Version 10.2 (10E125)

macOS Version 10.14.4

iPhone X Simulator

Additional Detail from JIRA
Votes 3
Component/s Compiler, LLDB for Swift
Labels Bug, 5.0Regression
Assignee @aschwaighofer
Priority Medium

md5: 7b8d81d9943a8c1c1a7fd78f28934260

is duplicated by:

  • SR-10626 EXC_BREAKPOINT when creating a collection of specific type hierarchy.

Issue Description:

I am getting a consistent crash in my app target and tests when accessing a property under very specific conditions (see unit test in attached sample project). The issue is not present in Xcode 10.1.

When printing out the relevant variable on the line of the crash in lldb (`po orderStatuses`), I see:

expression produced error: error: /var/folders/84/26znbv2n5xsbl50vkk7f1_zr0000gn/T/expr33-b8f975..swift:1:93: error: 'WidgetOrderStatus' is not a member type of 'ArrayCrashTests'
Swift._DebuggerSupport.stringForPrintObject(Swift.UnsafePointer<Swift.Array<ArrayCrashTests.WidgetOrderStatus>>(bitPattern: 0x12b8714d0)!.pointee)

Each of the 3 changes below seems to stop the crash from happening:

  • Remove `creationDate` from the `Widget` struct

  • Remove the `WidgetOrder` wrapper enum and instead use `Widget` directly in its place

  • Convert the `shipped` property in `WidgetOrderStatus` to an Int (default value 0)

@swift-ci
Copy link
Author

Comment by Vineet Shah (JIRA)

@belkadan any updates on this? Note that it's not an LLDB crash as it's currently categorized as. It seems to be a compiler issue that results in crashes at runtime on iOS.

Given the severity of the crash and guaranteed reproducibility, this is preventing us from updating to Xcode 10.2, meanwhile all of our development phones have started auto-upgrading to iOS 12.2 so we're running out of devices to test on.

Thanks!

@belkadan
Copy link

I'm sorry, I can't really say anything here.

@swift-ci
Copy link
Author

Comment by Aditya Ayyakad (JIRA)

@belkadan it looks like the type of the array is getting erased?

```

(lldb) po Mirror(reflecting: orderStatuses).children
▿ AnyCollection<(label: Optional<String>, value: Any)>
▿ _box : <_CollectionBox<LazyMapSequence<Array<WidgetOrderStatus>, (label: Optional<String>, value: Any)>>: 0x6000005445a0>

```

This is preventing me from using Xcode 10.2 or Swift 5 at all with my apps. Please let me know if there's any other information I can provide for you so we can get this resolved as soon as possible.

@belkadan
Copy link

I'm sorry, I don't see how that comment is relevant.

This sounds a little like something Arnold fixed recently, so you could check a development snapshot from https://swift.org/download and see if the problem reproduces.

@swift-ci
Copy link
Author

Comment by Aditya Ayyakad (JIRA)

@belkadan Sorry but no the latest snapshot does not seem to work still. I tried it both from Xcode and the command line directly, but both crashed in the same way.

@belkadan
Copy link

Thanks, that's important to know.

@aschwaighofer
Copy link
Member

The initialization of the metadata of single case enums in Swift's runtime is broken. We miss initializing the extraInhabitants field.

You can introduce an extra empty case or not use a single case enum as a workaround.

@aschwaighofer
Copy link
Member

Will be fixed by apple/swift#24278 and apple/swift#24293

@eeckstein
Copy link
Member

Follow-up on our conversation from yesterday: Unfortunately there is no other workaround than to change the enum in the source code.

@swift-ci
Copy link
Author

swift-ci commented Jun 5, 2019

Comment by Vineet Shah (JIRA)

Can you confirm that changing the enum to `indirect` is a sufficient workaround?

@aschwaighofer
Copy link
Member

Yes. Making the enum indirect fixes the crash.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 7, 2022
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants