Skip to content

Release build crashes the compiler on Linux since #389 (RCodesign) #431

Closed

Description

@c4software

Since #389 (zsign replaced by RCodesign), a release build of XKit crashes the Swift compiler on Linux x86_64. Upstream CI builds debug only (build.yml), so it does not show there; the next tagged Linux release (release.yml) would hit it.

Reproduce (upstream's own image: the build-limd stage of the Dockerfile at ac40282, on swift:6.4.2-jammy)

git checkout ac40282
swift build -c release --target XKit
*** Program crashed: Bad pointer dereference at 0x… ***
Running pass "require<globals-aa>,function(invalidate<aa>),…" on module ".../XKit-t.build/Objects-normal/x86_64/DeveloperServicesAddAppGroupRequest.o"
error: Build failed

The crashing threads are in LLVM: Verifier::visitFunction, AttributeList::hasAttributeAtIndex, CodeGenPrepare::optimizeCallInst, KnownBits::getMaxValue. The other XKit objects of that batch then fail with error closing '….o' … No such file or directory.

Bisect (git bisect run between 1.24.0 (good) and ac40282 (bad), release build of the xtool product)

Same result

  • with Swift 6.4.1 and 6.4.2;
  • with SwiftBuild (the default) and --build-system native;
  • with -Xswiftc -num-threads -Xswiftc 0;
  • in upstream's image above, and in an Arch container (swift.org ubi9 toolchains).

A debug build works.

Not checked

Activity

  1. c4software commented on Nov 6, 2026

    @c4software
    ContributorAuthor

    I narrowed it down: it is a Swift compiler bug, set off by the two unimplemented() calls that #389 added in UnimplementedSigner (Sources/XKit/Signer/Signer.swift).

    In XKit (at 64fe8e3, release build of the XKit target)

    • It still crashes with:
      • RCodesignSigner.swift stubbed, or the RCodesign dependency removed altogether;
      • zsign / SignerSupport added back to the graph;
      • RCodesignSigner as a struct;
      • either @Dependency(\.signer) property replaced.
    • It builds with the pre-signer: replace zsign with RCodesign #389 XKit sources, or with only the UnimplementedSigner bodies changed. Either of the two calls alone is enough to crash:
      let operation: () throws -> Void = unimplemented()
      try operation()
      These pick the overload unimplemented<each Argument, Result>(…) -> @Sendable (repeat each Argument) throws -> sending Result of swift-issue-reporting 2.1.2, with an empty pack, called from an async function. The other unimplemented() calls in XKit pick the async-closure overloads and are fine.

    Minimal reproducer (no dependency, Swift 6.4.2, swift:6.4.2-jammy, x86_64)

    // Lib.swift
    public func make<each Argument>() -> (repeat each Argument) -> Void {
        { (argument: repeat each Argument) in }
    }
    // Min.swift
    import Lib
    
    public func run() async {
        let operation: () -> Void = make()
        operation()
    }
    swiftc -O -parse-as-library -emit-module -module-name Lib Lib.swift -emit-module-path Lib.swiftmodule
    swiftc -O -parse-as-library -c -I . Min.swift -o Min.o    # Segmentation fault
    
    #4 llvm::StructType::getTypeAtIndex(llvm::Value const*) const
    #5 llvm::GEPOperator::accumulateConstantOffset(...)
    #7 addArgumentAttrs(...)
    #8 llvm::PostOrderFunctionAttrsPass::run(...)
    ...
    #20 swift::performLLVMOptimizations(...)
    
    • -Onone builds.
    • A non-async run() builds.
    • A single module (the generic function and the caller together) builds.
    • -enable-library-evolution on Lib still crashes.
    • throws and sending do not matter.

    Workaround in xtool (tested at ac40282: swift build -c release --product xtool then builds):

         ) async throws {
    -        let operation: () throws -> Void = unimplemented()
    -        try operation()
    +        reportIssue("Unimplemented: Signer.sign")
    +        throw UnimplementedFailure(description: "Signer.sign")
         }
    
         func analyze(executable: URL) async throws -> Data? {
    -        let operation: () throws -> Data? = unimplemented()
    -        return try operation()
    +        reportIssue("Unimplemented: Signer.analyze")
    +        throw UnimplementedFailure(description: "Signer.analyze")
         }
  2. added a commit that references this issue on Nov 7, 2026
    3ed0404
  3. added a commit that references this issue on Nov 8, 2026
    a2875dd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions