Skip to content

[SR-585] Segfault on Linux in code using "catch let error as NSError" #43202

Closed
@swift-ci

Description

@swift-ci
Previous ID SR-585
Radar rdar://problem/30766599
Original Reporter rothomp3 (JIRA User)
Type Bug
Status Resolved
Resolution Done

Attachment: Download

Environment

Ubuntu Linux 15.10
LLVM 3ebdbb2c7e, Clang f66c5bb67b, Swift e25cd88

Additional Detail from JIRA
Votes 8
Component/s Compiler
Labels Bug, RunTimeCrash, Runtime
Assignee rothomp3 (JIRA)
Priority Medium

md5: f2030dd3a4949c21dd4280ad4f13922d

is duplicated by:

  • SR-3565 SIGSEGV: invalid address constructing AnyError from NSError
  • SR-1380 NSFileManager.moveItem(atPath:toPath:) segfaults on Ubuntu 15.10

relates to:

  • SR-1547 NSData causes segmentation fault

Issue Description:

Short example to reproduce the problem:

import Foundation

do {
    throw NSError(domain: "com.mydomain", code: -1, userInfo: [NSLocalizedDescriptionKey: "an error!"])
} catch let error as NSError {
    print(error.userInfo)
}

Backtrace from "swift errortest.swift":

#​0 0x0000000003042448 llvm::sys::PrintStackTrace(llvm::raw_ostream&) (/home/robert/swift/usr/bin/swift+0x3042448)
#​1 0x0000000003040c46 llvm::sys::RunSignalHandlers() (/home/robert/swift/usr/bin/swift+0x3040c46)
#​2 0x0000000003042f76 SignalHandler(int) (/home/robert/swift/usr/bin/swift+0x3042f76)
#​3 0x00007fa62486ad10 __restore_rt (/lib/x86_64-linux-gnu/libpthread.so.0+0x10d10)
#​4 0x00007fa621bb2eb7 swift_dynamicCast (/home/robert/swift/usr/lib/swift/linux/libswiftCore.so+0x2fceb7)
#​5 0x00007fa624c7b1b2
#&#8203;6 0x0000000000d1f6c4 llvm::MCJIT::runFunction(llvm::Function*, llvm::ArrayRef<llvm::GenericValue>) (/home/robert/swift/usr/bin/swift+0xd1f6c4)
#&#8203;7 0x0000000000d22ccf llvm::ExecutionEngine::runFunctionAsMain(llvm::Function*, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, char const* const*) (/home/robert/swift/usr/bin/swift+0xd22ccf)
#&#8203;8 0x0000000000bfd338 swift::RunImmediately(swift::CompilerInstance&, std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > > > const&, swift::IRGenOptions&, swift::SILOptions const&) (/home/robert/swift/usr/bin/swift+0xbfd338)
#&#8203;9 0x00000000007775d4 performCompile(swift::CompilerInstance&, swift::CompilerInvocation&, llvm::ArrayRef<char const*>, int&) (/home/robert/swift/usr/bin/swift+0x7775d4)
#&#8203;10 0x0000000000772b89 frontend_main(llvm::ArrayRef<char const*>, char const*, void*) (/home/robert/swift/usr/bin/swift+0x772b89)
#&#8203;11 0x000000000076e276 main (/home/robert/swift/usr/bin/swift+0x76e276)
#&#8203;12 0x00007fa6231f0a40 __libc_start_main /build/buildd/glibc-2.21/csu/libc-start.c:323:0
#&#8203;13 0x000000000076d799 _start (/home/robert/swift/usr/bin/swift+0x76d799)
Stack dump:
0.  Program arguments: /home/robert/swift/usr/bin/swift -frontend -interpret ./errortest.swift -target x86_64-unknown-linux-gnu -disable-objc-interop -module-name errortest 

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.compilerThe Swift compiler itselfcrashBug: A crash, i.e., an abnormal termination of softwarerun-time crashBug → crash: Swift code crashed during executionruntimeThe Swift Runtime

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions