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-2920] NSError dynamic conditional cast crash #45514

Closed
swift-ci opened this issue Oct 12, 2016 · 8 comments
Closed

[SR-2920] NSError dynamic conditional cast crash #45514

swift-ci opened this issue Oct 12, 2016 · 8 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 regression run-time crash Bug → crash: Swift code crashed during execution swift 3.0

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-2920
Radar rdar://problem/31404281
Original Reporter mhuusko5 (JIRA User)
Type Bug
Status Resolved
Resolution Done
Additional Detail from JIRA
Votes 1
Component/s Compiler
Labels Bug, 3.0Regression, RunTimeCrash
Assignee mhuusko5 (JIRA)
Priority Medium

md5: 97236bb0d0c0b9ccae0498bd9cb7453e

Issue Description:

private func catchError(_ error: NSError) -> Error {
    if let error = error as? URLError {

Could not cast value of type 'NSError' (0x11bab6270) to 'Foundation.URLError' (0x107e7dab0).

@swift-ci
Copy link
Collaborator Author

Comment by Mathew Huusko V (JIRA)

private func catchError(_ error: NSError) -> Error {
 if let error = (error as Swift.Error) as? URLError {

The above doesn't crash.

@belkadan
Copy link
Contributor

@DougGregor, you were looking at something like this, no?

@DougGregor
Copy link
Member

I don't recall seeing this issue. mhuusko5 (JIRA User), can you give us some sample code that triggers this?

@swift-ci
Copy link
Collaborator Author

Comment by Mathew Huusko V (JIRA)

That's really I've got really for context/nothing special is happening. An NSError is being passed in from an Objective-C API, and attempting to check if it's a Foundation.URLError crashes every time.

@swift-ci
Copy link
Collaborator Author

Comment by Tomáš Linhart (JIRA)

I have also encountered the problem myself.

It is quite easy to reproduce.

let error = NSError(domain: "RandomDomain", code: 0)
let urlError = error as? URLError

@belkadan
Copy link
Contributor

belkadan commented Apr 3, 2017

Still occurring on master.

@swift-ci create

@jckarter
Copy link
Member

Trying a fix for master: #9536
and for 4.0: #9537

@jckarter
Copy link
Member

Merged. Should be fixed in future seeds.

@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 regression run-time crash Bug → crash: Swift code crashed during execution swift 3.0
Projects
None yet
Development

No branches or pull requests

5 participants