Skip to content

Linux compiler crash with parameter packs, works on macOS #76103

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

Open
GeorgeLyon opened this issue Aug 27, 2024 · 2 comments
Open

Linux compiler crash with parameter packs, works on macOS #76103

GeorgeLyon opened this issue Aug 27, 2024 · 2 comments
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 generics Feature: generic declarations and types triage needed This issue needs more specific labels

Comments

@GeorgeLyon
Copy link

Description

Crash when using parameter packs as an associated type

Reproduction

protocol Foo {
  associatedtype Value
  func foo(_ value: Value)
}

struct ComplexFoo<each Bar: Foo>: Foo {
  typealias Value = (repeat (each Bar).Value)
  func foo(_ value: Value) {

  }
}

Stack dump

Building for debugging...
error: compile command failed due to signal 6 (use -v to see invocation)
swift-frontend: /home/build-user/swift/lib/SILGen/ManagedValue.h:318: swift::SILValue swift::Lowering::ManagedValue::getLValueAddress() const: Assertion `isLValue() && "This isn't an lvalue"' 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 -primary-file /workspaces/Glaude/Test/Sources/Test/Test.swift -emit-dependencies-path /workspaces/Glaude/Test/.build/aarch64-unknown-linux-gnu/debug/Test.build/Test.d -emit-reference-dependencies-path /workspaces/Glaude/Test/.build/aarch64-unknown-linux-gnu/debug/Test.build/Test.swiftdeps -target aarch64-unknown-linux-gnu -Xllvm -aarch64-use-tbi -disable-objc-interop -I /workspaces/Glaude/Test/.build/aarch64-unknown-linux-gnu/debug/Modules -color-diagnostics -enable-testing -g -debug-info-format=dwarf -dwarf-version=4 -module-cache-path /workspaces/Glaude/Test/.build/aarch64-unknown-linux-gnu/debug/ModuleCache -swift-version 6 -Onone -D SWIFT_PACKAGE -D DEBUG -empty-abi-descriptor -resource-dir /usr/lib/swift -enable-anonymous-context-mangled-names -file-compilation-dir /workspaces/Glaude/Test -Xcc -fPIC -Xcc -g -Xcc -fno-omit-frame-pointer -module-name Test -package-name test -plugin-path /usr/lib/swift/host/plugins -plugin-path /usr/local/lib/swift/host/plugins -parse-as-library -o /workspaces/Glaude/Test/.build/aarch64-unknown-linux-gnu/debug/Test.build/Test.swift.o -index-store-path /workspaces/Glaude/Test/.build/aarch64-unknown-linux-gnu/debug/index/store -index-system-modules
1.      Swift version 6.0-dev (LLVM c3efe9282719c35, Swift b163fed2b3101e0)
2.      Compiling with the current language version
3.      While evaluating request ASTLoweringRequest(Lowering AST to SIL for file "/workspaces/Glaude/Test/Sources/Test/Test.swift")
4.      While generating SIL witness table protocol conformance ComplexFoo<repeat each Bar>: Foo at 'ComplexFoo' (at /workspaces/Glaude/Test/Sources/Test/Test.swift:12:1)
5.      While generating protocol witness thunk SIL function "@$s4Test10ComplexFooVyxxQp_QPGAA0C0A2aEP3fooyy5ValueQzFTW".
 for 'foo(_:)' (at /workspaces/Glaude/Test/Sources/Test/Test.swift:14: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  0x0000aaaae5d666e0
1  swift-frontend  0x0000aaaae5d646d4
2  swift-frontend  0x0000aaaae5d66dec
3  linux-vdso.so.1 0x0000ffff8d5a97a0 __kernel_rt_sigreturn + 0
4  libc.so.6       0x0000ffff8b8cf200
5  libc.so.6       0x0000ffff8b88a67c raise + 28
6  libc.so.6       0x0000ffff8b877130 abort + 228
7  libc.so.6       0x0000ffff8b883fd0
8  libc.so.6       0x0000ffff8b884040 __assert_perror_fail + 0
9  swift-frontend  0x0000aaaadfe274c0
10 swift-frontend  0x0000aaaadfe24884
11 swift-frontend  0x0000aaaadfe2c548
12 swift-frontend  0x0000aaaadfe1cc30
13 swift-frontend  0x0000aaaadfe1f888
14 swift-frontend  0x0000aaaadfe523a0
15 swift-frontend  0x0000aaaadfe54db4
16 swift-frontend  0x0000aaaadfe5461c
17 swift-frontend  0x0000aaaadfe53fc8
18 swift-frontend  0x0000aaaadfe512f8
19 swift-frontend  0x0000aaaadfe53574
20 swift-frontend  0x0000aaaadfe52f34
21 swift-frontend  0x0000aaaadfd562fc
22 swift-frontend  0x0000aaaadfe3eafc
23 swift-frontend  0x0000aaaadfd5b988
24 swift-frontend  0x0000aaaadfd56df4
25 swift-frontend  0x0000aaaadf67c780
26 swift-frontend  0x0000aaaadf689c98
27 swift-frontend  0x0000aaaadf67f114
28 swift-frontend  0x0000aaaadf67e31c
29 swift-frontend  0x0000aaaadf466f60
30 libc.so.6       0x0000ffff8b8773fc
31 libc.so.6       0x0000ffff8b8774cc __libc_start_main + 152
32 swift-frontend  0x0000aaaadf466170

Expected behavior

Deos not crash (the same code does not crash on macOS)

Environment

Swift version 6.0-dev (LLVM c3efe9282719c35, Swift b163fed)
Target: aarch64-unknown-linux-gnu

Additional information

Using a struct to wrap the tuple also works fine i.e. typealias Value = Baz<repeat (each Bar).Value>

@GeorgeLyon GeorgeLyon 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 Aug 27, 2024
@rjmansfield
Copy link
Contributor

This also happens on macOS with a compiler built with asserts enabled and happens with HEAD (6c99946).

Assertion failed: (isLValue() && "This isn't an lvalue"), function getLValueAddress, file ManagedValue.h, line 319.
Please submit a bug report (https://swift.org/contributing/#reporting-bugs) and include the crash backtrace.
Stack dump:
0.	Program arguments: /Users/ryan_mansfield/swift/build/Ninja-RelWithDebInfoAssert/swift-macosx-arm64/bin/swift-frontend -frontend -c -primary-file /Users/ryan_mansfield/crash.swift -target arm64-apple-macosx15.0 -Xllvm -aarch64-use-tbi -enable-objc-interop -color-diagnostics -empty-abi-descriptor -Xcc -working-directory -Xcc /Users/ryan_mansfield/swift/llvm-project/lldb -resource-dir /Users/ryan_mansfield/swift/build/Ninja-RelWithDebInfoAssert/swift-macosx-arm64/lib/swift -module-name crash -in-process-plugin-server-path /Users/ryan_mansfield/swift/build/Ninja-RelWithDebInfoAssert/swift-macosx-arm64/lib/swift/host/libSwiftInProcPluginServer.dylib -plugin-path /Users/ryan_mansfield/swift/build/Ninja-RelWithDebInfoAssert/swift-macosx-arm64/lib/swift/host/plugins -plugin-path /Users/ryan_mansfield/swift/build/Ninja-RelWithDebInfoAssert/swift-macosx-arm64/local/lib/swift/host/plugins -o /var/folders/cl/z48nl9xx18307rwb9l42n2yr0000gn/T/TemporaryDirectory.wat6UR/crash-1.o
1.	Swift version 6.1-dev (LLVM 834570a7ffed2b3, Swift 6c9994632acb5c3)
2.	Compiling with effective version 5.10
3.	While evaluating request ASTLoweringRequest(Lowering AST to SIL for file "/Users/ryan_mansfield/crash.swift")
4.	While generating SIL witness table protocol conformance ComplexFoo<repeat each Bar>: Foo at 'ComplexFoo' (at /Users/ryan_mansfield/crash.swift:6:1)
5.	While generating protocol witness thunk SIL function "@$s5crash10ComplexFooVyxxQp_QPGAA0C0A2aEP3fooyy5ValueQzFTW".
 for 'foo(_:)' (at /Users/ryan_mansfield/crash.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           0x000000010a4d260c llvm::sys::PrintStackTrace(llvm::raw_ostream&, int) + 56
1  swift-frontend           0x000000010a4d0d60 llvm::sys::RunSignalHandlers() + 112
2  swift-frontend           0x000000010a4d2c70 SignalHandler(int) + 332
3  libsystem_platform.dylib 0x0000000184668184 _sigtramp + 56
4  libsystem_pthread.dylib  0x0000000184632f70 pthread_kill + 288
5  libsystem_c.dylib        0x000000018453f908 abort + 128
6  libsystem_c.dylib        0x000000018453ec1c err + 0

There's a separate issue about how some of the release linux toolchains have asserts enabled which explains the difference between the two platforms.

@GeorgeLyon
Copy link
Author

GeorgeLyon commented Aug 27, 2024

To follow up, wrapping the associated type in a struct only gets a bit farther, but runs into a similar crash after adding some complexity.

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 generics Feature: generic declarations and types triage needed This issue needs more specific labels
Projects
None yet
Development

No branches or pull requests

3 participants