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-2713] Printing an NSError casted to Error results in a crash #45317

Open
swift-ci opened this issue Sep 21, 2016 · 2 comments
Open

[SR-2713] Printing an NSError casted to Error results in a crash #45317

swift-ci opened this issue Sep 21, 2016 · 2 comments
Assignees
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software Linux Platform: Linux run-time crash Bug → crash: Swift code crashed during execution standard library Area: Standard library umbrella

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-2713
Radar None
Original Reporter seabaylea (JIRA User)
Type Bug
Additional Detail from JIRA
Votes 1
Component/s Standard Library
Labels Bug, Linux, RunTimeCrash
Assignee @DougGregor
Priority Medium

md5: 9b696cc035ad26ac58324d6b9a4259f8

Issue Description:

When running the following simple test case on Linux, we get a crash with a SIGSEGV:

import Foundation

let error = NSError(domain: NSCocoaErrorDomain, code: CocoaError.propertyListReadCorrupt.rawValue, userInfo: nil) as Error
print(error)

Note that when running the same code on Darwin, the result is:

Error Domain=NSCocoaErrorDomain Code=3840 "The data couldn’t be read because it isn’t in the correct format."
Program ended with exit code: 0

The backtrace for the SIGSEGV is as follows:

(lldb) bt
* thread #​1: tid = 24648, 0x00007ffff7d0ced8 libswiftCore.so`swift_getErrorValue + 8, name = 'errortest', stop reason = signal SIGSEGV: invalid address (fault address: 0x90)
  * frame #​0: 0x00007ffff7d0ced8 libswiftCore.so`swift_getErrorValue + 8
    frame #​1: 0x0000000000401123 errortest`main + 211 at errortest.swift:5
    frame #&#8203;2: 0x00007ffff5ce3ac0 libc.so.6`__libc_start_main(main=(errortest`main at errortest.swift), argc=1, argv=0x00007fffffffe5c8, init=<unavailable>, fini=<unavailable>, rtld_fini=<unavailable>, stack_end=0x00007fffffffe5b8) + 240 at libc-start.c:289
    frame #&#8203;3: 0x0000000000400f79 errortest`_start + 41
@belkadan
Copy link
Contributor

@DougGregor, Error's just a normal protocol on Linux and NSError a normal conforming type, right?

@DougGregor
Copy link
Member

Yes, there's no bridging there. I bet some part of the compiler is special-casing `NSError` when Objective-C interoperability is disabled.

@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. crash Bug: A crash, i.e., an abnormal termination of software Linux Platform: Linux run-time crash Bug → crash: Swift code crashed during execution standard library Area: Standard library umbrella
Projects
None yet
Development

No branches or pull requests

4 participants