Skip to content

Compiler exit with non-zero code #68916

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

Closed
mattyoung opened this issue Oct 2, 2023 · 1 comment
Closed

Compiler exit with non-zero code #68916

mattyoung opened this issue Oct 2, 2023 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself declarations Feature: declarations patterns Feature: patterns properties Feature: properties SILGen Area → compiler: The SIL generation stage struct Feature → type declarations: Structure declarations swift 5.9 tuple patterns Feature → patterns: Tuple patterns type declarations Feature → declarations: Type declarations unexpected behavior Bug: Unexpected behavior or incorrect output

Comments

@mattyoung
Copy link

mattyoung commented Oct 2, 2023

Description

When compiling the following code, the compiler exit with non-zero code.

Steps to reproduce

struct Foo {
    let value: Int

    let (aaa, bbb) = ("aaa", "bbb")     // bbb is wrong! it's "aaa" but should be "bbb"

        // uncomment this to make the compiler fail with non-zero exit
    let (z1, z2, z3) = ("one", 1, Double.pi)   // !!!


    func tellMe() {
        print(foo.aaa)
        print(foo.bbb)          // output:  aaa


        assert(aaa == "aaa")
        assert(bbb == "bbb", "bbb should be bbb but it's \(bbb)")
    }

}


let foo = Foo(value: 1)


foo.tellMe()




print("Hello")

Compile the above on the command line and run the resulting executable to see it output this:

swiftc foo.swift
PtrToInt source must be pointer
  %27 = ptrtoint i64 %24 to double
<unknown>:0: error: fatal error encountered during compilation; please submit a bug report (https://swift.org/contributing/#reporting-bugs)
<unknown>:0: note: Broken module found, compilation aborted!
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /Library/Developer/CommandLineTools/usr/bin/swift-frontend -frontend -c -primary-file foo.swift -target arm64-apple-darwin23.0.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk -color-diagnostics -external-plugin-path /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/lib/swift/host/plugins#/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/bin/swift-plugin-server -external-plugin-path /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/local/lib/swift/host/plugins#/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/bin/swift-plugin-server -external-plugin-path /Library/Developer/Developer/usr/lib/swift/host/plugins#/Library/Developer/Developer/usr/bin/swift-plugin-server -external-plugin-path /Library/Developer/Developer/usr/local/lib/swift/host/plugins#/Library/Developer/Developer/usr/bin/swift-plugin-server -plugin-path /Library/Developer/CommandLineTools/usr/lib/swift/host/plugins -plugin-path /Library/Developer/CommandLineTools/usr/local/lib/swift/host/plugins -target-sdk-version 14.0 -module-name foo -o /var/folders/n0/7d8p6c1n6bv_lzl_rftmk7mm0000gn/T/foo-032829.o
1.	Apple Swift version 5.9 (swiftlang-5.9.0.128.108 clang-1500.0.40.1)
2.	Compiling with the current language version
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           0x0000000107c7f14c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x000000010a7fdf2c llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x000000010653f10c SignalHandler(int) + 352
3  libsystem_platform.dylib 0x0000000181fb1a24 _sigtramp + 56
4  libsystem_pthread.dylib  0x0000000181f82cc0 pthread_kill + 288
5  libsystem_c.dylib        0x0000000181e92a50 abort + 180
6  swift-frontend           0x000000010a7a7374 llvm::vfs::recursive_directory_iterator::increment(std::__1::error_code&) + 0
7  swift-frontend           0x0000000107c2f890 llvm::report_fatal_error(llvm::Twine const&, bool) + 280
8  swift-frontend           0x0000000107c2f778 llvm::report_fatal_error(llvm::Twine const&, bool) + 0
9  swift-frontend           0x00000001098125a4 std::__1::__function::__func<llvm::CombinerHelper::matchCombineFAddFpExtFMulToFMadOrFMAAggressive(llvm::MachineInstr&, std::__1::function<void (llvm::MachineIRBuilder&)>&)::$_52, std::__1::allocator<llvm::CombinerHelper::matchCombineFAddFpExtFMulToFMadOrFMAAggressive(llvm::MachineInstr&, std::__1::function<void (llvm::MachineIRBuilder&)>&)::$_52>, void (llvm::MachineIRBuilder&)>::operator()(llvm::MachineIRBuilder&) + 0
10 swift-frontend           0x000000010a4ae490 llvm::PassManager<llvm::Module, llvm::AnalysisManager<llvm::Module>>::run(llvm::Module&, llvm::AnalysisManager<llvm::Module>&) + 224
11 swift-frontend           0x0000000109618990 swift::performLLVMOptimizations(swift::IRGenOptions const&, llvm::Module*, llvm::TargetMachine*, llvm::raw_pwrite_stream*) + 4252
12 swift-frontend           0x00000001061465bc swift::performLLVM(swift::IRGenOptions const&, swift::DiagnosticEngine&, llvm::sys::SmartMutex<false>*, llvm::GlobalVariable*, llvm::Module*, llvm::TargetMachine*, llvm::StringRef, swift::UnifiedStatsReporter*) + 2736
13 swift-frontend           0x000000010a7b0c74 generateCode(swift::CompilerInstance&, llvm::StringRef, llvm::Module*, llvm::GlobalVariable*) + 252
14 swift-frontend           0x000000010a093618 performCompileStepsPostSILGen(swift::CompilerInstance&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) + 1708
15 swift-frontend           0x000000010a7b591c performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1748
16 swift-frontend           0x000000010a7b9474 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4568
17 swift-frontend           0x000000010a0ff4e0 swift::mainEntry(int, char const**) + 4116
18 dyld                     0x0000000181c09058 start + 2224
<unknown>:0: error: unable to execute command: Abort trap: 6
<unknown>:0: error: compile command failed due to signal 6 (use -v to see invocation)

Expected behavior
Compiler should not exit abnormally.

@mattyoung mattyoung added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels labels Oct 2, 2023
@jckarter
Copy link
Contributor

jckarter commented Oct 3, 2023

Same bug as #68915.

@jckarter jckarter closed this as completed Oct 3, 2023
@jckarter jckarter added duplicate Resolution: Duplicates another issue and removed triage needed This issue needs more specific labels labels Oct 3, 2023
@AnthonyLatsis AnthonyLatsis added compiler The Swift compiler itself patterns Feature: patterns SILGen Area → compiler: The SIL generation stage unexpected behavior Bug: Unexpected behavior or incorrect output struct Feature → type declarations: Structure declarations properties Feature: properties declarations Feature: declarations type declarations Feature → declarations: Type declarations tuple patterns Feature → patterns: Tuple patterns swift 5.9 labels Jan 29, 2024
@AnthonyLatsis AnthonyLatsis removed the duplicate Resolution: Duplicates another issue label May 6, 2025
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. compiler The Swift compiler itself declarations Feature: declarations patterns Feature: patterns properties Feature: properties SILGen Area → compiler: The SIL generation stage struct Feature → type declarations: Structure declarations swift 5.9 tuple patterns Feature → patterns: Tuple patterns type declarations Feature → declarations: Type declarations unexpected behavior Bug: Unexpected behavior or incorrect output
Projects
None yet
Development

No branches or pull requests

3 participants