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-14858] Crash when decomposing labeled tuple returned from a function #57205

Closed
swift-ci opened this issue Jun 30, 2021 · 1 comment
Closed
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler in itself

Comments

@swift-ci
Copy link
Collaborator

Previous ID SR-14858
Radar None
Original Reporter jonaszell97 (JIRA User)
Type Bug
Status Resolved
Resolution Done
Environment

Mac mini (M1, 2020)

macOS 11.4

Apple Swift version 5.4.2 (swiftlang-1205.0.28.2 clang-1205.0.19.57)

Target: arm64-apple-darwin20.5.0

Additional Detail from JIRA
Votes 0
Component/s Compiler
Labels Bug
Assignee None
Priority Medium

md5: 83eda0e5d9fd4f80c09b8eb02ae38a55

Issue Description:

The following code snippet causes the compiler to crash:

func getLabeledTuple() -> (label1: [Bool]?, label2: [Bool]?) {
    return (label1: nil, label2: nil)
}

func decomposeLabeledTuple() -> Int? {
    let (label1, label2) = getLabeledTuple()
    guard let label1 = label1, let label2 = label2 else {
        return nil
    }
    return nil
}

Command:

swiftc test.swift -o test

Stack Trace:

Stored value type does not match pointer operand type!

store %swift.bridge* %17, i64* %1, align 8

i64Stored value type does not match pointer operand type!

store %swift.bridge* %25, i64* %4, align 8

i64in function $s4test21decomposeLabeledTupleSiSgyF

<unknown>:0: error: fatal error encountered during compilation; please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project

<unknown>:0: note: Broken function found, compilation aborted!

Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the project and the crash backtrace.

Stack dump:

0. Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file test.swift -target arm64-apple-darwin20.5.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.3.sdk -color-diagnostics -target-sdk-version 11.3 -module-name test -o /var/folders/b3/mxpqyntn0rqg9vcq1xv1p42w0000gn/T/test-b00f98.o

1. Apple Swift version 5.4.2 (swiftlang-1205.0.28.2 clang-1205.0.19.57)

2. Running pass 'Module Verifier' on function '@"$s4test21decomposeLabeledTupleSiSgyF"'

0 swift-frontend 0x0000000104fac6e0 llvm::sys::PrintStackTrace(llvm::raw_ostream&) + 52

1 swift-frontend 0x0000000104fab858 llvm::sys::RunSignalHandlers() + 128

2 swift-frontend 0x0000000104faccb0 SignalHandler(int) + 292

3 libsystem_platform.dylib 0x000000019cff6c44 _sigtramp + 56

4 libsystem_pthread.dylib 0x000000019cfab43c pthread_kill + 292

5 libsystem_c.dylib 0x000000019cef3460 abort + 104

6 swift-frontend 0x0000000100eedd28 std::_1::_throw_length_error(char const*) + 0

7 swift-frontend 0x0000000104f198c8 llvm::report_fatal_error(llvm::Twine const&, bool) + 252

8 swift-frontend 0x0000000104f197cc llvm::report_fatal_error(llvm::Twine const&, bool) + 0

9 swift-frontend 0x0000000104ec3ef0 void llvm::VerifierSupport::CheckFailed<llvm::Instruction*, llvm::MDNode const*>(llvm::Twine const&, llvm::Instruction* const&, llvm::MDNode const* const&) + 0

10 swift-frontend 0x0000000104e688c8 llvm::FPPassManager::runOnFunction(llvm::Function&) + 1136

11 swift-frontend 0x0000000104e67e80 llvm::legacy::FunctionPassManagerImpl::run(llvm::Function&) + 96

12 swift-frontend 0x0000000104e6e4f8 llvm::legacy::FunctionPassManager::run(llvm::Function&) + 336

13 swift-frontend 0x000000010120230c swift::performLLVMOptimizations(swift::IRGenOptions const&, llvm::Module*, llvm::TargetMachine*) + 1484

14 swift-frontend 0x0000000101203228 swift::performLLVM(swift::IRGenOptions const&, swift::DiagnosticEngine&, llvm::sys::SmartMutex<false>, llvm::GlobalVariable, llvm::Module*, llvm::TargetMachine*, llvm::StringRef, swift::UnifiedStatsReporter*) + 2464

15 swift-frontend 0x0000000100ef954c 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*) + 3084

16 swift-frontend 0x0000000100eeb58c swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 5556

17 swift-frontend 0x0000000100e80460 main + 1136

18 libdyld.dylib 0x000000019cfc9450 start + 4

<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)

@typesanitizer
Copy link

I see this crash with Swift 5.4 on x86_64 as well, but it seems to be fixed on the main branch and in the Xcode 13 beta. Please verify with a development toolchain snapshot from swift.org or a recent beta from developer.apple.com .

@swift-ci swift-ci transferred this issue from apple/swift-issues Apr 25, 2022
This issue was closed.
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 in itself
Projects
None yet
Development

No branches or pull requests

2 participants