Skip to content

Swift compiler crash with -Osize optimization on UInt32 string conversion. #84372

@CrazyFanFan

Description

@CrazyFanFan

Description

The Swift compiler (version 6.2) crashes when compiling a simple Swift program with the -Osize optimization flag. This occurs on Xcode 26.0's built-in Swift compiler.

Reproduction

print(UInt32("ffffff08", radix: 16) ?? 0)

Stack dump

  • Create a file named main.swift with the above code.
  • Run the following command:
    swift -Osize main.swift

Expected behavior

The code should compile and run, printing the integer value of "ffffff08" in base 16.

Environment

macOS version: 26.0 (25A354)
Xcode version: 26.0 (17A324)
Swift version:

$ swift -version
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-macosx26.0

Additional information

Stack dump:
0.  Program arguments: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -interpret /Users/kkk/main.swift -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 -Osize -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 main -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 -- -o output.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 ExecuteSILPipelineRequest(Run pipelines { PrepareOptimizationPasses, EarlyModulePasses, HighLevel,Function+EarlyLoopOpt, HighLevel,Module+StackPromote, MidLevel,Function, ClosureSpecialize, LowLevel,Function, LateLoopOpt, SIL Debug Info Generator } on SIL for main)
4.  While running pass #34355 SILModuleTransform "StackProtection".
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           0x0000000108d65bcc llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000108d6355c llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000108d661f8 SignalHandler(int, __siginfo*, void*) + 344
3  libsystem_platform.dylib 0x0000000193ba2744 _sigtramp + 56
4  swift-frontend           0x00000001026a1384 $s3SIL19SmallProjectionPathV4push_5indexA2C9FieldKindO_SitF + 232
5  swift-frontend           0x00000001026b9d84 $s3SIL19AddressUseDefWalkerPAAE13walkUpDefault7address4pathAA10WalkResultOAA5Value_p_4PathQztFAA06AccessnE033_FFCBBB6CF68C612F8133E8B2C7CD6411LLV_Tg5Tf4enn_nAA13IndexAddrInstC_Tg5 + 284
6  swift-frontend           0x00000001026ba67c $s3SIL16AccessPathWalker33_FFCBBB6CF68C612F8133E8B2C7CD6411LLV6walkUp7address4pathAA10WalkResultOAA5Value_p_AD0C0VtFTf4enn_n + 232
7  swift-frontend           0x00000001026b9dac $s3SIL19AddressUseDefWalkerPAAE13walkUpDefault7address4pathAA10WalkResultOAA5Value_p_4PathQztFAA06AccessnE033_FFCBBB6CF68C612F8133E8B2C7CD6411LLV_Tg5Tf4enn_nAA13IndexAddrInstC_Tg5 + 324
8  swift-frontend           0x00000001026ba67c $s3SIL16AccessPathWalker33_FFCBBB6CF68C612F8133E8B2C7CD6411LLV6walkUp7address4pathAA10WalkResultOAA5Value_p_AD0C0VtFTf4enn_n + 232
9  swift-frontend           0x00000001026ba47c $s3SIL16AccessPathWalker33_FFCBBB6CF68C612F8133E8B2C7CD6411LLV4walk7startAt07initialC0yAA5Value_p_AA015SmallProjectionC0VtFTf4enn_n + 44
10 swift-frontend           0x00000001026a621c $s3SIL5ValuePAAE19accessPathWithScopeAA06AccessD0V_AA05BeginG4InstCSg5scopetvg + 84
11 swift-frontend           0x0000000102705c3c $s9Optimizer27StackProtectionOptimization33_EF1CF29496A732741F4525426237A327LLV7process8function_y3SIL8FunctionC_AA0M11PassContextVtF + 528
12 swift-frontend           0x00000001027057d8 $s9Optimizer15stackProtectionAA10ModulePassVvpfiyAA0dE7ContextVcfU_ + 228
13 swift-frontend           0x00000001038ec778 swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 13328
14 swift-frontend           0x000000010390f0a0 swift::SimpleRequest<swift::ExecuteSILPipelineRequest, std::__1::tuple<> (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1>::evaluateRequest(swift::ExecuteSILPipelineRequest const&, swift::Evaluator&) + 52
15 swift-frontend           0x00000001038f2e5c 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'()) + 412
16 swift-frontend           0x00000001038f5988 swift::runSILOptimizationPasses(swift::SILModule&) + 448
17 swift-frontend           0x0000000102d9be54 swift::CompilerInstance::performSILProcessing(swift::SILModule*) + 1148
18 swift-frontend           0x00000001029a0460 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*) + 1360
19 swift-frontend           0x000000010299fdbc swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 2680
20 swift-frontend           0x00000001029a36dc performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 4932
21 swift-frontend           0x00000001029a168c swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3580
22 swift-frontend           0x0000000102922c6c swift::mainEntry(int, char const**) + 5412
23 dyld                     0x00000001937d9d54 start + 7184
[1]    98978 trace trap  swift -O -Osize /Users/kkk/main.swift -o output.o

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugA deviation from expected or documented behavior. Also: expected but undesirable behavior.crashBug: A crash, i.e., an abnormal termination of softwaretriage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions