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

Compiler crash when throwing from a throws(Never) function #73053

Open
Jnosh opened this issue Apr 16, 2024 · 0 comments
Open

Compiler crash when throwing from a throws(Never) function #73053

Jnosh opened this issue Apr 16, 2024 · 0 comments
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 triage needed This issue needs more specific labels

Comments

@Jnosh
Copy link
Contributor

Jnosh commented Apr 16, 2024

Description

Throwing from a throws(Never) function crashes swiftc.

Reproduction

enum MyError: Error {
    case failed
}

func foo() throws(Never) {
    throw MyError.failed
}

Stack dump

Stack dump:
0.	Program arguments: /Users/<user>/Library/Developer/Toolchains/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-04-15-a.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file main.swift -target arm64-apple-macosx14.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.4.sdk -color-diagnostics -swift-version 6 -empty-abi-descriptor -resource-dir /Users/<user>/Library/Developer/Toolchains/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-04-15-a.xctoolchain/usr/lib/swift -module-name main -target-sdk-version 14.4 -target-sdk-name macosx14.4 -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -plugin-path /Users/<user>/Library/Developer/Toolchains/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-04-15-a.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Users/<user>/Library/Developer/Toolchains/swift-6.0-DEVELOPMENT-SNAPSHOT-2024-04-15-a.xctoolchain/usr/local/lib/swift/host/plugins -o /var/folders/mk/5k70fbgj28g370g9tzg97n_80000gn/T/TemporaryDirectory.p0XXZQ/main-1.o
1.	Apple Swift version 6.0-dev (LLVM c5ac128e678cf31, Swift 59748d9cf60064b)
2.	Compiling with the current language version
3.	While walking into body of 'foo()' (at main.swift:6:1)
Stack dump without symbol names (ensure you have llvm-symbolizer in your PATH or set the environment var `LLVM_SYMBOLIZER_PATH` to point to it):
0  swift-frontend           0x0000000109906e08 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x00000001099055d4 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000109907450 SignalHandler(int) + 304
3  libsystem_platform.dylib 0x0000000194407584 _sigtramp + 56
4  libsystem_pthread.dylib  0x00000001943d6c20 pthread_kill + 288
5  libsystem_c.dylib        0x00000001942e3a20 abort + 180
6  swift-frontend           0x0000000105aea868 (anonymous namespace)::Verifier::checkSameType(swift::Type, swift::Type, char const*) + 260
7  swift-frontend           0x0000000105adb334 (anonymous namespace)::Verifier::walkToStmtPost(swift::Stmt*) + 1508
8  swift-frontend           0x0000000105af1544 swift::Stmt* (anonymous namespace)::Traversal::traverse<swift::Stmt>(swift::ASTWalker::PreWalkResult<swift::Stmt*>, llvm::function_ref<swift::Stmt* (swift::Stmt*)>, llvm::function_ref<swift::ASTWalker::PostWalkResult<swift::Stmt*> (swift::Stmt*)>) + 104
9  swift-frontend           0x0000000105af1754 swift::Stmt* llvm::function_ref<swift::Stmt* (swift::Stmt*)>::callback_fn<(anonymous namespace)::Traversal::doIt(swift::Stmt*)::'lambda'(swift::Stmt*)>(long, swift::Stmt*) + 448
10 swift-frontend           0x0000000105af1530 swift::Stmt* (anonymous namespace)::Traversal::traverse<swift::Stmt>(swift::ASTWalker::PreWalkResult<swift::Stmt*>, llvm::function_ref<swift::Stmt* (swift::Stmt*)>, llvm::function_ref<swift::ASTWalker::PostWalkResult<swift::Stmt*> (swift::Stmt*)>) + 84
11 swift-frontend           0x0000000105af3b10 (anonymous namespace)::Traversal::visitAbstractFunctionDecl(swift::AbstractFunctionDecl*) + 660
12 swift-frontend           0x0000000105af28fc (anonymous namespace)::Traversal::visit(swift::Decl*) + 156
13 swift-frontend           0x0000000105aefde4 (anonymous namespace)::Traversal::doIt(swift::Decl*) + 288
14 swift-frontend           0x0000000105aefcb8 swift::Decl::walk(swift::ASTWalker&) + 32
15 swift-frontend           0x0000000105c99344 swift::SourceFile::walk(swift::ASTWalker&) + 196
16 swift-frontend           0x0000000105ad9a6c swift::verify(swift::SourceFile&) + 96
17 swift-frontend           0x0000000105db01e8 swift::TypeCheckSourceFileRequest::cacheResult(std::__1::tuple<>) const + 76
18 swift-frontend           0x00000001057ee98c swift::performTypeChecking(swift::SourceFile&) + 92
19 swift-frontend           0x00000001046f73ac bool llvm::function_ref<bool (swift::SourceFile&)>::callback_fn<swift::CompilerInstance::performSema()::$_7>(long, swift::SourceFile&) + 16
20 swift-frontend           0x00000001046f118c swift::CompilerInstance::forEachFileToTypeCheck(llvm::function_ref<bool (swift::SourceFile&)>) + 76
21 swift-frontend           0x00000001046f1120 swift::CompilerInstance::performSema() + 76
22 swift-frontend           0x00000001044c6d54 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 60
23 swift-frontend           0x00000001044b81e0 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 708
24 swift-frontend           0x00000001044b714c swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2380
25 swift-frontend           0x00000001042d1a78 swift::mainEntry(int, char const**) + 3096
26 dyld                     0x000000019404e0e0 start + 2360

Expected behavior

The compiler should not crash.

Environment

Apple Swift version 6.0-dev (LLVM c5ac128e678cf31, Swift 59748d9)
Target: arm64-apple-macosx14.0

Additional information

No response

@Jnosh Jnosh added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. crash Bug: A crash, i.e., an abnormal termination of software triage needed This issue needs more specific labels labels Apr 16, 2024
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 triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant