-
Notifications
You must be signed in to change notification settings - Fork 10.6k
Closed
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.crashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwaretriage neededThis issue needs more specific labelsThis issue needs more specific labels
Description
Description
If a @MainActor class that is generic and has at least one reference-type stored variable also has an isolated deinit, the complier crashes if optimization is enabled. If optimization is not enabled, compilation succeeds.
Reproduction
class AClass {}
indirect enum AnIndirectEnum {
case a
}
protocol AProtocol {}
var aProtocolExistential: any AProtocol {
struct Concrete: AProtocol {}
return Concrete()
}
actor AnActor {}
struct AStruct {}
enum AnEnum {
case a
}
@MainActor class GenericMainActorClass<T> {
// If any of these is present, the compiler crashes with -O
private var a = AClass()
private var b = AnIndirectEnum.a
private var c = aProtocolExistential
private var d = AnActor()
// These don't cause the crash
private var e = AStruct()
private var f = AnEnum.a
isolated deinit {}
}Stack dump
error: compile command failed due to signal 11 (use -v to see invocation)
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0. Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file IsolatedDeinitBug.swift -target arm64-apple-macosx15.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX26.0.sdk -color-diagnostics -Xcc -fcolor-diagnostics -O -new-driver-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-driver -empty-abi-descriptor -no-auto-bridging-header-chaining -module-name IsolatedDeinitBug -disable-clang-spi -target-sdk-version 26.0 -target-sdk-name macosx26.0 -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 -in-process-plugin-server-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins -enable-default-cmo -o /var/folders/y5/vsbxrsyd6s5d0h_zjb34y1m40000gp/T/TemporaryDirectory.50alMg/IsolatedDeinitBug-1.o
1. Apple Swift version 6.2 (swiftlang-6.2.0.19.9 clang-1700.3.19.1)
2. Compiling with effective version 5.10
3. While evaluating request IRGenRequest(IR Generation for file "IsolatedDeinitBug.swift")
4. While emitting IR SIL function "@$s17IsolatedDeinitBug21GenericMainActorClassCfD".
for 'deinit' (at IsolatedDeinitBug.swift:32:14)
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 0x0000000107289bcc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1 swift-frontend 0x000000010728755c llvm::sys::RunSignalHandlers() + 112
2 swift-frontend 0x000000010728a1f8 SignalHandler(int, __siginfo*, void*) + 344
3 libsystem_platform.dylib 0x0000000194c556a4 _sigtramp + 56
4 swift-frontend 0x000000010158b880 (anonymous namespace)::IRGenSILFunction::visitSILBasicBlock(swift::SILBasicBlock*) + 18888
5 swift-frontend 0x000000010158b880 (anonymous namespace)::IRGenSILFunction::visitSILBasicBlock(swift::SILBasicBlock*) + 18888
6 swift-frontend 0x00000001015857e8 (anonymous namespace)::IRGenSILFunction::emitSILFunction() + 15996
7 swift-frontend 0x0000000101581540 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 2836
8 swift-frontend 0x0000000101395c44 swift::irgen::IRGenerator::emitGlobalTopLevel(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&) + 2176
9 swift-frontend 0x000000010152f6a0 swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const + 4296
10 swift-frontend 0x00000001015802ec swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)17>::evaluateRequest(swift::IRGenRequest const&, swift::Evaluator&) + 180
11 swift-frontend 0x0000000101538d44 swift::IRGenRequest::OutputType swift::Evaluator::getResultUncached<swift::IRGenRequest, swift::IRGenRequest::OutputType swift::evaluateOrFatal<swift::IRGenRequest>(swift::Evaluator&, swift::IRGenRequest)::'lambda'()>(swift::IRGenRequest const&, swift::IRGenRequest::OutputType swift::evaluateOrFatal<swift::IRGenRequest>(swift::Evaluator&, swift::IRGenRequest)::'lambda'()) + 856
12 swift-frontend 0x00000001015323b8 swift::performIRGeneration(swift::FileUnit*, swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::GlobalVariable**) + 176
13 swift-frontend 0x0000000100ec9130 generateIR(swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, llvm::GlobalVariable*&, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>) + 156
14 swift-frontend 0x0000000100ec474c 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*) + 2108
15 swift-frontend 0x0000000100ec374c swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1032
16 swift-frontend 0x0000000100ec6a7c performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1764
17 swift-frontend 0x0000000100ec568c swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3580
18 swift-frontend 0x0000000100e46c6c swift::mainEntry(int, char const**) + 5412
19 dyld 0x000000019487ab98 start + 6076
Expected behavior
The code should compile without errors both with and without -O.
Environment
swift-driver version: 1.127.14.1 Apple Swift version 6.2 (swiftlang-6.2.0.19.9 clang-1700.3.19.1)
Target: arm64-apple-macosx15.0
Additional information
No response
fzy-github
Metadata
Metadata
Assignees
Labels
bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.A deviation from expected or documented behavior. Also: expected but undesirable behavior.crashBug: A crash, i.e., an abnormal termination of softwareBug: A crash, i.e., an abnormal termination of softwaretriage neededThis issue needs more specific labelsThis issue needs more specific labels