sourcekit-lsp
sourcekit-lsp copied to clipboard
crash on moving nested generic type to its own file
finally got at least one of the crashes from https://forums.swift.org/t/vscode-with-5-9-stopping-server-failed/67397/ isolated to a minimal reproducer.
steps to reproduce:
- create an SPM project containing the following sources:
Package.swift
// swift-tools-version: 5.9
// The swift-tools-version declares the minimum version of Swift required to build this package.
import PackageDescription
let package = Package(
name: "swift-vscode-test",
products: [
// Products define the executables and libraries a package produces, making them visible to other packages.
.library(
name: "swift-vscode-test",
targets: ["swift-vscode-test"]),
],
dependencies:
[
.package(url: "https://github.com/apple/swift-atomics", .upToNextMinor(
from: "1.1.0")),
],
targets: [
// Targets are the basic building blocks of a package, defining a module or a test suite.
// Targets can depend on other targets in this package and products from dependencies.
.target(
name: "swift-vscode-test",
dependencies: [
.product(name: "Atomics", package: "swift-atomics"),
]),
.testTarget(
name: "swift-vscode-testTests",
dependencies: ["swift-vscode-test"]),
]
)
A.swift
import Atomics
@frozen public
struct A<T> where T:AtomicValue, T == T.AtomicRepresentation.Value
{
let b:B
init(t:T)
{
self.b = .init(x: t)
}
}
extension A
{
@frozen public
struct B
{
let x:ManagedAtomic<T>
init(x:T)
{
self.x = .init(x)
}
}
}
here is a zip archive with the exact directory layout i used:
-
cut and paste the
A.B
type to its own file, using Ctrl-N to create a new file, pasting the contents, and saving it with a new file nameB.swift
.
B.swift
extension A
{
@frozen public
struct B
{
let x:ManagedAtomic<T>
init(x:T)
{
self.x = .init(x)
}
}
}
note that the required import Atomics
is not included.
-
save the modified
A.swift
. -
close both files
A.swift
andB.swift
in VSCode, observing a message similar to the following in the sourcekit-lsp output:
[Trace - 8:40:53 PM] Sending request 'textDocument/codeAction - (43)'.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
[Trace - 8:40:54 PM] Sending notification '$/cancelRequest'.
-
reopen both files
A.swift
andB.swift
and observe that neither has any syntax highlighting. -
wait 15 seconds.
-
observe a crash dump appearing in the sourcekit-lsp output that looks like the following:
*** Program crashed: Illegal instruction at 0x00005630bf6b02c3 ***
Thread 0 "sourcekit-lsp":
0 0x00007fb0e9df9fee __sigsuspend + 62 in libc-2.26.so
Thread 1:
0 0x00007fb0e9eb584c epoll_wait + 92 in libc-2.26.so
Thread 2:
0 0x00007fb0e9eb584c epoll_wait + 92 in libc-2.26.so
Thread 3:
0 0x00007fb0eaf71377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so
Thread 4:
0 0x00007fb0e9eb584c epoll_wait + 92 in libc-2.26.so
Thread 5:
0 0x00007fb0eaf71377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so
Thread 6:
0 0x00007fb0e9eb584c epoll_wait + 92 in libc-2.26.so
Thread 7:
0 0x00007fb0eaf71377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so
Thread 8:
0 0x00007fb0e9eb584c epoll_wait + 92 in libc-2.26.so
Thread 9:
0 0x00007fb0eaf71377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so
Thread 10:
0 0x00007fb0e9eb584c epoll_wait + 92 in libc-2.26.so
Thread 11:
0 0x00007fb0eaf71377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so
Thread 12:
0 0x00007fb0e9eb584c epoll_wait + 92 in libc-2.26.so
Thread 13:
0 0x00007fb0eaf71377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so
Thread 14:
0 0x00007fb0e9eb584c epoll_wait + 92 in libc-2.26.so
Thread 15:
0 0x00007fb0eaf71377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so
Thread 16:
0 0x00007fb0eaf73c10 do_futex_wait + 64 in libpthread-2.26.so
Thread 17:
0 0x00007fb0ec71a750 swift_getAssociatedTypeWitness in libswiftCore.so
1 [ra] [thunk] 0x00007fb0ec5f05ba protocol witness for _UnicodeParser.parseScalar<A>(from:) in conformance Unicode.UTF16.ForwardParser + 57 in libswiftCore.so
2 [ra] 0x00007fb0ec4b79dc static String._fromCodeUnits<A, B>(_:encoding:repair:) + 1179 in libswiftCore.so
Thread 18:
0 0x00007fb0eaf73c10 do_futex_wait + 64 in libpthread-2.26.so
Thread 19:
0 0x00007fb0eaf73c10 do_futex_wait + 64 in libpthread-2.26.so
Thread 20:
0 0x00007fb0eaf73c10 do_futex_wait + 64 in libpthread-2.26.so
Thread 21 crashed:
0 [system] 0x00005630bf6b02c3 closure #1 in BuildSystemManager.unregisterForChangeNotifications(for:) + 259 in sourcekit-lsp at /home/build-user/sourcekit-lsp/<compiler-generated>
Thread 22:
0 0x00007fb0eaf73c10 do_futex_wait + 64 in libpthread-2.26.so
Thread 23:
0 0x00007fb0eaf73c10 do_futex_wait + 64 in libpthread-2.26.so
Thread 24:
0 0x00007fb0eaf73c10 do_futex_wait + 64 in libpthread-2.26.so
Thread 25:
0 0x00007fb0eaf6c74a pthread_join + 186 in libpthread-2.26.so
Thread 26:
0 0x00007fb0eaf73c10 do_futex_wait + 64 in libpthread-2.26.so
Thread 27:
0 0x00007fb0eaf73c10 do_futex_wait + 64 in libpthread-2.26.so
Thread 28:
0 0x00007fb0eaf73c10 do_futex_wait + 64 in libpthread-2.26.so
Thread 29:
0 0x00007fb0eaf6c74a pthread_join + 186 in libpthread-2.26.so
Thread 30:
0 0x00007fb0eaf73c10 do_futex_wait + 64 in libpthread-2.26.so
Thread 31:
0 0x00007fb0e9ea6e05 __lxstat64 + 21 in libc-2.26.so
1 [ra] 0x00007fafdfc9ee04 llvm::sys::fs::real_path(llvm::Twine const&, llvm::SmallVectorImpl<char>&, bool) + 211 in libsourcekitdInProc.so
2 [ra] 0x6373762d74666977
Registers:
rax 0x0000000800000003 34359738371
rdx 0x00007fb0bc1c9620 68 80 e1 c0 30 56 00 00 78 92 83 17 f6 0f 00 c0 h·áÀ0V··x···ö··À
rcx 0xfffffffe00000000 18446744065119617024
rbx 0x0000000600000003 25769803779
rsi 0x00007faffc030218 03 00 00 00 00 00 00 00 f0 4b 01 fc af 7f 00 00 ········ðK·ü¯···
rdi 0xa61887ea18c9f045 11968465449245077573
rbp 0x0000000000000000 0
rsp 0x00007fb03e2edb50 40 96 1c bc b0 7f 00 00 ea 01 6b bf 30 56 00 00 @··¼°···ê·k¿0V··
r8 0x24ead53e80009bf9 2660172994327911417
r9 0x80000000ffffffff 9223372041149743103
r10 0x0000000100000000 4294967296
r11 0x0000000200000000 8589934592
r12 0x0000000000000000 0
r13 0x00007fb0dc042e90 e8 ee 72 bc b0 7f 00 00 03 00 00 00 00 00 00 00 èîr¼°···········
r14 0x80007faffc030210 9223512430678835728
r15 0x00007fb0bc1c9640 90 2e 04 dc b0 7f 00 00 30 76 04 dc b0 7f 00 00 ·.·Ü°···0v·Ü°···
rip 0x00005630bf6b02c3 0f 0b 66 66 2e 0f 1f 84 00 00 00 00 00 55 41 57 ··ff.········UAW
rflags 0x0000000000010246 ZF PF
cs 0x0033 fs 0x0000 gs 0x0000
Images (66 omitted):
0x00005630beb55000–0x00005630c0b088c0 <no build ID> sourcekit-lsp /usr/bin/sourcekit-lsp
0x00007fafdf20e000–0x00007fafe5f30a70 <no build ID> libsourcekitdInProc.so /usr/lib/libsourcekitdInProc.so
0x00007fb0e9dc6000–0x00007fb0e9f6947c 53637569236bdb02fc17a3530699a635d2f98f6e libc-2.26.so /usr/lib64/libc-2.26.so
0x00007fb0eaf64000–0x00007fb0eaf7bf7c 0231966c233a89975bc72a53fd9d6bd2792392bd libpthread-2.26.so /usr/lib64/libpthread-2.26.so
0x00007fb0ec30a000–0x00007fb0ec84deb8 <no build ID> libswiftCore.so /usr/lib/swift/linux/libswiftCore.so
[Info - 8:41:33 PM] Connection to server got closed. Server will restart.
VSCode plugin version: 1.5.2 VSCode version: 1.82.2 swift version: 5.9-RELEASE
Hmm, unfortunately, I can’t reproduce the crash on macOS and I don’t have a Linux environment set up currently where I could test it.
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
indicates that maybe clangd is crashing but I don’t know why we would start clangd since it’s only a Swift project.
Could you reproduce the failure with debug logging enabled? I expect that it should give me a bit more information about what the internal state does.
"swift.swiftEnvironmentVariables": {
"SOURCEKIT_LOGGING": "3"
}
where do i add these lines to enable debug logging?
It’s a VS Code setting in the Swift extension.
Tracked in Apple’s issue tracker as rdar://115859641
Closing this issue because this issue hasn’t received any updates in almost a year. Please re-open if you are able to provide the requested log output.