Description
Description
A runtime error is generated when attempting to run SwiftLint
after building it (either in Debug or Release mode) under Linux. It appears to affect x86_64
and aarch64
platforms, albeit only on the nightly snapshots (the 5.9 Release branch is not affected).
The error generated at runtime is:
failed to demangle witness for associated type '' in conformance 'Swift.Array<SwiftParser.Parser.ExperimentalFeatures>: Sequence' from mangled name '?z??ySayxGG' - subject type x does not conform to protocol Collection
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
Stack dump:
0. While evaluating request ExportedSourceFileRequest(source_file "/home/user/s7/Plugins/SwiftLintPlugin/SwiftLintPlugin.swift")
Steps to reproduce
Running the following commands on the terminal window is sufficient to reproduce this issue:
mkdir SwiftLint
cd SwiftLint
git clone https://github.com/realm/SwiftLint . --depth 1
rm ./Tests/SwiftLintTestHelpers/*.swift
swift build -Xswiftc -static-stdlib
./.build/aarch64-unknown-linux-gnu/debug/swiftlint
If building for x86_64, the executable may be found inside .build/x86_64-unknown-linux-gnu/debug
. Otherwise, search for the generated swiftlint
executable.
In the above example, we are Linting the SwiftLint repository itself. It is sufficient to trigger the runtime crash, but for a minimal reproducer of files that require Linting, one can make new directory with a single file called Package.swift
; the file only needs to contain // swift-tools-version:5.8
(note that a blank file won't trigger the crash).
Expected behavior
The program should Lint all specified files successfully.
Environment
- Swift compiler version info: 2023-09-20a, 2023-09-26a nightly toolchains.
- Xcode version info: N/A
- Deployment target: Linux x86_64 (Ubuntu 18.04), Linux ARM64 (Ubuntu 20.04).
Additional context
Some additional packages may need to be installed (this list is not exhaustive):
apt install libcurl4-openssl-dev libxml2-dev
No issues were found when building for macOS; in fact the -Xswiftc -static-stdlib
flag is not supported.
Here is a stack trace from an lldb
run on Ubuntu 18, x86_64:
* thread #72, name = 'swiftlint', stop reason = signal SIGABRT
* frame #0: 0x00007ffff6477e87 libc.so.6`__GI_raise(sig=<unavailable>) at raise.c:51
frame #1: 0x00007ffff64797f1 libc.so.6`__GI_abort at abort.c:79
frame #2: 0x0000555557a862f9 swiftlint`swift::fatalErrorv(unsigned int, char const*, __va_list_tag*) + 137
frame #3: 0x0000555557a86383 swiftlint`swift::fatalError(unsigned int, char const*, ...) + 131
frame #4: 0x0000555557a9ee4a swiftlint`swift_getAssociatedTypeWitnessSlow + 1274
frame #5: 0x0000555557a9e945 swiftlint`swift_getAssociatedTypeWitness + 37
frame #6: 0x00005555578faeb5 swiftlint`Swift.SetAlgebra.init<τ_0_0 where τ_1_0: Swift.Sequence, τ_0_0.Element == τ_1_0.Element>(__owned τ_1_0) -> τ_0_0 + 197
frame #7: 0x0000555556b9f276 swiftlint`protocol witness for SetAlgebra.init<A>(_:) in conformance Parser.ExperimentalFeatures at <compiler-generated>:0
frame #8: 0x00007fffc6f25523 libsourcekitdInProc.so`swiftASTGen.parseSourceFile(buffer: Swift.UnsafePointer<Swift.UInt8>, bufferLength: Swift.Int, moduleName: Swift.UnsafePointer<Swift.UInt8>, filename: Swift.UnsafePointer<Swift.UInt8>, ctxPtr: Swift.Optional<Swift.UnsafeMutableRawPointer>) -> Swift.UnsafeRawPointer + 291
frame #9: 0x00007fffc6e7e72d libsourcekitdInProc.so`swift::ExportedSourceFileRequest::evaluate(swift::Evaluator&, swift::SourceFile const*) const + 509
frame #10: 0x00007fffc7226f2d libsourcekitdInProc.so`llvm::Expected<swift::ExportedSourceFileRequest::OutputType> swift::Evaluator::getResultUncached<swift::ExportedSourceFileRequest>(swift::ExportedSourceFileRequest const&) + 397
frame #11: 0x00007fffc7226bc3 libsourcekitdInProc.so`llvm::Expected<swift::ExportedSourceFileRequest::OutputType> swift::Evaluator::getResultCached<swift::ExportedSourceFileRequest, (void*)0>(swift::ExportedSourceFileRequest const&) + 435
frame #12: 0x00007fffc7202848 libsourcekitdInProc.so`swift::ExportedSourceFileRequest::OutputType swift::evaluateOrDefault<swift::ExportedSourceFileRequest>(swift::Evaluator&, swift::ExportedSourceFileRequest, swift::ExportedSourceFileRequest::OutputType) + 24
frame #13: 0x00007fffc7202826 libsourcekitdInProc.so`swift::SourceFile::getExportedSourceFile() const + 38
frame #14: 0x00007fffc6e7d5fc libsourcekitdInProc.so`swift::Parser::parseTopLevelItems(llvm::SmallVectorImpl<swift::ASTNode>&) + 204
frame #15: 0x00007fffc6eda36a libsourcekitdInProc.so`swift::ParserUnit::parse() + 90
frame #16: 0x00007fffc56468e6 libsourcekitdInProc.so`void SourceKit::WorkQueue::DispatchData::callAndDelete<(anonymous namespace)::SwiftDocumentSyntaxInfo::parseIfNeeded()::'lambda'()>(void*) + 22
frame #17: 0x00007fffcb7dca3a libsourcekitdInProc.so`executeBlock(void*) + 10
frame #18: 0x00007fffcb7dca5a libsourcekitdInProc.so`void* llvm::thread::ThreadProxy<std::tuple<void (*)(void*), void*>>(void*) + 10
frame #19: 0x00007ffff71d96db libpthread.so.0`start_thread(arg=0x00007fff967cc700) at pthread_create.c:463
frame #20: 0x00007ffff655a61f libc.so.6`__clone at clone.S:95