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

Compiler crash while emitting IR SIL function for Swift Macro #80062

Open
mgutski opened this issue Mar 17, 2025 · 0 comments
Open

Compiler crash while emitting IR SIL function for Swift Macro #80062

mgutski opened this issue Mar 17, 2025 · 0 comments
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 triage needed This issue needs more specific labels

Comments

@mgutski
Copy link

mgutski commented Mar 17, 2025

Description

When building in release configuration, the compiler crashes with segmentation fault (signal 11) while emitting IR SIL function "@$s21ConfidentialKitMacros15ObfuscatedMacroO9expansion2of16providingPeersOf2inSay11SwiftSyntax04DeclM0VGAH09AttributeM0V_xq_tKAH0nM8ProtocolRz0lmC00E16ExpansionContextR_r0_lFZTf4nndd_n" .

The crash happens when compiling the @Obfuscated macro from the _ConfidentialKit library in the swift-confidential package.

The compilation succeeds when building in debug configuration.

Tested with Xcode 16.2 (swiftlang-6.0.3.1.10) and Xcode 16.3 Beta 2 (swiftlang-6.1.0.109.103) on macOS (arm64 and x86_64).

Reproduction

  1. Clone the swift-confidential repository.
    git clone https://github.com/securevale/swift-confidential.git && cd swift-confidential
  2. Checkout the topic/swift-6-support branch.
    git checkout topic/swift-6-support
  3. Build the library target _ConfidentialKit in release configuration.
    swift build --target _ConfidentialKit --configuration release

Stack dump

0  swift-frontend           0x000000010711ee14 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x000000010711cc4c llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x000000010711f450 SignalHandler(int) + 360
3  libsystem_platform.dylib 0x00000001917f2de4 _sigtramp + 56
4  swift-frontend           0x00000001016862d8 swift::irgen::ElementLayout::project(swift::irgen::IRGenFunction&, swift::irgen::Address, std::__1::optional<swift::irgen::NonFixedOffsetsImpl*>, llvm::Twine const&) const + 1236
5  swift-frontend           0x00000001015418a0 swift::irgen::RecordTypeInfo<(anonymous namespace)::LoadableStructTypeInfo, swift::irgen::LoadableTypeInfo, (anonymous namespace)::StructFieldInfo, true, true>::initialize(swift::irgen::IRGenFunction&, swift::irgen::Explosion&, swift::irgen::Address, bool) const + 160
6  swift-frontend           0x00000001015ee07c (anonymous namespace)::IRGenSILFunction::visitSILBasicBlock(swift::SILBasicBlock*) + 75332
7  swift-frontend           0x00000001015da32c (anonymous namespace)::IRGenSILFunction::emitSILFunction() + 15860
8  swift-frontend           0x00000001015d6080 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 2788
9  swift-frontend           0x00000001013fb93c swift::irgen::IRGenerator::emitLazyDefinitions() + 5288
10 swift-frontend           0x000000010158986c swift::performIRGeneration(swift::ModuleDecl*, swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::ArrayRef<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>, llvm::GlobalVariable**) + 2736
11 swift-frontend           0x0000000100f75ac4 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>>>) + 216
12 swift-frontend           0x0000000100f71014 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
13 swift-frontend           0x0000000100f706b4 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 2688
14 swift-frontend           0x0000000100f735ec performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1764
15 swift-frontend           0x0000000100f71f70 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3716
16 swift-frontend           0x0000000100ef6054 swift::mainEntry(int, char const**) + 5428
17 dyld                     0x000000019143c274 start + 2840

Expected behavior

The compilation succeeds, regardless of the selected build configuration.

Environment

swift-driver version: 1.120.5 Apple Swift version 6.1 (swiftlang-6.1.0.109.103 clang-1700.0.13.2)
Target: arm64-apple-macosx15.0

Additional information

No response

@mgutski mgutski 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 Mar 17, 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 triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

1 participant