swiftlang / swift

The Swift Programming Language
https://swift.org
Apache License 2.0
67.56k stars 10.35k forks source link

compiler crash involving Mutex #77304

Open wtholliday opened 13 hours ago

wtholliday commented 13 hours ago

Description

I added a few lines to my project and the compiler is crashing. Need to enable C++ interop. Concise repro attached.

Reproduction

import Synchronization

public class SomeClass { }

public class Thing {
    public static let rc = Mutex(SomeClass())
}

Stack dump

1.  Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4)
2.  Compiling with the current language version
3.  While generating Clang header
4.  While printing 'Thing' (at /Users/holliday/Sculptura/SculpturaBase/Sources/SculpturaBase/Thing.swift:7:8)
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           0x0000000105b0e9ac llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000105b0cc00 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000105b0ef78 SignalHandler(int) + 292
3  libsystem_platform.dylib 0x000000018b4d4184 _sigtramp + 56
4  swift-frontend           0x000000010065058c swift::DeclAndTypePrinter::Implementation::visitVarDecl(swift::VarDecl*) + 532
5  swift-frontend           0x000000010065058c swift::DeclAndTypePrinter::Implementation::visitVarDecl(swift::VarDecl*) + 532
6  swift-frontend           0x00000001006562cc void swift::DeclAndTypePrinter::Implementation::printMembers<false, llvm::iterator_range<swift::DeclIterator>>(llvm::iterator_range<swift::DeclIterator>&&) + 692
7  swift-frontend           0x000000010065a4e0 void llvm::function_ref<void ()>::callback_fn<swift::DeclAndTypePrinter::Implementation::visitClassDecl(swift::ClassDecl*)::'lambda'()>(long) + 56
8  swift-frontend           0x000000010067ac20 swift::ClangClassTypePrinter::printClassTypeDecl(swift::ClassDecl const*, llvm::function_ref<void ()>, swift::DeclAndTypePrinter&) + 2888
9  swift-frontend           0x000000010064e79c swift::ASTVisitor<swift::DeclAndTypePrinter::Implementation, void, void, void, void, void, void>::visit(swift::Decl*) + 1296
10 swift-frontend           0x000000010064b90c swift::DeclAndTypePrinter::print(swift::Decl const*) + 448
11 swift-frontend           0x0000000100666058 (anonymous namespace)::ModuleWriter::write() + 4712
12 swift-frontend           0x0000000100667234 swift::printModuleContentsAsCxx(llvm::raw_ostream&, swift::ModuleDecl&, swift::SwiftToClangInteropContext&, bool, llvm::StringSet<llvm::MallocAllocator>&) + 1192
13 swift-frontend           0x00000001006750a4 swift::printAsClangHeader(llvm::raw_ostream&, swift::ModuleDecl*, llvm::StringRef, swift::FrontendOptions const&, swift::IRGenOptions const&, clang::HeaderSearch&) + 8824
14 swift-frontend           0x0000000100469ae0 swift::withOutputPath(swift::DiagnosticEngine&, llvm::vfs::OutputBackend&, llvm::StringRef, llvm::function_ref<bool (llvm::raw_pwrite_stream&)>) + 128
15 swift-frontend           0x00000001004be934 performEndOfPipelineActions(swift::CompilerInstance&) + 5752
16 swift-frontend           0x00000001004baf30 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 5200
17 swift-frontend           0x00000001004b8ea0 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3572
18 swift-frontend           0x000000010043ff64 swift::mainEntry(int, char const**) + 3680
19 dyld                     0x000000018b11c274 start + 2840

Expected behavior

No crash

Environment

swift-driver version: 1.115 Apple Swift version 6.0.2 (swiftlang-6.0.2.1.2 clang-1600.0.26.4) Target: arm64-apple-macosx15.0

Additional information

CompilerCrash.zip

wtholliday commented 13 hours ago

Crashes on latest snapshot off main as well:

1.    Apple Swift version 6.1-dev (LLVM f4b733c38006ec1, Swift f4bea5f7c0a7aa5)
2.    Compiling with effective version 5.10
3.    While generating Clang header
4.    While printing 'Thing' (at /Users/holliday/CompilerCrash/CompilerCrash/ContentView.swift:13:8)
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):