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-1380] NSFileManager.moveItem(atPath:toPath:) segfaults on Ubuntu 15.10 #4156

Closed
Bouke opened this issue May 2, 2016 · 5 comments
Closed

Comments

@Bouke
Copy link
Contributor

Bouke commented May 2, 2016

Previous ID SR-1380
Radar None
Original Reporter @Bouke
Type Bug
Status Closed
Resolution Duplicate
Additional Detail from JIRA
Votes 0
Component/s Foundation
Labels Bug, RunTimeCrash
Assignee None
Priority Medium

md5: 8b5c4469cb4daaed76121aa11c7877e9

duplicates:

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

Issue Description:

$touch somefile
$swift
Welcome to Swift version 3.0-dev (LLVM 752e1430fc, Clang 1e6cba3ce3, Swift 56052cfe61). Type :help for assistance.
  1> import Foundation 
  2> NSFileManager.defaultManager().fileExists(atPath: "somefile")
$R0: Bool = true
  3> try! NSFileManager.defaultManager().moveItem(atPath: "somefile", toPath: "otherfile")
Execution interrupted. Enter code to recover and continue.
Enter LLDB commands to investigate (type :help for assistance.)
  4> :bt
* thread #&#8203;1: tid = 26598, 0x00007ffff7b22592 libswiftCore.so`swift::TargetExistentialTypeMetadata<swift::InProcess>::projectValue(swift::OpaqueValue const*) const + 34, name = 'repl_swift', stop reason = signal SIGSEGV: invalid address (fault address: 0x90)
  * frame #&#8203;0: 0x00007ffff7b22592 libswiftCore.so`swift::TargetExistentialTypeMetadata<swift::InProcess>::projectValue(swift::OpaqueValue const*) const + 34
    frame #&#8203;1: 0x00007ffff7ae91ec libswiftCore.so`findDynamicValueAndType(swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::OpaqueValue*&, swift::TargetMetadata<swift::InProcess> const*&, bool&) + 44
    frame #&#8203;2: 0x00007ffff7ae9edc libswiftCore.so`_dynamicCastToExistential(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*, swift::TargetExistentialTypeMetadata<swift::InProcess> const*, swift::DynamicCastFlags) + 60
    frame #&#8203;3: 0x00007ffff7ae9903 libswiftCore.so`swift_dynamicCast + 659
    frame #&#8203;4: 0x00007ffff79aa80b libswiftCore.so`generic specialization <preserving fragile attribute, Swift.ErrorProtocol, Swift.String with Swift.String : Swift.OutputStream in Swift> of Swift._debugPrint_unlocked <A, B where B: Swift.OutputStream> (A, inout B) -> () + 155
    frame #&#8203;5: 0x00007ffff7946b45 libswiftCore.so`swift_unexpectedError + 261
    frame #&#8203;6: 0x00007ffff7fed12e $__lldb_expr6`main + 302
    frame #&#8203;7: 0x00000000004009a0 repl_swift`__gmon_start__ + 16
  5> import Glibc
  6> rename("somefile", "otherfile")
$R1: Int32 = 0

Using the latest snapshot (april 25th).

@ddunbar
Copy link
Member

ddunbar commented May 6, 2016

/cc @parkera @phausler

@parkera
Copy link
Member

parkera commented May 6, 2016

Huh, it's implemented the same way as your `rename`.

@Bouke
Copy link
Contributor Author

Bouke commented May 7, 2016

guard self.fileExists(atPath: dstPath) else { throw... }

The destination should not exist; so the negative should be the case:

guard !self.fileExists(atPath: dstPath) else { throw... }

I'll submit a PR for this.

However, apparently printing the error segfaults, I don't think it is supposed to do that?

do {
    throw NSError(domain: NSCocoaErrorDomain, code: NSCocoaError.FileWriteFileExistsError.rawValue, userInfo: [NSFilePathErrorKey : "abc" as NSString])
} catch let error {
    print(error)
}

@parkera
Copy link
Member

parkera commented May 7, 2016

Is there a bug in NSError's string conversion function maybe?

@ffried
Copy link
Contributor

ffried commented Feb 28, 2017

Just had a similar problem with NSError being thrown by JSONSerialization.
This is very likely the same issue as SR-585.

@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

4 participants