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-3565] SIGSEGV: invalid address constructing AnyError from NSError #4302

Closed
swift-ci opened this issue Jan 6, 2017 · 1 comment
Closed

Comments

@swift-ci
Copy link
Contributor

swift-ci commented Jan 6, 2017

Previous ID SR-3565
Radar None
Original Reporter ratkins (JIRA User)
Type Bug
Status Resolved
Resolution Duplicate
Environment

Swift Linux 3.1-dev and 3.0.2-RELEASE

Additional Detail from JIRA
Votes 0
Component/s Foundation, Standard Library
Labels Bug, Linux, RunTimeCrash
Assignee ratkins (JIRA)
Priority Medium

md5: 5b9d3230b7ac7f688bfb307915146db5

duplicates:

  • SR-585 Segfault on Linux in code using "catch let error as NSError"

Issue Description:

I added a feature to Result to make its AnyError type implement LocalizedError and delegate to the wrapped error. This works fine on Swift on Darwin, but fails on Linux:

$ swift -I.build/debug -L.build/debug -lResult                              
Welcome to Swift version 3.0.2 (swift-3.0.2-RELEASE). Type :help for assistance.
  1> import Foundation
  2> import Result
  3> let r = Result<String, AnyError>("a")
r: Result.Result<String, Result.AnyError> = success {
  success = "a"
}

[...]

  8> let nse = NSError(domain: "Foo", code: 42, userInfo: [NSLocalizedDescriptionKey: "localized description"]) 
nse: Foundation.NSError = {
  Foundation.NSObject = {}
  _domain = "Foo"
  _code = 42
  _userInfo = 1 key/value pair {
    [0] = {
      key = "NSLocalizedDescription"
      value = "localized description"
    }
  }
}
  9> print(nse.localizedDescription)
localized description
 10> print(nse.userInfo[NSLocalizedDescriptionKey])
Optional("localized description")
 11> let ae = AnyError(nse)
ae: Result.AnyError = {
  error = <extracting data from value failed>

}
Execution interrupted. Enter code to recover and continue.
Enter LLDB commands to investigate (type :help for assistance.)
 12> :bt
* thread #&#8203;1: tid = 1401, 0x00007ffff7cde9cf libswiftCore.so`_dynamicCastFromExistential(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetExistentialTypeMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*, swift::DynamicCastFlags) + 191, name = 'repl_swift', stop reason = signal SIGSEGV: invalid address (fault address: 0x0)
  * frame #&#8203;0: 0x00007ffff7cde9cf libswiftCore.so`_dynamicCastFromExistential(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetExistentialTypeMetadata<swift::InProcess> const*, swift::TargetMetadata<swift::InProcess> const*, swift::DynamicCastFlags) + 191
    frame #&#8203;1: 0x00007ffff7cde49b libswiftCore.so`swift_dynamicCast + 955
    frame #&#8203;2: 0x00007ffff7f582fb libResult.so`AnyError.init(error=Error @ 0x00007fffffffe500, self=Result.AnyError @ 0x00007fffffffe508) -> AnyError + 91 at Result.swift:197
    frame #&#8203;3: 0x00007ffff7f49e4d $__lldb_expr24`main + 109
    frame #&#8203;4: 0x00000000004009f0 repl_swift`swift_once + 16
    frame #&#8203;5: 0x00007fffffffe550
    frame #&#8203;6: 0x00007ffff6dd6830 libc.so.6`__libc_start_main + 240
    frame #&#8203;7: 0x0000000000400a19 repl_swift`_start + 41
 12>  

@aciidb0mb3r confirms the same result on the 3.1-dev snapshot of January 4.

@jckarter
Copy link
Member

Looks like SR-585. Should be fixed now.

@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

2 participants