Skip to content

6.1 nightly crashes on "Assertion `!type.hasPrimaryArchetype()' failed" with typed throws #80020

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

Closed
sebsto opened this issue Mar 14, 2025 · 3 comments · Fixed by #80273
Closed
Assignees
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

@sebsto
Copy link

sebsto commented Mar 14, 2025

Description

Compiling code on 6.1 nightly crashes.
I can't provide a simple project for reproduction.

Project: https://github.com/sebsto/swift-aws-lambda-runtime
Branch main compiles
Branch sebsto/fix_507 causes the crashes

Reproduction

git clone https://github.com/sebsto/swift-aws-lambda-runtime.git
cd swift-aws-lambda-runtime
git fetch --all
git checkout sebsto/fix_507 

docker run -it --rm -v .:/work swiftlang/swift:nightly-6.1-jammy bash -c "(cd /work && swift build)"

Stack dump

error: compile command failed due to signal 6 (use -v to see invocation)
swift-frontend: /home/build-user/swift/lib/SIL/IR/SILFunction.cpp:523: SILType swift::SILFunction::mapTypeIntoContext(SILType) const: Assertion `!type.hasPrimaryArchetype()' failed.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.      Program arguments: /usr/bin/swift-frontend -frontend -c /work/Sources/AWSLambdaRuntime/ControlPlaneRequest.swift /work/Sources/AWSLambdaRuntime/ControlPlaneRequestEncoder.swift -primary-file /work/Sources/AWSLambdaRuntime/FoundationSupport/Context+Foundation.swift -primary-file /work/Sources/AWSLambdaRuntime/FoundationSupport/Lambda+JSON.swift /work/Sources/AWSLambdaRuntime/FoundationSupport/Vendored/ByteBuffer-foundation.swift /work/Sources/AWSLambdaRuntime/FoundationSupport/Vendored/JSON+ByteBuffer.swift /work/Sources/AWSLambdaRuntime/Lambda+Codable.swift /work/Sources/AWSLambdaRuntime/Lambda+LocalServer.swift /work/Sources/AWSLambdaRuntime/Lambda.swift /work/Sources/AWSLambdaRuntime/LambdaContext.swift /work/Sources/AWSLambdaRuntime/LambdaHandlers.swift /work/Sources/AWSLambdaRuntime/LambdaRequestID.swift /work/Sources/AWSLambdaRuntime/LambdaRuntime+ServiceLifecycle.swift /work/Sources/AWSLambdaRuntime/LambdaRuntime.swift /work/Sources/AWSLambdaRuntime/LambdaRuntimeClient.swift /work/Sources/AWSLambdaRuntime/LambdaRuntimeClientError.swift /work/Sources/AWSLambdaRuntime/LambdaRuntimeClientProtocol.swift /work/Sources/AWSLambdaRuntime/Utils.swift -emit-dependencies-path /work/.build/aarch64-unknown-linux-gnu/debug/AWSLambdaRuntime.build/Context+Foundation.d -emit-reference-dependencies-path /work/.build/aarch64-unknown-linux-gnu/debug/AWSLambdaRuntime.build/Context+Foundation.swiftdeps -emit-dependencies-path /work/.build/aarch64-unknown-linux-gnu/debug/AWSLambdaRuntime.build/Lambda+JSON.d -emit-reference-dependencies-path /work/.build/aarch64-unknown-linux-gnu/debug/AWSLambdaRuntime.build/Lambda+JSON.swiftdeps -target aarch64-unknown-linux-gnu -Xllvm -aarch64-use-tbi -disable-objc-interop -I /work/.build/aarch64-unknown-linux-gnu/debug/Modules -color-diagnostics -enable-testing -g -debug-info-format=dwarf -dwarf-version=4 -module-cache-path /work/.build/aarch64-unknown-linux-gnu/debug/ModuleCache -swift-version 6 -Onone -D SWIFT_PACKAGE -D DEBUG -D FoundationJSONSupport -D LocalServerSupport -D ServiceLifecycleSupport -empty-abi-descriptor -resource-dir /usr/lib/swift -enable-anonymous-context-mangled-names -file-compilation-dir /work -Xcc -fmodule-map-file=/work/.build/checkouts/swift-atomics/Sources/_AtomicsShims/include/module.modulemap -Xcc -I -Xcc /work/.build/checkouts/swift-atomics/Sources/_AtomicsShims/include -Xcc -fmodule-map-file=/work/.build/aarch64-unknown-linux-gnu/debug/CNIOWASI.build/module.modulemap -Xcc -I -Xcc /work/.build/checkouts/swift-nio/Sources/CNIOWASI/include -Xcc -fmodule-map-file=/work/.build/checkouts/swift-nio/Sources/CNIOWindows/include/module.modulemap -Xcc -I -Xcc /work/.build/checkouts/swift-nio/Sources/CNIOWindows/include -Xcc -fmodule-map-file=/work/.build/aarch64-unknown-linux-gnu/debug/CNIOLinux.build/module.modulemap -Xcc -I -Xcc /work/.build/checkouts/swift-nio/Sources/CNIOLinux/include -Xcc -fmodule-map-file=/work/.build/aarch64-unknown-linux-gnu/debug/CNIODarwin.build/module.modulemap -Xcc -I -Xcc /work/.build/checkouts/swift-nio/Sources/CNIODarwin/include -Xcc -fmodule-map-file=/work/.build/aarch64-unknown-linux-gnu/debug/CNIOAtomics.build/module.modulemap -Xcc -I -Xcc /work/.build/checkouts/swift-nio/Sources/CNIOAtomics/include -Xcc -fmodule-map-file=/work/.build/aarch64-unknown-linux-gnu/debug/CNIOLLHTTP.build/module.modulemap -Xcc -I -Xcc /work/.build/checkouts/swift-nio/Sources/CNIOLLHTTP/include -Xcc -fPIC -Xcc -g -Xcc -fno-omit-frame-pointer -module-name AWSLambdaRuntime -package-name work -in-process-plugin-server-path /usr/lib/swift/host/libSwiftInProcPluginServer.so -plugin-path /usr/lib/swift/host/plugins -plugin-path /usr/local/lib/swift/host/plugins -parse-as-library -o /work/.build/aarch64-unknown-linux-gnu/debug/AWSLambdaRuntime.build/Context+Foundation.swift.o -o /work/.build/aarch64-unknown-linux-gnu/debug/AWSLambdaRuntime.build/Lambda+JSON.swift.o -index-store-path /work/.build/aarch64-unknown-linux-gnu/debug/index/store -index-system-modules
1.      Swift version 6.1-dev (LLVM 08670c03fe16573, Swift 493744d5e4900b2)
2.      Compiling with the current language version
3.      While evaluating request IRGenRequest(IR Generation for file "/work/Sources/AWSLambdaRuntime/FoundationSupport/Lambda+JSON.swift")
4.      While emitting IR SIL function "@$s16AWSLambdaRuntime06LambdaB0C7decoder7encoder4bodyACyAA0C14CodableAdapterVyAA0c7HandlerH0Vyqd__qd_0_AA07ClosureI0Vyqd__qd_0_GGqd__qd_0_AA0C16JSONEventDecoderVAA0C17JSONOutputEncoderVyqd_0_GGG20FoundationEssentials11JSONDecoderC_AV11JSONEncoderCqd_0_qd___AA0C7ContextVtYaKcntcATRszSeRd__SERd_0_r0_lufC".
 for 'init(decoder:encoder:body:)' (at /work/Sources/AWSLambdaRuntime/FoundationSupport/Lambda+JSON.swift:91:24)
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  0x0000aaaaf1129074
1  swift-frontend  0x0000aaaaf1126ec8
2  swift-frontend  0x0000aaaaf1129788
3  linux-vdso.so.1 0x0000ffffa867a7a0 __kernel_rt_sigreturn + 0
4  libc.so.6       0x0000ffffa6acf1f0
5  libc.so.6       0x0000ffffa6a8a67c raise + 28
6  libc.so.6       0x0000ffffa6a77130 abort + 228
7  libc.so.6       0x0000ffffa6a83fd4
8  libc.so.6       0x0000ffffa6a8404c
9  swift-frontend  0x0000aaaaeb2d51a4
10 swift-frontend  0x0000aaaaea8f6d48
11 swift-frontend  0x0000aaaaea8d6080
12 swift-frontend  0x0000aaaaea8d40d4
13 swift-frontend  0x0000aaaaea8d17a8
14 swift-frontend  0x0000aaaaea78f1bc
15 swift-frontend  0x0000aaaaea63f2c0
16 swift-frontend  0x0000aaaaea694ad8
17 swift-frontend  0x0000aaaaea648a10
18 swift-frontend  0x0000aaaaea6413b4
19 swift-frontend  0x0000aaaaea232460
20 swift-frontend  0x0000aaaaea22ed3c
21 swift-frontend  0x0000aaaaea22dd5c
22 swift-frontend  0x0000aaaaea23b2d8
23 swift-frontend  0x0000aaaaea2303c4
24 swift-frontend  0x0000aaaaea22f7d4
25 swift-frontend  0x0000aaaaea016838
26 libc.so.6       0x0000ffffa6a773fc
27 libc.so.6       0x0000ffffa6a774cc __libc_start_main + 152
28 swift-frontend  0x0000aaaaea015a30
[9/25] Compiling MockServer MockHTTPServer.swift

Expected behavior

no crashes :-)

Environment

docker container swiftlang/swift:nightly-6.1-jammy

Swift version 6.1-dev (LLVM 08670c03fe16573, Swift 493744d)
Target: aarch64-unknown-linux-gnu

Additional information

No response

@sebsto sebsto 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 14, 2025
@sebsto
Copy link
Author

sebsto commented Mar 15, 2025

The change that started to crash the compiler is in this commit
sebsto/swift-aws-lambda-runtime@456569a

@sebsto
Copy link
Author

sebsto commented Mar 15, 2025

The line that causes the compiler to crash is a typed throw
https://github.com/sebsto/swift-aws-lambda-runtime/blob/46e76f354401d3c50c1eb76b6a7e55c738fcbc23/Sources/AWSLambdaRuntime/LambdaRuntime.swift#L50

    public init(
        handler: sending Handler,
        eventLoop: EventLoop = Lambda.defaultEventLoop,
        logger: Logger = Logger(label: "LambdaRuntime")
    ) throws(LambdaRuntimeError) {

Removing the type in the throws clause solves the issue

sebsto added a commit to sebsto/swift-aws-lambda-runtime that referenced this issue Mar 15, 2025
@sebsto sebsto changed the title 6.1 nightly crashes on Assertion `!type.hasPrimaryArchetype()' failed 6.1 nightly crashes on "Assertion `!type.hasPrimaryArchetype()' failed" with typed throws Mar 15, 2025
@slavapestov slavapestov self-assigned this Mar 25, 2025
@slavapestov
Copy link
Contributor

Here is a reproducer:

enum MyError: Error {
  case error
}

struct G<T> {
  init(t: T) throws(MyError) {}

  init<U>(_: U) where T == Optional<U> {
    do {
      try self.init(t: .none)
    } catch {
      fatalError("Failed to initialize G: \(error)")
    }
  }
}
Assertion failed: (!type.hasPrimaryArchetype()), function mapTypeIntoContext, file SILFunction.cpp, line 523.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /Users/slava/src/build/Ninja-RelWithDebInfoAssert/swift-macosx-arm64/bin/swift-frontend -frontend -c -primary-file reduced.swift -target arm64-apple-macosx15.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -color-diagnostics -Xcc -fcolor-diagnostics -empty-abi-descriptor -no-auto-bridging-header-chaining -module-name reduced -in-process-plugin-server-path /Users/slava/src/build/Ninja-RelWithDebInfoAssert/swift-macosx-arm64/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Users/slava/src/build/Ninja-RelWithDebInfoAssert/swift-macosx-arm64/lib/swift/host/plugins -plugin-path /Users/slava/src/build/Ninja-RelWithDebInfoAssert/swift-macosx-arm64/local/lib/swift/host/plugins -o /var/folders/qn/b1yvkm_x0ml3hphs428lmyx40000gn/T/TemporaryDirectory.0bsTVT/reduced-1.o
1.	Swift version 6.2-dev (LLVM 42e6d992f604dae, Swift abe1fd5b69b6568)
2.	Compiling with effective version 5.10
3.	While evaluating request IRGenRequest(IR Generation for file "reduced.swift")
4.	While emitting IR SIL function "@$s7reduced1GVyACyqd__SgGqd__cADRszlufC".
 for 'init(_:)' (at reduced.swift:8:3)
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           0x00000001079e1c34 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x00000001079e0384 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x00000001079e227c SignalHandler(int, __siginfo*, void*) + 296
3  libsystem_platform.dylib 0x0000000199e3f624 _sigtramp + 56
4  libsystem_pthread.dylib  0x0000000199e0588c pthread_kill + 296
5  libsystem_c.dylib        0x0000000199d0ec60 abort + 124
6  libsystem_c.dylib        0x0000000199d0deec err + 0
7  swift-frontend           0x0000000107a3c760 swift::GenericEnvironment::mapTypeIntoContext(swift::SILModule&, swift::SILType) const (.cold.3) + 0
8  swift-frontend           0x00000001031a34d4 swift::SILFunction::mapTypeIntoContext(swift::SILType) const + 296
9  swift-frontend           0x0000000102983ef0 (anonymous namespace)::IRGenSILFunction::visitFullApplySite(swift::FullApplySite) + 4892
10 swift-frontend           0x0000000102966258 (anonymous namespace)::IRGenSILFunction::visitSILBasicBlock(swift::SILBasicBlock*) + 2220
11 swift-frontend           0x00000001029649e0 (anonymous namespace)::IRGenSILFunction::emitSILFunction() + 8776
12 swift-frontend           0x0000000102962238 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) + 1816

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

Successfully merging a pull request may close this issue.

2 participants