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-11344] EXC_BAD_INSTRUCTION when bridging (NSError() as Error) to NSError #3293

Closed
cltnschlosser opened this issue Aug 21, 2019 · 2 comments

Comments

@cltnschlosser
Copy link

Previous ID SR-11344
Radar None
Original Reporter @cltnschlosser
Type Bug
Status Resolved
Resolution Invalid
Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug, RunTimeCrash
Assignee None
Priority Medium

md5: 05ccefda8332df816343f54152e02cdb

Issue Description:

Runtime crash when bridging Error to NSError if it was created with: NSError()

The following playground reproduces the issue:

let thisIsFine: Error = NSError(domain: "Test", code: 0)
thisIsFine as NSError
let thisCrashes: Error = NSError()
thisCrashes as NSError
@theblixguy
Copy link

Crashes with this message:

-[NSError init] called; this results in an invalid NSError instance. It will raise an exception in a future release. Please call errorWithDomain:code:userInfo: or initWithDomain:code:userInfo:. This message shown only once.

Partial stack trace:

5  libswiftCore.dylib       0x00000001223a6ff6 $ss23_getErrorDomainNSStringyyXlSPyxGs0B0RzlF + 22
6  libswiftCore.dylib       0x00000001222e9539 _swift_stdlib_bridgeErrorToNSError + 297
7  libswiftCore.dylib       0x000000011bdac0dd _swift_stdlib_bridgeErrorToNSError + 4188810445

@belkadan
Copy link

Right, that's "correct" behavior. NSError() has never actually worked, and hopefully the Foundation folks will be able to deprecate it properly soon.

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
@shahmishal shahmishal transferred this issue from apple/swift May 5, 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

3 participants