Skip to content

IRBuilder compiler crash with main-snapshot-2025-05-14 toolchain #81650

Open
@RandomHashTags

Description

@RandomHashTags

Description

My networking library encounters a compile crash when utilizing integer generic parameters and inline arrays as underlying storage for a value type.

Reproduction

Not sure how to create a minimal reproducer here as there is a lot of context.

If you uncomment the let server = try Server<Router, Socket>(...) (line) in the main.swift file it will crash.

#declareRouter is declared as the following, which declares a type of Router.

@freestanding(declaration, names: named(router))
public macro declareRouter(...)

Basically if I try creating a Server with the following Router type it crashes:

Router<
    RouterResponderStorage<
        CompiledStaticResponderStorage<0, 1, 7, 3, 0>,
        DynamicResponderStorage
    >,
    RouterResponderStorage<
        CompiledStaticResponderStorage<0, 0, 1, 0, 0>,
        DynamicResponderStorage
    >,
    StaticErrorResponder, DynamicRouteResponder, RouteResponses.StaticString
>

Relevant links:

Stack dump

swift-frontend: /home/build-user/swift/lib/IRGen/IRBuilder.h:193: Address swift::irgen::IRBuilder::CreateStructGEP(Address, unsigned int, Size, const llvm::Twine &): Assertion `isa<llvm::StructType>(address.getElementType()) || isa<llvm::ArrayType>(address.getElementType())' failed.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.      Program arguments: /home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-05-14/usr/bin/swift-frontend -frontend -c -primary-file /home/paradigm/Desktop/GitProjects/destiny/Sources/Run/main.swift -emit-dependencies-path /home/paradigm/Desktop/GitProjects/destiny/.build/x86_64-unknown-linux-gnu/debug/Run.build/main.d -emit-reference-dependencies-path /home/paradigm/Desktop/GitProjects/destiny/.build/x86_64-unknown-linux-gnu/debug/Run.build/main.swiftdeps -serialize-diagnostics-path /home/paradigm/Desktop/GitProjects/destiny/.build/x86_64-unknown-linux-gnu/debug/Run.build/main.dia -target x86_64-unknown-linux-gnu -disable-objc-interop -I /home/paradigm/Desktop/GitProjects/destiny/.build/x86_64-unknown-linux-gnu/debug/Modules -color-diagnostics -Xcc -fcolor-diagnostics -enable-testing -g -debug-info-format=dwarf -dwarf-version=4 -module-cache-path /home/paradigm/Desktop/GitProjects/destiny/.build/x86_64-unknown-linux-gnu/debug/ModuleCache -swift-version 5 -Onone -D SWIFT_PACKAGE -D DEBUG -D SWIFT_MODULE_RESOURCE_BUNDLE_UNAVAILABLE -D Destiny -D DestinyDefaults -entry-point-function-name Run_main -load-plugin-executable /home/paradigm/Desktop/GitProjects/destiny/.build/x86_64-unknown-linux-gnu/debug/DestinyMacros-tool#DestinyMacros -load-plugin-executable /home/paradigm/Desktop/GitProjects/destiny/.build/x86_64-unknown-linux-gnu/debug/DestinyUtilityMacros-tool#DestinyUtilityMacros -empty-abi-descriptor -enable-anonymous-context-mangled-names -file-compilation-dir /home/paradigm/Desktop/GitProjects/destiny -Xcc -fmodule-map-file=/home/paradigm/Desktop/GitProjects/destiny/.build/checkouts/swift-syntax/Sources/_SwiftSyntaxCShims/include/module.modulemap -Xcc -I -Xcc /home/paradigm/Desktop/GitProjects/destiny/.build/checkouts/swift-syntax/Sources/_SwiftSyntaxCShims/include -Xcc -fmodule-map-file=/home/paradigm/Desktop/GitProjects/destiny/.build/checkouts/CEpoll/module.modulemap -Xcc -fPIC -Xcc -g -Xcc -fno-omit-frame-pointer -no-auto-bridging-header-chaining -module-name Run -package-name destiny -in-process-plugin-server-path /home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-05-14/usr/lib/swift/host/libSwiftInProcPluginServer.so -plugin-path /home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-05-14/usr/lib/swift/host/plugins -plugin-path /home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-05-14/usr/local/lib/swift/host/plugins -o /home/paradigm/Desktop/GitProjects/destiny/.build/x86_64-unknown-linux-gnu/debug/Run.build/main.swift.o -index-store-path /home/paradigm/Desktop/GitProjects/destiny/.build/x86_64-unknown-linux-gnu/debug/index/store -index-system-modules
1.      Swift version 6.2-dev (LLVM be9c1978c3677f1, Swift 749e9ee090b6443)
2.      Compiling with effective version 5.10
3.      While evaluating request IRGenRequest(IR Generation for file "/home/paradigm/Desktop/GitProjects/destiny/Sources/Run/main.swift")
4.      While emitting IR SIL function "@Run_main".
 #0 0x0000583251f4d048 llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-05-14/usr/bin/swift-frontend+0x8bed048)
 #1 0x0000583251f4abee llvm::sys::RunSignalHandlers() (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-05-14/usr/bin/swift-frontend+0x8beabee)
 #2 0x0000583251f4d6e1 SignalHandler(int, siginfo_t*, void*) Signals.cpp:0:0
 #3 0x00007064e684def0 (/usr/lib/libc.so.6+0x3def0)
 #4 0x00007064e68a774c __pthread_kill_implementation /usr/src/debug/glibc/glibc/nptl/pthread_kill.c:44:76
 #5 0x00007064e684ddc0 raise /usr/src/debug/glibc/glibc/signal/../sysdeps/posix/raise.c:27:6
 #6 0x00007064e683557a abort /usr/src/debug/glibc/glibc/stdlib/abort.c:81:3
 #7 0x00007064e68354e3 __assert_perror_fail /usr/src/debug/glibc/glibc/assert/assert-perr.c:31:1
 #8 0x000058324a809a9a swift::irgen::IRBuilder::CreateStructGEP(swift::irgen::Address, unsigned int, swift::irgen::Size, llvm::Twine const&) crtstuff.c:0:0
 #9 0x000058324a8263b1 swift::irgen::ElementLayout::project(swift::irgen::IRGenFunction&, swift::irgen::Address, std::optional<swift::irgen::NonFixedOffsetsImpl*>, llvm::Twine const&) const (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-05-14/usr/bin/swift-frontend+0x14c63b1)
#10 0x000058324a9e00d2 swift::irgen::RecordField<(anonymous namespace)::StructFieldInfo>::projectAddress(swift::irgen::IRGenFunction&, swift::irgen::Address, std::optional<swift::irgen::NonFixedOffsetsImpl*>) const GenStruct.cpp:0:0
#11 0x000058324a9e1431 swift::irgen::RecordTypeInfoImpl<(anonymous namespace)::LoadableStructTypeInfo, swift::irgen::LoadableTypeInfo, (anonymous namespace)::StructFieldInfo, true>::initializeWithCopy(swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, bool) const GenStruct.cpp:0:0
#12 0x000058324a9e1547 swift::irgen::RecordTypeInfoImpl<(anonymous namespace)::LoadableStructTypeInfo, swift::irgen::LoadableTypeInfo, (anonymous namespace)::StructFieldInfo, true>::initializeWithCopy(swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, bool) const GenStruct.cpp:0:0
#13 0x000058324a9e1547 swift::irgen::RecordTypeInfoImpl<(anonymous namespace)::LoadableStructTypeInfo, swift::irgen::LoadableTypeInfo, (anonymous namespace)::StructFieldInfo, true>::initializeWithCopy(swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, bool) const GenStruct.cpp:0:0
#14 0x000058324a9e1547 swift::irgen::RecordTypeInfoImpl<(anonymous namespace)::LoadableStructTypeInfo, swift::irgen::LoadableTypeInfo, (anonymous namespace)::StructFieldInfo, true>::initializeWithCopy(swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, bool) const GenStruct.cpp:0:0
#15 0x000058324a9e1547 swift::irgen::RecordTypeInfoImpl<(anonymous namespace)::LoadableStructTypeInfo, swift::irgen::LoadableTypeInfo, (anonymous namespace)::StructFieldInfo, true>::initializeWithCopy(swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, bool) const GenStruct.cpp:0:0
#16 0x000058324aa8106e void llvm::function_ref<void (llvm::ArrayRef<swift::irgen::Address>)>::callback_fn<ArrayTypeInfoBase<swift::irgen::LoadableTypeInfo, swift::irgen::LoadableTypeInfo>::initializeWithCopy(swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, bool) const::'lambda'(llvm::ArrayRef<swift::irgen::Address>)>(long, llvm::ArrayRef<swift::irgen::Address>) crtstuff.c:0:0
#17 0x000058324aa7f48c ArrayTypeInfoBase<swift::irgen::LoadableTypeInfo, swift::irgen::LoadableTypeInfo>::initializeWithCopy(swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, bool) const crtstuff.c:0:0
#18 0x000058324a9e1547 swift::irgen::RecordTypeInfoImpl<(anonymous namespace)::LoadableStructTypeInfo, swift::irgen::LoadableTypeInfo, (anonymous namespace)::StructFieldInfo, true>::initializeWithCopy(swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, bool) const GenStruct.cpp:0:0
#19 0x000058324a9e1547 swift::irgen::RecordTypeInfoImpl<(anonymous namespace)::LoadableStructTypeInfo, swift::irgen::LoadableTypeInfo, (anonymous namespace)::StructFieldInfo, true>::initializeWithCopy(swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, bool) const GenStruct.cpp:0:0
#20 0x000058324a9e1547 swift::irgen::RecordTypeInfoImpl<(anonymous namespace)::LoadableStructTypeInfo, swift::irgen::LoadableTypeInfo, (anonymous namespace)::StructFieldInfo, true>::initializeWithCopy(swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, bool) const GenStruct.cpp:0:0
#21 0x000058324a9e52ee swift::irgen::RecordTypeInfoImpl<(anonymous namespace)::FixedStructTypeInfo, swift::irgen::IndirectTypeInfo<(anonymous namespace)::FixedStructTypeInfo, swift::irgen::FixedTypeInfo>, (anonymous namespace)::StructFieldInfo, false>::initializeWithCopy(swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, bool) const GenStruct.cpp:0:0
#22 0x000058324aa7734b void llvm::function_ref<void (swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, swift::irgen::TypeInfo const&)>::callback_fn<swift::irgen::IRGenModule::getOrCreateOutlinedInitializeWithCopyFunction(swift::SILType, swift::irgen::TypeInfo const&, swift::irgen::OutliningMetadataCollector const&)::$_2>(long, swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, swift::irgen::TypeInfo const&) Outlining.cpp:0:0
#23 0x000058324aa77744 void llvm::function_ref<void (swift::irgen::IRGenFunction&)>::callback_fn<swift::irgen::IRGenModule::getOrCreateOutlinedCopyAddrHelperFunction(swift::SILType, swift::irgen::TypeInfo const&, swift::irgen::OutliningMetadataCollector const&, llvm::StringRef, llvm::function_ref<void (swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, swift::irgen::TypeInfo const&)>)::$_5>(long, swift::irgen::IRGenFunction&) Outlining.cpp:0:0
#24 0x000058324a8eb8c4 swift::irgen::IRGenModule::getOrCreateHelperFunction(llvm::StringRef, llvm::Type*, llvm::ArrayRef<llvm::Type*>, llvm::function_ref<void (swift::irgen::IRGenFunction&)>, bool, bool, bool, swift::irgen::IRLinkage*, std::optional<unsigned int>, std::optional<llvm::function_ref<void (llvm::AttributeList&)>>) (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-05-14/usr/bin/swift-frontend+0x158b8c4)
#25 0x000058324aa733cf swift::irgen::IRGenModule::getOrCreateOutlinedCopyAddrHelperFunction(swift::SILType, swift::irgen::TypeInfo const&, swift::irgen::OutliningMetadataCollector const&, llvm::StringRef, llvm::function_ref<void (swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, swift::irgen::TypeInfo const&)>) (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-05-14/usr/bin/swift-frontend+0x17133cf)
#26 0x000058324aa72ada swift::irgen::IRGenModule::getOrCreateOutlinedInitializeWithCopyFunction(swift::SILType, swift::irgen::TypeInfo const&, swift::irgen::OutliningMetadataCollector const&) (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-05-14/usr/bin/swift-frontend+0x1712ada)
#27 0x000058324aa7229f swift::irgen::OutliningMetadataCollector::emitCallToOutlinedCopy(swift::irgen::Address, swift::irgen::Address, swift::SILType, swift::irgen::TypeInfo const&, swift::IsInitialization_t, swift::IsTake_t) const (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-05-14/usr/bin/swift-frontend+0x171229f)
#28 0x000058324aa76ce0 void llvm::function_ref<void (swift::irgen::OutliningMetadataCollector&)>::callback_fn<swift::irgen::TypeInfo::callOutlinedCopy(swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, swift::IsInitialization_t, swift::IsTake_t) const::$_0>(long, swift::irgen::OutliningMetadataCollector&) Outlining.cpp:0:0
#29 0x000058324aa71ec5 swift::irgen::TypeInfo::withWitnessableMetadataCollector(swift::irgen::IRGenFunction&, swift::SILType, swift::irgen::LayoutIsNeeded_t, swift::irgen::DeinitIsNeeded_t, llvm::function_ref<void (swift::irgen::OutliningMetadataCollector&)>) const (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-05-14/usr/bin/swift-frontend+0x1711ec5)
#30 0x000058324aa71fb1 swift::irgen::TypeInfo::callOutlinedCopy(swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, swift::IsInitialization_t, swift::IsTake_t) const (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-05-14/usr/bin/swift-frontend+0x1711fb1)
#31 0x000058324a9e5148 swift::irgen::RecordTypeInfoImpl<(anonymous namespace)::FixedStructTypeInfo, swift::irgen::IndirectTypeInfo<(anonymous namespace)::FixedStructTypeInfo, swift::irgen::FixedTypeInfo>, (anonymous namespace)::StructFieldInfo, false>::initializeWithCopy(swift::irgen::IRGenFunction&, swift::irgen::Address, swift::irgen::Address, swift::SILType, bool) const GenStruct.cpp:0:0
#32 0x000058324aa4959c (anonymous namespace)::IRGenSILFunction::visitSILBasicBlock(swift::SILBasicBlock*) IRGenSIL.cpp:0:0
#33 0x000058324aa3d130 (anonymous namespace)::IRGenSILFunction::emitSILFunction() IRGenSIL.cpp:0:0
#34 0x000058324aa39c53 swift::irgen::IRGenModule::emitSILFunction(swift::SILFunction*) (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-05-14/usr/bin/swift-frontend+0x16d9c53)
#35 0x000058324a8d2caf swift::irgen::IRGenerator::emitGlobalTopLevel(std::vector<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>, std::allocator<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>> const&) (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-05-14/usr/bin/swift-frontend+0x1572caf)
#36 0x000058324a74857e swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-05-14/usr/bin/swift-frontend+0x13e857e)
#37 0x000058324a7be21c swift::GeneratedModule swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)17>::callDerived<0ul>(swift::Evaluator&, std::integer_sequence<unsigned long, 0ul>) const crtstuff.c:0:0
#38 0x000058324a7be179 swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)17>::evaluateRequest(swift::IRGenRequest const&, swift::Evaluator&) crtstuff.c:0:0
#39 0x000058324a752b34 swift::IRGenRequest::OutputType swift::Evaluator::getResultUncached<swift::IRGenRequest, swift::IRGenRequest::OutputType swift::evaluateOrFatal<swift::IRGenRequest>(swift::Evaluator&, swift::IRGenRequest)::'lambda'()>(swift::IRGenRequest const&, swift::IRGenRequest::OutputType swift::evaluateOrFatal<swift::IRGenRequest>(swift::Evaluator&, swift::IRGenRequest)::'lambda'()) crtstuff.c:0:0
#40 0x000058324a74ad58 swift::performIRGeneration(swift::FileUnit*, swift::IRGenOptions const&, swift::TBDGenOptions const&, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule>>, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::GlobalVariable**) (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-05-14/usr/bin/swift-frontend+0x13ead58)
#41 0x000058324a2b7c96 generateIR(swift::IRGenOptions const&, swift::TBDGenOptions const&, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule>>, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, llvm::GlobalVariable*&, llvm::ArrayRef<std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char>>>) FrontendTool.cpp:0:0
#42 0x000058324a2b35c5 performCompileStepsPostSILGen(swift::CompilerInstance&, std::unique_ptr<swift::SILModule, std::default_delete<swift::SILModule>>, llvm::PointerUnion<swift::ModuleDecl*, swift::SourceFile*>, swift::PrimarySpecificPaths const&, int&, swift::FrontendObserver*) FrontendTool.cpp:0:0
#43 0x000058324a2b2092 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-05-14/usr/bin/swift-frontend+0xf52092)
#44 0x000058324a2c3f1a withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) FrontendTool.cpp:0:0
#45 0x000058324a2b511e performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) FrontendTool.cpp:0:0
#46 0x000058324a2b4273 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-05-14/usr/bin/swift-frontend+0xf54273)
#47 0x000058324a02bb2a swift::mainEntry(int, char const**) (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-05-14/usr/bin/swift-frontend+0xccbb2a)
#48 0x00007064e68376b5 __libc_start_call_main /usr/src/debug/glibc/glibc/csu/../sysdeps/nptl/libc_start_call_main.h:74:3
#49 0x00007064e6837769 call_init /usr/src/debug/glibc/glibc/csu/../csu/libc-start.c:128:20
#50 0x00007064e6837769 __libc_start_main /usr/src/debug/glibc/glibc/csu/../csu/libc-start.c:347:5
#51 0x000058324a02ab25 _start (/home/paradigm/.local/share/swiftly/toolchains/main-snapshot-2025-05-14/usr/bin/swift-frontend+0xccab25)

Expected behavior

Successfully compile or show compiler diagnostic.

Environment

Swift

Swift version 6.2-dev (LLVM be9c1978c3677f1, Swift 749e9ee)
Target: x86_64-unknown-linux-gnu
Build config: +assertions

Swiftly

1.0.0

OS

Arch Linux (6.14.6-arch1-1)

IDE

VS Code (1.100.0)

Swift (VS Code Extension)

2.2.0

Additional information

Swift Forum post about its discovery.

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