8000 Compiler Crash in SILMem2Reg in removeSingleBlockAllocation · Issue #81768 · swiftlang/swift · GitHub
[go: up one dir, main page]

Skip to content

Compiler Crash in SILMem2Reg in removeSingleBlockAllocation #81768

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

Open
tothambrus11 opened this issue May 25, 2025 · 1 comment
Open

Compiler Crash in SILMem2Reg in removeSingleBlockAllocation #81768

tothambrus11 opened this issue May 25, 2025 · 1 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 SIL

Comments

@tothambrus11
Copy link

Description

The 6.1 and 6.1.1 release Swift compiler is failing on MacOS in release build during the SILMem2Reg optimization. On Ubuntu and Windows, everything works fine, and 6.0 also works fine.

The assertion error originates from

assert(runningVals && runningVals->isStorageValid);

I suspect there was a small change in SILMem2Reg.cpp between the 6.1 and 6.0 release that caused (or revealed) this error.

Reproduction

For reproducing the problem, you can use this repository: https://github.com/tothambrus11/Archivist/tree/swift-compiler-crash
Run on macos using swift 6.1.

Stack dump

Assertion failed: (runningVals && runningVals->isStorageValid), function removeSingleBlockAllocation, file SILMem2Reg.cpp, line 2050.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /Users/runner/hostedtoolcache/swift-6.1.1-RELEASE-xcode/6.1.1/aarch64/usr/bin/swift-frontend -frontend -c /Users/runner/work/Archivist/Archivist/Tests/ArchiveTests/MacroTests.swift /Users/runner/work/Archivist/Archivist/Tests/ArchiveTests/ReadableArchiveTests.swift /Users/runner/work/Archivist/Archivist/Tests/ArchiveTests/SwiftArchivableTests.swift /Users/runner/work/Archivist/Archivist/Tests/ArchiveTests/WriteableArchiveTests.swift -supplementary-output-file-map /var/folders/w5/_8wgjw3j5cg6mgrth3s2kg9m0000gn/T/TemporaryDirectory.Lm7qdg/supplementaryOutputs-1 -target arm64-apple-macosx13.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -sdk /Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -I /Users/runner/work/Archivist/Archivist/.build/arm64-apple-macosx/release/Modules -I /Users/runner/hostedtoolcache/swift-6.1.1-RELEASE-xcode/6.1.1/aarch64/usr/lib/swift/macosx/testing -I /Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -F /Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/PrivateFrameworks -enable-testing -g -debug-info-format=dwarf -dwarf-version=4 -module-cache-path /Users/runner/work/Archivist/Archivist/.build/arm64-apple-macosx/release/ModuleCache -swift-version 6 -O -D SWIFT_PACKAGE -enable-cross-import-overlays -load-plugin-executable /Users/runner/work/Archivist/Archivist/.build/arm64-apple-macosx/release/ArchivistMacros-tool#ArchivistMacros -empty-abi-descriptor -plugin-path /Users/runner/hostedtoolcache/swift-6.1.1-RELEASE-xcode/6.1.1/aarch64/usr/lib/swift/host/plugins/testing -resource-dir /Users/runner/hostedtoolcache/swift-6.1.1-RELEASE-xcode/6.1.1/aarch64/usr/lib/swift -file-compilation-dir /Users/runner/work/Archivist/Archivist -Xcc -fmodule-map-file=/Users/runner/work/Archivist/Archivist/.build/checkouts/swift-syntax/Sources/_SwiftSyntaxCShims/include/module.modulemap -Xcc -I -Xcc /Users/runner/work/Archivist/Archivist/.build/checkouts/swift-syntax/Sources/_SwiftSyntaxCShims/include -Xcc -isysroot -Xcc /Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -Xcc -F -Xcc /Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -Xcc -F -Xcc /Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/PrivateFrameworks -Xcc -fPIC -Xcc -g -module-name ArchivistTests -package-name archivist -in-process-plugin-server-path /Users/runner/hostedtoolcache/swift-6.1.1-RELEASE-xcode/6.1.1/aarch64/usr/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Users/runner/hostedtoolcache/swift-6.1.1-RELEASE-xcode/6.1.1/aarch64/usr/lib/swift/host/plugins -plugin-path /Users/runner/hostedtoolcache/swift-6.1.1-RELEASE-xcode/6.1.1/aarch64/usr/local/lib/swift/host/plugins -target-sdk-version 14.5 -target-sdk-name macosx14.5 -external-plugin-path /Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode_15.4.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -enable-default-cmo -parse-as-library -num-threads 3 -o /Users/runner/work/Archivist/Archivist/.build/arm64-apple-macosx/release/ArchivistTests.build/MacroTests.swift.o -o /Users/runner/work/Archivist/Archivist/.build/arm64-apple-macosx/release/ArchivistTests.build/ReadableArchiveTests.swift.o -o /Users/runner/work/Archivist/Archivist/.build/arm64-apple-macosx/release/ArchivistTests.build/SwiftArchivableTests.swift.o -o /Users/runner/work/Archivist/Archivist/.build/arm64-apple-macosx/release/ArchivistTests.build/WriteableArchiveTests.swift.o -index-store-path /Users/runner/work/Archivist/Archivist/.build/arm64-apple-macosx/release/index/store -index-system-modules
1.	Apple Swift version 6.1.1 (swift-6.1.1-RELEASE)
2.	Compiling with the current language version
3.	While evaluating request ExecuteSILPipelineRequest(Run pipelines { PrepareOptimizationPasses, EarlyModulePasses, HighLevel,Function+EarlyLoopOpt, HighLevel,Module+StackPromote, MidLevel,Function, ClosureSpecialize, LowLevel,Function, LateLoopOpt, SIL Debug Info Generator } on SIL for ArchivistTests)
4.	While running pass #50284 SILFunctionTransform "Mem2Reg" on SILFunction "@$s9Archivist16WriteableArchiveV5writeyyqd__KAA10ArchivableRd__lFAA12BinaryBufferV_s5Int16VTg5".
 for 'write(_:)' (in module 'Archivist')
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           0x0000000106123844 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000106121f70 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000106123e88 SignalHandler(int) + 292
3  libsystem_platform.dylib 0x00000001983e3584 _sigtramp + 56
4  libsystem_pthread.dylib  0x00000001983b2c20 pthread_kill + 288
5  libsystem_c.dylib        0x00000001982bfa30 abort + 180
6  libsystem_c.dylib        0x00000001982bed20 err + 0
7  swift-frontend           0x00000001061f26e0 isWriteOnlyAllocation(swift::SILValue) (.cold.2) + 0
8  swift-frontend           0x000000010187e954 (anonymous namespace)::SILMem2Reg::run() + 7804
9  swift-frontend           0x0000000101796e98 swift::SILPassManager::runPassOnFunction(unsigned int, swift::SILFunction*) + 1452
10 swift-frontend           0x0000000101797c1c swift::SILPassManager::runFunctionPasses(unsigned int, unsigned int) + 1060
11 swift-frontend           0x0000000101794e14 swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 72
12 swift-frontend           0x0000000101794d94 swift::ExecuteSILPipelineRequest::evaluate(swift::Evaluator&, swift::SILPipelineExecutionDescriptor) const + 68
13 swift-frontend           0x00000001017e0bd4 swift::SimpleRequest<swift::ExecuteSILPipelineRequest, std::__1::tuple<> (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1>::evaluateRequest(swift::ExecuteSILPipelineRequest const&, swift::Evaluator&) + 28
14 swift-frontend           0x00000001017b0f98 swift::ExecuteSILPipelineRequest::OutputType swift::Evaluator::getResultUncached<swift::ExecuteSILPipelineRequest, swift::ExecuteSILPipelineRequest::OutputType swift::evaluateOrFatal<swift::ExecuteSILPipelineRequest>(swift::Evaluator&, swift::ExecuteSILPipelineRequest)::'lambda'()>(swift::ExecuteSILPipelineRequest const&, swift::ExecuteSILPipelineRequest::OutputType swift::evaluateOrFatal<swift::ExecuteSILPipelineRequest>(swift::Evaluator&, swift::ExecuteSILPipelineRequest)::'lambda'()) + 204
15 swift-frontend           0x0000000101795004 swift::executePassPipelinePlan(swift::SILModule*, swift::SILPassPipelinePlan const&, bool, swift::irgen::IRGenModule*) + 64
16 swift-frontend           0x00000001017c3ef0 swift::runSILOptimizationPasses(swift::SILModule&) + 156
17 swift-frontend           0x00000001010687c8 swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 636
18 swift-frontend           0x0000000100e351f0 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*) + 820
19 swift-frontend           0x0000000100e34bdc swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1328
20 swift-frontend           0x0000000100e[40](https://github.com/tothambrus11/Archivist/actions/runs/15240971598/job/42860982994#step:4:41)994 withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 164
21 swift-frontend           0x0000000100e36590 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 716
22 swift-frontend           0x0000000100e35dac swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 2228
23 swift-frontend           0x0000000100c19734 swift::mainEntry(int, char const**) + 3064
24 dyld                     0x0000000198027154 start + 2476
error: fatalError

Expected behavior

No crash

Environment

MacOS, Swift 6.1, Swift 6.1.1

Additional information

No response

@tothambrus11 tothambrus11 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 May 25, 2025
@nate-chandler
Copy link
Contributor

On macOS, I see this assertion failure when running swift test with the 5.10 toolchain, the 6.0.3 toolchain, and the 6.1 toolchain. I do not see it with the latest 6.2 toolchain. You mentioned

6.0 also works fine

Was that using the toolchain in Xcode?

@nate-chandler nate-chandler added SIL and removed triage needed This issue needs more specific labels labels May 28, 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. crash Bug: A crash, i.e., an abnormal termination of software SIL
Projects
None yet
Development

No branches or pull requests

2 participants
0