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

5.10 "LoadableByAddress" non-deterministic compiler crash when parameter pack closure saved to instance property. #74609

Open
vanvoorden opened this issue Jun 21, 2024 · 10 comments
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. compiler The Swift compiler itself crash Bug: A crash, i.e., an abnormal termination of software function types Feature → types: function types generics Feature: generic declarations and types good first issue Good for newcomers IRGen LLVM IR generation needs tests Flag: Issue is fixed but needs tests / PR needs tests parameter packs Feature → generics: Parameter packs properties Feature: properties swift 5.10 types Feature: types

Comments

@vanvoorden
Copy link
Contributor

vanvoorden commented Jun 21, 2024

Description

https://forums.swift.org/t/non-deterministic-5-10-compiler-failures-from-predictablememoryaccessoptimizations-and-swift-5-10/72630

This is a repro for a PredictableMemoryAccessOptimizations crash I originally saw in another project. There's a lot going on in that project… I attempted to look for a more "clean" repro. This is now reporting as a LoadableByAddress crash… but the code is following a similar pattern to my other project.

This crash seems to be non-deterministic… sometimes it crashes… sometimes it doesn't.

This code does not (for now) crash for me from the 6.0 toolchain. I'm only seeing the crashes from production Swift 5.10 (and Xcode 15.4).

It looks like this will be fixed once 6.0 goes live in Q3. I would really like to find some kind of workaround that could unblock me when building from production Xcode 15.4. Any ideas for that would be great!

Reproduction

struct Repeater<each Element> {
  let elements: (repeat () -> each Element)
}

struct Box<T> {
  
}

let repeater: Repeater<Box<Int>>

This code does not crash with probability one. I can clean and build again and I eventually see a crash.

Saving the parameter pack elements as the return values of a closure pack seems to be important to the crash. It also seems to be important for the repeating element type to be a generic type.

I can prevent the crash with probability one by not saving the closure pack to a variable:

struct Repeater<each Element> {
  //  let elements: (repeat () -> each Element)
}

struct Box<T> {
  
}

let repeater: Repeater<Box<Int>>

Stack dump

Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /Applications/Xcode_15.4.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/swift-frontend -frontend -c -primary-file /Users/rick/Desktop/RepeaterDemo/Sources/main.swift -emit-dependencies-path /Users/rick/Library/Developer/Xcode/DerivedData/RepeaterDemo-aoiveyvurevauqfmtsmslveqfmoc/Build/Intermediates.noindex/RepeaterDemo.build/Debug/RepeaterDemo.build/Objects-normal/arm64/main.d -emit-const-values-path /Users/rick/Library/Developer/Xcode/DerivedData/RepeaterDemo-aoiveyvurevauqfmtsmslveqfmoc/Build/Intermediates.noindex/RepeaterDemo.build/Debug/RepeaterDemo.build/Objects-normal/arm64/main.swiftconstvalues -emit-reference-dependencies-path /Users/rick/Library/Developer/Xcode/DerivedData/RepeaterDemo-aoiveyvurevauqfmtsmslveqfmoc/Build/Intermediates.noindex/RepeaterDemo.build/Debug/RepeaterDemo.build/Objects-normal/arm64/main.swiftdeps -serialize-diagnostics-path /Users/rick/Library/Developer/Xcode/DerivedData/RepeaterDemo-aoiveyvurevauqfmtsmslveqfmoc/Build/Intermediates.noindex/RepeaterDemo.build/Debug/RepeaterDemo.build/Objects-normal/arm64/main.dia -target arm64-apple-macos14.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -stack-check -sdk /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk -I /Users/rick/Library/Developer/Xcode/DerivedData/RepeaterDemo-aoiveyvurevauqfmtsmslveqfmoc/Build/Products/Debug -I /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib -F /Users/rick/Library/Developer/Xcode/DerivedData/RepeaterDemo-aoiveyvurevauqfmtsmslveqfmoc/Build/Products/Debug -F /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/Library/Frameworks -no-color-diagnostics -enable-testing -g -module-cache-path /Users/rick/Library/Developer/Xcode/DerivedData/ModuleCache.noindex -swift-version 5 -enforce-exclusivity=checked -Onone -D SWIFT_PACKAGE -D DEBUG -D Xcode -serialize-debugging-options -package-name repeaterdemo -const-gather-protocols-file /Users/rick/Library/Developer/Xcode/DerivedData/RepeaterDemo-aoiveyvurevauqfmtsmslveqfmoc/Build/Intermediates.noindex/RepeaterDemo.build/Debug/RepeaterDemo.build/Objects-normal/arm64/RepeaterDemo_const_extract_protocols.json -empty-abi-descriptor -validate-clang-modules-once -clang-build-session-file /Users/rick/Library/Developer/Xcode/DerivedData/ModuleCache.noindex/Session.modulevalidation -Xcc -working-directory -Xcc /Users/rick/Desktop/RepeaterDemo -resource-dir /Applications/Xcode_15.4.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift -enable-anonymous-context-mangled-names -Xcc -ivfsstatcache -Xcc /Users/rick/Library/Developer/Xcode/DerivedData/SDKStatCaches.noindex/macosx14.5-23F73-12794b5fd74727c21755f2ea17ca96a1.sdkstatcache -Xcc -I/Users/rick/Library/Developer/Xcode/DerivedData/RepeaterDemo-aoiveyvurevauqfmtsmslveqfmoc/Build/Products/Debug/include -Xcc -I/Users/rick/Library/Developer/Xcode/DerivedData/RepeaterDemo-aoiveyvurevauqfmtsmslveqfmoc/Build/Intermediates.noindex/RepeaterDemo.build/Debug/RepeaterDemo.build/DerivedSources-normal/arm64 -Xcc -I/Users/rick/Library/Developer/Xcode/DerivedData/RepeaterDemo-aoiveyvurevauqfmtsmslveqfmoc/Build/Intermediates.noindex/RepeaterDemo.build/Debug/RepeaterDemo.build/DerivedSources/arm64 -Xcc -I/Users/rick/Library/Developer/Xcode/DerivedData/RepeaterDemo-aoiveyvurevauqfmtsmslveqfmoc/Build/Intermediates.noindex/RepeaterDemo.build/Debug/RepeaterDemo.build/DerivedSources -Xcc -DSWIFT_PACKAGE -Xcc -DDEBUG=1 -module-name RepeaterDemo -frontend-parseable-output -disable-clang-spi -target-sdk-version 14.5 -target-sdk-name macosx14.5 -external-plugin-path /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/lib/swift/host/plugins#/Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/local/lib/swift/host/plugins#/Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX14.5.sdk/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/lib/swift/host/plugins#/Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -external-plugin-path /Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/local/lib/swift/host/plugins#/Applications/Xcode_15.4.0.app/Contents/Developer/Platforms/MacOSX.platform/Developer/usr/bin/swift-plugin-server -plugin-path /Applications/Xcode_15.4.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Applications/Xcode_15.4.0.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/local/lib/swift/host/plugins -o /Users/rick/Library/Developer/Xcode/DerivedData/RepeaterDemo-aoiveyvurevauqfmtsmslveqfmoc/Build/Intermediates.noindex/RepeaterDemo.build/Debug/RepeaterDemo.build/Objects-normal/arm64/main.o -index-unit-output-path /RepeaterDemo.build/Debug/RepeaterDemo.build/Objects-normal/arm64/main.o -index-store-path /Users/rick/Library/Developer/Xcode/DerivedData/RepeaterDemo-aoiveyvurevauqfmtsmslveqfmoc/Index.noindex/DataStore -index-system-modules
1.	Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
2.	Compiling with the current language version
3.	While evaluating request IRGenRequest(IR Generation for file "/Users/rick/Desktop/RepeaterDemo/Sources/main.swift")
4.	While converting type 'Repeater<Box<Int>>' (declared at [/Users/rick/Desktop/RepeaterDemo/Sources/main.swift:1:1 - line:3:1] RangeText="struct Repeater<each Element> {
  let elements: (repeat () -> each Element)
")
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           0x0000000105cabf3c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x0000000105cab0f8 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x0000000105cac544 SignalHandler(int) + 360
3  libsystem_platform.dylib 0x0000000192893584 _sigtramp + 56
4  swift-frontend           0x00000001014348c8 (anonymous namespace)::SubstFunctionTypePatternVisitor::handleGenericNominalType(swift::Lowering::AbstractionPattern, swift::CanType) + 312
5  swift-frontend           0x00000001014348c8 (anonymous namespace)::SubstFunctionTypePatternVisitor::handleGenericNominalType(swift::Lowering::AbstractionPattern, swift::CanType) + 312
6  swift-frontend           0x0000000101432c2c (anonymous namespace)::SubstFunctionTypePatternVisitor::visit(swift::CanType, swift::Lowering::AbstractionPattern) + 1104
7  swift-frontend           0x00000001014326c8 (anonymous namespace)::SubstFunctionTypePatternVisitor::handleUnabstractedFunctionType(swift::CanTypeWrapper<swift::AnyFunctionType>, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::AbstractionPattern) + 208
8  swift-frontend           0x0000000101432234 swift::Lowering::AbstractionPattern::getSubstFunctionTypePattern(swift::CanTypeWrapper<swift::AnyFunctionType>, swift::Lowering::TypeConverter&, swift::Lowering::AbstractionPattern, swift::CanType, bool&) const + 236
9  swift-frontend           0x000000010147aad8 getSILFunctionType(swift::Lowering::TypeConverter&, swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILExtInfoBuilder, (anonymous namespace)::Conventions const&, swift::ForeignInfo const&, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SubstitutionMap>, swift::ProtocolConformanceRef) + 2008
10 swift-frontend           0x0000000101472cbc getNativeSILFunctionType(swift::Lowering::TypeConverter&, swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILExtInfoBuilder, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SubstitutionMap>, swift::ProtocolConformanceRef) + 2004
11 swift-frontend           0x0000000101519c78 swift::Lowering::TypeConverter::computeLoweredRValueType(swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanType)::LoweredRValueTypeVisitor::visitAnyFunctionType(swift::CanTypeWrapper<swift::AnyFunctionType>) + 804
12 swift-frontend           0x0000000101509334 swift::Lowering::TypeConverter::getTypeLowering(swift::Lowering::AbstractionPattern, swift::Type, swift::TypeExpansionContext) + 556
13 swift-frontend           0x00000001014fbe9c swift::SILType::getFieldType(swift::VarDecl*, swift::Lowering::TypeConverter&, swift::TypeExpansionContext) const + 532
14 swift-frontend           0x0000000100a38064 swift::irgen::TypeConverter::convertStructType(swift::TypeBase*, swift::CanType, swift::StructDecl*) + 5756
15 swift-frontend           0x0000000100a65360 swift::irgen::TypeConverter::getTypeEntry(swift::CanType) + 1108
16 swift-frontend           0x00000001009b11c4 swift::irgen::IRGenModule::emitSILGlobalVariable(swift::SILGlobalVariable*) + 208
17 swift-frontend           0x000000010092037c swift::irgen::IRGenerator::emitGlobalTopLevel(std::__1::vector<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>, std::__1::allocator<std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char>>>> const&) + 2292
18 swift-frontend           0x0000000100a7f940 swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const + 4016
19 swift-frontend           0x0000000100ac954c swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::IRGenRequest const&, swift::Evaluator&) + 176
20 swift-frontend           0x0000000100a8c264 llvm::Expected<swift::IRGenRequest::OutputType> swift::Evaluator::getResultUncached<swift::IRGenRequest>(swift::IRGenRequest const&) + 836
21 swift-frontend           0x0000000100a82438 swift::performIRGeneration(swift::FileUnit*, swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::GlobalVariable**) + 264
22 swift-frontend           0x00000001005b00b8 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>>>) + 156
23 swift-frontend           0x00000001005aa294 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*) + 1892
24 swift-frontend           0x00000001005a9444 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 608
25 swift-frontend           0x00000001005ad694 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 1448
26 swift-frontend           0x00000001005ab6d0 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 4968
27 swift-frontend           0x000000010053ae8c swift::mainEntry(int, char const**) + 2612
28 dyld                     0x00000001924da0e0 start + 2360
Command SwiftCompile failed with a nonzero exit code

Environment

swift-driver version: 1.90.11.1 Apple Swift version 5.10 (swiftlang-5.10.0.13 clang-1500.3.9.4)
Target: arm64-apple-macosx14.0

@vanvoorden vanvoorden 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 Jun 21, 2024
@vanvoorden
Copy link
Contributor Author

@AnthonyLatsis Would you know if we were tracking anything related to this? This crash seems to be fixed in 6.0… but I don't know if someone landed a fix to this issue directly or this fix came along implicitly with a fix for a different issue. Were there any related 5.10 workarounds to another issue that might workaround this one before 6.0 ships? Thanks!

@vanvoorden
Copy link
Contributor Author

@slavapestov Do you remember if we were tracking anything similar to this in 5.10? Do you know if we documented any workarounds to compile that code from 5.10? Thanks!

@hborla hborla added parameter packs Feature → generics: Parameter packs and removed triage needed This issue needs more specific labels labels Jul 14, 2024
@AnthonyLatsis AnthonyLatsis added compiler The Swift compiler itself generics Feature: generic declarations and types function types Feature → types: function types types Feature: types swift 5.10 IRGen LLVM IR generation properties Feature: properties needs tests Flag: Issue is fixed but needs tests / PR needs tests good first issue Good for newcomers labels Jul 15, 2024
@AnthonyLatsis
Copy link
Collaborator

Would you know if we were tracking anything related to this? This crash seems to be fixed in 6.0…

I could not find anything similar enough. It seems so — I cannot get it to crash either.

As for workarounds, indirection does the job, as it often does:

private struct FnBox<T> {
  let fn: () -> T
}

struct Repeater<each Element> {
  private let _elements: (repeat FnBox<each Element>)

  var elements: (repeat () -> each Element) {
    return (repeat (each _elements).fn)
  }

  init(elements element: repeat @escaping () -> each Element) {
    self._elements = (repeat FnBox(fn: each element))
  }

  func printElements() {
    print((repeat (each elements)()))
  }
}

let repeater = Repeater(elements: { 2 }, { "" }, { true })
repeater.printElements()

@AnthonyLatsis
Copy link
Collaborator

Dear first-time contributors, this only needs an IRGen test case. Here is a minimal crash reproduction for Swift 5.10:

struct Foo<each T> {
  let tuple: (repeat () -> each T)
}

func test(_: Foo<Int>) {} // Boom
// func test(_: Foo<Int, Int>) {} // No boom

@vanvoorden
Copy link
Contributor Author

Dear first-time contributors, this only needs an IRGen test case. Here is a minimal crash reproduction for Swift 5.10:

struct Foo<each T> {
  let tuple: (repeat () -> each T)
}

func test(_: Foo<Int>) {} // Boom
// func test(_: Foo<Int, Int>) {} // No boom

@AnthonyLatsis Hmm… I was unable to repro the crash with this example from Xcode_15.4.0 and swiftlang-5.10.0.13 clang-1500.3.9.4. Are there are any specific parameters I should be passing to the compiler for that for producing the crash?

@vanvoorden
Copy link
Contributor Author

Would you know if we were tracking anything related to this? This crash seems to be fixed in 6.0…

I could not find anything similar enough. It seems so — I cannot get it to crash either.

As for workarounds, indirection does the job, as it often does:

private struct FnBox<T> {
  let fn: () -> T
}

struct Repeater<each Element> {
  private let _elements: (repeat FnBox<each Element>)

  var elements: (repeat () -> each Element) {
    return (repeat (each _elements).fn)
  }

  init(elements element: repeat @escaping () -> each Element) {
    self._elements = (repeat FnBox(fn: each element))
  }

  func printElements() {
    print((repeat (each elements)()))
  }
}

let repeater = Repeater(elements: { 2 }, { "" }, { true })
repeater.printElements()

Ahh… it looks like this works for me for 5.10 and unblocks my original use-case. Thanks!

@AnthonyLatsis
Copy link
Collaborator

AnthonyLatsis commented Jul 16, 2024

I was unable to repro the crash with this example from Xcode_15.4.0 and swiftlang-5.10.0.13 clang-1500.3.9.4.

I confirmed the crash with the godbolt.org 5.10 compiler. Does it reproduce in your terminal? Try

echo 'struct Foo<each T> {let tuple: (repeat () -> each T)};func test(_: Foo<Int>) {}' | swiftc -emit-ir -

where swiftc is your 5.10 compiler.

@vanvoorden
Copy link
Contributor Author

'struct Foo<each T> {let tuple: (repeat () -> each T)};func test(_: Foo<Int>) {}'

https://gist.github.com/vanvoorden/aa279eb43920870f70dac07343c5fcc2

Hmm… I tried this locally and don't see a crash in here. Godbolt looks like it is running on Intel. I am running on Apple Silicon. Would that have something to do with it?

@AnthonyLatsis
Copy link
Collaborator

AnthonyLatsis commented Jul 16, 2024

Godbolt looks like it is running on Intel. I am running on Apple Silicon.

Ok, this is starting to make more sense. A x86_64-apple-macosx14.0 5.10 asserts compiler downloaded from Swift.org hits an LLVM assertion:

Assertion failed: (isa<To>(Val) && "cast<Ty>() argument of incompatible type!"), function cast, file Casting.h, line 578.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /Users/mac/Library/Developer/Toolchains/swift-5.10-DEVELOPMENT-SNAPSHOT-2024-05-31-a.xctoolchain/usr/bin/swift-frontend -frontend -emit-ir -primary-file - -target x86_64-apple-macosx14.0 -enable-objc-interop -color-diagnostics -new-driver-path /Users/mac/Library/Developer/Toolchains/swift-5.10-DEVELOPMENT-SNAPSHOT-2024-05-31-a.xctoolchain/usr/bin/swift-driver -empty-abi-descriptor -resource-dir /Users/mac/Library/Developer/Toolchains/swift-5.10-DEVELOPMENT-SNAPSHOT-2024-05-31-a.xctoolchain/usr/lib/swift -module-name main -plugin-path /Users/mac/Library/Developer/Toolchains/swift-5.10-DEVELOPMENT-SNAPSHOT-2024-05-31-a.xctoolchain/usr/lib/swift/host/plugins -plugin-path /Users/mac/Library/Developer/Toolchains/swift-5.10-DEVELOPMENT-SNAPSHOT-2024-05-31-a.xctoolchain/usr/local/lib/swift/host/plugins -o -
1.	Apple Swift version 5.10-dev (LLVM e98989b1092ff3a, Swift 0e5cb27c42ec3c7)
2.	Compiling with the current language version
3.	While evaluating request IRGenRequest(IR Generation for file "<stdin>")
4.	While evaluating request ExecuteSILPipelineRequest(Run pipelines { IRGen Preparation } on SIL for main)
5.	While running pass #4 SILModuleTransform "LoadableByAddress".
6.	While converting type 'Foo<Int>' (declared at [<stdin>:1:1 - line:1:53] RangeText="struct Foo<each T> {let tuple: (repeat () -> each T)")
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           0x000000010f02fb8b llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 43
1  swift-frontend           0x000000010f02eed5 llvm::sys::RunSignalHandlers() + 85
2  swift-frontend           0x000000010f0301be SignalHandler(int) + 270
3  libsystem_platform.dylib 0x00007ff80d870fdd _sigtramp + 29
4  swift-frontend           0x000000010ac8e9b2 profileParams(llvm::FoldingSetNodeID&, llvm::ArrayRef<swift::AnyFunctionType::Param>) + 34
5  libsystem_c.dylib        0x00007ff80d767a79 abort + 126
6  libsystem_c.dylib        0x00007ff80d766d68 err + 0
7  swift-frontend           0x000000010f410b63 swift::Lowering::AbstractionPattern::getNumFunctionParams() const (.cold.5) + 35
8  swift-frontend           0x000000010a485e58 swift::Lowering::AbstractionPattern::getNumFunctionParams() const + 104
9  swift-frontend           0x000000010a486024 swift::Lowering::FunctionParamGenerator::FunctionParamGenerator(swift::Lowering::AbstractionPattern, swift::ArrayRefView<swift::AnyFunctionType::Param, swift::AnyFunctionType::CanParam, swift::AnyFunctionType::CanParam::getFromParam(swift::AnyFunctionType::Param const&), true>, bool) + 212
10 swift-frontend           0x000000010a488aa1 (anonymous namespace)::SubstFunctionTypePatternVisitor::handleUnabstractedFunctionType(swift::CanTypeWrapper<swift::AnyFunctionType>, swift::Lowering::AbstractionPattern, swift::CanType, swift::Lowering::AbstractionPattern) + 177
11 swift-frontend           0x000000010a488607 swift::Lowering::AbstractionPattern::getSubstFunctionTypePattern(swift::CanTypeWrapper<swift::AnyFunctionType>, swift::Lowering::TypeConverter&, swift::Lowering::AbstractionPattern, swift::CanType, bool&) const + 503
12 swift-frontend           0x000000010a4d6a93 getSILFunctionType(swift::Lowering::TypeConverter&, swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILExtInfoBuilder, (anonymous namespace)::Conventions const&, swift::ForeignInfo const&, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SubstitutionMap>, swift::ProtocolConformanceRef) + 6339
13 swift-frontend           0x000000010a4cbfba getNativeSILFunctionType(swift::Lowering::TypeConverter&, swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanTypeWrapper<swift::AnyFunctionType>, swift::SILExtInfoBuilder, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SILDeclRef>, llvm::Optional<swift::SubstitutionMap>, swift::ProtocolConformanceRef) + 1546
14 swift-frontend           0x000000010a578165 swift::Lowering::TypeConverter::computeLoweredRValueType(swift::TypeExpansionContext, swift::Lowering::AbstractionPattern, swift::CanType)::LoweredRValueTypeVisitor::visitAnyFunctionType(swift::CanTypeWrapper<swift::AnyFunctionType>) + 901
15 swift-frontend           0x000000010a5641b4 swift::Lowering::TypeConverter::getTypeLowering(swift::Lowering::AbstractionPattern, swift::Type, swift::TypeExpansionContext) + 900
16 swift-frontend           0x000000010a558c11 swift::SILType::getFieldType(swift::VarDecl*, swift::Lowering::TypeConverter&, swift::TypeExpansionContext) const + 241
17 swift-frontend           0x0000000109a56a74 swift::irgen::TypeConverter::convertStructType(swift::TypeBase*, swift::CanType, swift::StructDecl*) + 1140
18 swift-frontend           0x0000000109a7e751 swift::irgen::TypeConverter::convertAnyNominalType(swift::CanType, swift::NominalTypeDecl*) + 417
19 swift-frontend           0x0000000109a7ce81 swift::irgen::TypeConverter::convertType(swift::CanType) + 289
20 swift-frontend           0x0000000109a7c6e0 swift::irgen::TypeConverter::getTypeEntry(swift::CanType) + 768
21 swift-frontend           0x0000000109b2a351 isLargeLoadableType(swift::GenericEnvironment*, swift::SILType, swift::irgen::IRGenModule&) + 289
22 swift-frontend           0x0000000109b295bb LargeSILTypeMapper::getNewSILType(swift::GenericEnvironment*, swift::SILType, swift::irgen::IRGenModule&) + 459
23 swift-frontend           0x0000000109b3c4ba (anonymous namespace)::LoadableStorageAllocation::allocateLoadableStorage() + 1258
24 swift-frontend           0x0000000109b2b671 (anonymous namespace)::LoadableByAddress::run() + 849
25 swift-frontend           0x0000000109feeac1 swift::SILPassManager::runModulePass(unsigned int) + 865
26 swift-frontend           0x0000000109ff174b swift::SILPassManager::execute() + 619
27 swift-frontend           0x0000000109feb638 swift::SILPassManager::executePassPipelinePlan(swift::SILPassPipelinePlan const&) + 72
28 swift-frontend           0x0000000109feb5b1 swift::ExecuteSILPipelineRequest::evaluate(swift::Evaluator&, swift::SILPipelineExecutionDescriptor) const + 65
29 swift-frontend           0x000000010a02bf5d swift::SimpleRequest<swift::ExecuteSILPipelineRequest, std::__1::tuple<> (swift::SILPipelineExecutionDescriptor), (swift::RequestFlags)1>::evaluateRequest(swift::ExecuteSILPipelineRequest const&, swift::Evaluator&) + 29
30 swift-frontend           0x000000010a006489 llvm::Expected<swift::ExecuteSILPipelineRequest::OutputType> swift::Evaluator::getResultUncached<swift::ExecuteSILPipelineRequest>(swift::ExecuteSILPipelineRequest const&) + 233
31 swift-frontend           0x0000000109feb7e2 swift::executePassPipelinePlan(swift::SILModule*, swift::SILPassPipelinePlan const&, bool, swift::irgen::IRGenModule*) + 82
32 swift-frontend           0x0000000109a98dee swift::IRGenRequest::evaluate(swift::Evaluator&, swift::IRGenDescriptor) const + 2590
33 swift-frontend           0x0000000109af3fcf swift::GeneratedModule swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)9>::callDerived<0ul>(swift::Evaluator&, std::__1::integer_sequence<unsigned long, 0ul>) const + 223
34 swift-frontend           0x0000000109af3eae swift::SimpleRequest<swift::IRGenRequest, swift::GeneratedModule (swift::IRGenDescriptor), (swift::RequestFlags)9>::evaluateRequest(swift::IRGenRequest const&, swift::Evaluator&) + 14
35 swift-frontend           0x0000000109aa58d6 llvm::Expected<swift::IRGenRequest::OutputType> swift::Evaluator::getResultUncached<swift::IRGenRequest>(swift::IRGenRequest const&) + 246
36 swift-frontend           0x0000000109a9b717 swift::performIRGeneration(swift::FileUnit*, swift::IRGenOptions const&, swift::TBDGenOptions const&, std::__1::unique_ptr<swift::SILModule, std::__1::default_delete<swift::SILModule>>, llvm::StringRef, swift::PrimarySpecificPaths const&, llvm::StringRef, llvm::GlobalVariable**) + 311
37 swift-frontend           0x0000000109550444 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>>>) + 180
38 swift-frontend           0x000000010954bc5e 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*) + 1566
39 swift-frontend           0x000000010954ae06 swift::performCompileStepsPostSema(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 806
40 swift-frontend           0x000000010955db5f withSemanticAnalysis(swift::CompilerInstance&, swift::FrontendObserver*, llvm::function_ref<bool (swift::CompilerInstance&)>, bool) + 143
41 swift-frontend           0x000000010954dc17 performCompile(swift::CompilerInstance&, int&, swift::FrontendObserver*) + 935
42 swift-frontend           0x000000010954c9c0 swift::performFrontend(llvm::ArrayRef<char const*>, char const*, void*, swift::FrontendObserver*) + 3136
43 swift-frontend           0x00000001093f1370 swift::mainEntry(int, char const**) + 1648
44 dyld                     0x00007ff80d4b6366 start + 1942
Abort trap: 6

Since neither yours nor the Godbolt 5.10 compilers hit an assertion, they must be no-asserts compilers. Without this assertion to terminate the program we get a memory access violation, which appears to not be deterministically caught by Apple Silicon in contrast to x86_64.

@vanvoorden
Copy link
Contributor Author

@AnthonyLatsis For some reason this workaround seems to lead to some Global is external, but doesn't have external or weak linkage! crashes. I am unblocked with the workarounds from #75405.

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. compiler The Swift compiler itself crash Bug: A crash, i.e., an abnormal termination of software function types Feature → types: function types generics Feature: generic declarations and types good first issue Good for newcomers IRGen LLVM IR generation needs tests Flag: Issue is fixed but needs tests / PR needs tests parameter packs Feature → generics: Parameter packs properties Feature: properties swift 5.10 types Feature: types
Projects
None yet
Development

No branches or pull requests

3 participants