VSCode with 5.9 : Stopping server failed

ever since upgrading to 5.9, sourcekit-lsp on VSCode has gotten a lot more unstable, i continually get the “Client SourceKit Language Server: connection to server is erroring. Shutting down server.” problem, and the only logging output it prints is:

[Error - 4:44:34 PM] Stopping server failed
  Message: Cannot call write after a stream was destroyed
  Code: -32099 

has anyone else encountered something similar?

I have not seen this before. A couple of questions to help me figure out the problem:

  1. Is this on macOS, Linux or Windows?
  2. Do you get any semantic functionality (jump to definition, code completion, etc.) or do you get the error straight after opening your project?
  3. What kind of project are you opening? A Swift Package or a project with compile_commands.json?
  4. Do you also see this issue when opening a newly created SwiftPM package or only with specific projects? If it’s only one project, can you share it?
  5. Could you change the SourceKit-LSP logging (swift.sourcekit-lsp.trace.server) to verbose, open VSCode’s Output View, select “SourceKit Server” from the dropdown, reproduce the issue and share the log.

linux, in an Amazon Linux 2 docker container, with VSCode plugin version 1.5.1.

it usually happens when i split out a chunk of a file into a separate file, such as when using Ctrl-N to move a nested type to its own file.

an SPM project, but unfortunately i have not had time to reduce it to a smaller case.

i will usually see some output like:

sourcekit: [1:getBufferStamp:1186.6119] failed to stat file:  (No such file or directory)
sourcekit: [1:getBufferStamp:1186.8409] failed to stat file:  (No such file or directory)
sourcekit: [1:getBufferStamp:1186.8994] failed to stat file:  (No such file or directory)
sourcekit: [1:getBufferStamp:1186.9206] failed to stat file:  (No such file or directory)
sourcekit: [1:getBufferStamp:1186.9400] failed to stat file:  (No such file or directory)
sourcekit: [1:getBufferStamp:1186.9454] failed to stat file:  (No such file or directory)
sourcekit: [1:getBufferStamp:1186.9820] failed to stat file:  (No such file or directory)
sourcekit: [1:getBufferStamp:1186.9995] failed to stat file:  (No such file or directory)
2023-09-20 20:24:30.212 sourcekit-lsp[55220:792cf700] [warning]: dependency 'swift-hash' is not used by any target
PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.

the highlights will freeze for about 15 seconds, and the the crash trace will appear:

*** Program crashed: Illegal instruction at 0x0000557475b492c3 ***

Thread 0 "sourcekit-lsp":

0  0x00007f37dea51fee __sigsuspend + 62 in libc-2.26.so

Thread 1:

0  0x00007f37deb0d84c epoll_wait + 92 in libc-2.26.so

Thread 2:

0  0x00007f37deb0d84c epoll_wait + 92 in libc-2.26.so

Thread 3:

0  0x00007f37dfbc9377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so

Thread 4:

0  0x00007f37deb0d84c epoll_wait + 92 in libc-2.26.so

Thread 5:

0  0x00007f37dfbc9377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so

Thread 6:

0  0x00007f37deb0d84c epoll_wait + 92 in libc-2.26.so

Thread 7:

0  0x00007f37dfbc9377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so

Thread 8:

0  0x00007f37deb0d84c epoll_wait + 92 in libc-2.26.so

Thread 9:

0  0x00007f37dfbc9377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so

Thread 10:

0  0x00007f37deb0d84c epoll_wait + 92 in libc-2.26.so

Thread 11:

0  0x00007f37dfbc9377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so

Thread 12:

0  0x00007f37deb0d84c epoll_wait + 92 in libc-2.26.so

Thread 13:

0  0x00007f37dfbc9377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so

Thread 14:

0  0x00007f37dfbc474a pthread_join + 186 in libpthread-2.26.so

Thread 15:

0  0x00007f37deb044a7 getrusage + 7 in libc-2.26.so

Thread 16:

0  0x00007f37dfbcbc10 do_futex_wait + 64 in libpthread-2.26.so

Thread 17:

0  0x00007f37dfbcbc10 do_futex_wait + 64 in libpthread-2.26.so

Thread 18:

0  0x00007f37dfbcbc10 do_futex_wait + 64 in libpthread-2.26.so

Thread 19:

0  0x00007f37dfbcbc10 do_futex_wait + 64 in libpthread-2.26.so

Thread 20 crashed:

0 [system] 0x0000557475b492c3 closure #1 in BuildSystemManager.unregisterForChangeNotifications(for:) + 259 in sourcekit-lsp at /home/build-user/sourcekit-lsp/<compiler-generated>

Thread 21:

0  0x00007f37dfbcbc10 do_futex_wait + 64 in libpthread-2.26.so

Thread 22:

0  0x00007f37dfbcbc10 do_futex_wait + 64 in libpthread-2.26.so

Thread 23:

0  0x00007f37dfbc474a pthread_join + 186 in libpthread-2.26.so

Thread 24:

0  0x00007f37dfbc474a pthread_join + 186 in libpthread-2.26.so

Thread 25:

0  0x00007f37dfbcbc10 do_futex_wait + 64 in libpthread-2.26.so

Thread 26:

0  0x00007f37dfbcbc10 do_futex_wait + 64 in libpthread-2.26.so

Thread 27:

0  0x00007f37dfbcbc10 do_futex_wait + 64 in libpthread-2.26.so

Thread 28:

0  0x00007f36e11a34f0 swift::writeEscaped(llvm::StringRef, llvm::raw_ostream&) + 48 in libsourcekitdInProc.so

Thread 29:

0  0x00007f37deb0d521 clone + 49 in libc-2.26.so

Thread 30:

0  0x00007f36df73b2b0 llvm::opt::Option::acceptInternal(llvm::opt::ArgList const&, llvm::StringRef, unsigned int&) const + 160 in libsourcekitdInProc.so


Registers:

rax 0x0000000200000003  8589934595
rdx 0x00007f37b82b4230  68 10 2b 77 74 55 00 00 ba f6 03 f7 e6 0f 00 c0  h·+wtU··ºö·÷æ··À
rcx 0xfffffffe00000000  18446744065119617024
rbx 0x0000000000000003  3
rsi 0x00007f360f53f048  03 00 00 00 00 00 00 00 90 79 01 24 37 7f 00 00  ·········y·$7···
rdi 0x5f02b7e9fb98dfcd  6846236599132938189
rbp 0x0000000000000000  0
rsp 0x00007f37d79a6b50  50 42 2b b8 37 7f 00 00 ea 91 b4 75 74 55 00 00  PB+¸7···ê·´utU··
 r8 0x6508b0a325ab137d  7280263012402533245
 r9 0x80000000ffffffff  9223372041149743103
r10 0x0000000100000000  4294967296
r11 0x0000000200000000  8589934592
r12 0x0000000000000000  0
r13 0x00007f36bf203010  a0 cf 5d b8 37 7f 00 00 03 00 00 00 00 00 00 00   Ï]¸7···········
r14 0x80007f360f53f040  9223511907016896576
r15 0x00007f37b82b4250  10 30 20 bf 36 7f 00 00 f0 77 00 a0 37 7f 00 00  ·0 ¿6···ðw· 7···
rip 0x0000557475b492c3  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 (67 omitted):

0x0000557474fee000–0x0000557476fa18c0 <no build ID>                            sourcekit-lsp          /usr/bin/sourcekit-lsp
0x00007f36db40e000–0x00007f36e2130a70 <no build ID>                            libsourcekitdInProc.so /usr/lib/libsourcekitdInProc.so
0x00007f37dea1e000–0x00007f37debc147c 53637569236bdb02fc17a3530699a635d2f98f6e libc-2.26.so           /usr/lib64/libc-2.26.so
0x00007f37dfbbc000–0x00007f37dfbd3f7c 0231966c233a89975bc72a53fd9d6bd2792392bd libpthread-2.26.so     /usr/lib64/libpthread-2.26.so

[Info  - 8:25:43 PM] Connection to server got closed. Server will restart.

hope this helps!

okay, i made a bit more progress narrowing this down, there seems to be a slightly different crash that only affect generic types.

roughly what i did was:

  1. i cut a nested type out of a generic type, without its required import statements
  2. i did Ctrl-N to make a new file, and pasted the nested type in the new file, and saved it with a new name, which causes the highlights in the original file to freeze, since the nested type is no longer valid due to missing imports.
  3. i closed the original file and reopened it, seeing no highlights at all.
  4. in the sourcekit-lsp output, i saw:
*** Program crashed: Illegal instruction at 0x0000562fcc0362c3 ***

Thread 0 "sourcekit-lsp":

0  0x00007f7a509befee __sigsuspend + 62 in libc-2.26.so

Thread 1:

0  0x00007f7a50a7a84c epoll_wait + 92 in libc-2.26.so

Thread 2:

0  0x00007f7a50a7a84c epoll_wait + 92 in libc-2.26.so

Thread 3:

0  0x00007f7a51b36377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so

Thread 4:

0  0x00007f7a50a7a84c epoll_wait + 92 in libc-2.26.so

Thread 5:

0  0x00007f7a51b36377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so

Thread 6:

0  0x00007f7a50a7a84c epoll_wait + 92 in libc-2.26.so

Thread 7:

0  0x00007f7a51b36377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so

Thread 8:

0  0x00007f7a50a7a84c epoll_wait + 92 in libc-2.26.so

Thread 9:

0  0x00007f7a51b36377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so

Thread 10:

0  0x00007f7a50a7a84c epoll_wait + 92 in libc-2.26.so

Thread 11:

0  0x00007f7a51b36377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so

Thread 12:

0  0x00007f7a51b38c10 do_futex_wait + 64 in libpthread-2.26.so

Thread 13:

0              0x00007f7a532caec6 swift::metadataimpl::ValueWitnesses<swift::metadataimpl::NativeBox<unsigned short, 2ul, 2ul, 2ul> >::initializeWithCopy(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*) + 6 in libswiftCore.so
1 [ra] [thunk] 0x00007f7a531b55ba protocol witness for _UnicodeParser.parseScalar<A>(from:) in conformance Unicode.UTF16.ForwardParser + 57 in libswiftCore.so
2 [ra]         0x00007f7a5307c9dc static String._fromCodeUnits<A, B>(_:encoding:repair:) + 1179 in libswiftCore.so

Thread 14:

0      0x00007f7a532e282e swift::MetadataCacheKey::operator==(swift::MetadataCacheKey const&) const + 62 in libswiftCore.so
1 [ra] 0x00007f7a53171582 static String._slowFromCodeUnits<A, B>(_:encoding:repair:) + 129 in libswiftCore.so
2 [ra] 0x00007f7a5307c9dc static String._fromCodeUnits<A, B>(_:encoding:repair:) + 1179 in libswiftCore.so

Thread 15:

0  0x00007f7a51b38c10 do_futex_wait + 64 in libpthread-2.26.so

Thread 16:

0  0x00007f7a51b38c10 do_futex_wait + 64 in libpthread-2.26.so

Thread 17:

0  0x00007f7a51b38c10 do_futex_wait + 64 in libpthread-2.26.so

Thread 18:

0  0x00007f7a51b38c10 do_futex_wait + 64 in libpthread-2.26.so

Thread 19 crashed:

0 [system] 0x0000562fcc0362c3 closure #1 in BuildSystemManager.unregisterForChangeNotifications(for:) + 259 in sourcekit-lsp at /home/build-user/sourcekit-lsp/<compiler-generated>

Thread 20:

0  0x00007f7a51b38c10 do_futex_wait + 64 in libpthread-2.26.so

Thread 21:

0  0x00007f7a51b38c10 do_futex_wait + 64 in libpthread-2.26.so


Registers:

rax 0x0000000800000003  34359738371
rdx 0x00007f7a2042cf30  68 e0 79 cd 2f 56 00 00 94 d1 0a 44 ef 0f 00 c0  hàyÍ/V···Ñ·Dï··À
rcx 0xfffffffe00000000  18446744065119617024
rbx 0x0000000600000003  25769803779
rsi 0x00007f7964620eb8  03 00 00 00 00 00 00 00 50 52 06 20 7a 7f 00 00  ········PR· z···
rdi 0x00007f7938004a10  00 00 02 07 01 02 03 02 00 00 00 00 00 00 00 00  ················
rbp 0x0000000000000000  0
rsp 0x00007f7a41ce3b50  50 cf 42 20 7a 7f 00 00 ea 61 03 cc 2f 56 00 00  PÏB z···êa·Ì/V··
 r8 0x0000000000000002  2
 r9 0x80000000ffffffff  9223372041149743103
r10 0x0000000100000000  4294967296
r11 0x0000000200000000  8589934592
r12 0x0000000000000000  0
r13 0x00007f79640045d0  20 42 31 20 7a 7f 00 00 03 00 00 00 00 00 00 00   B1 z···········
r14 0x80007f7964620eb0  9223512196206694064
r15 0x00007f7a2042cf50  d0 45 00 64 79 7f 00 00 50 7a 0b 34 7a 7f 00 00  ÐE·dy···Pz·4z···
rip 0x0000562fcc0362c3  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 (67 omitted):

0x0000562fcb4db000–0x0000562fcd48e8c0 <no build ID>                            sourcekit-lsp      /usr/bin/sourcekit-lsp
0x00007f7a5098b000–0x00007f7a50b2e47c 53637569236bdb02fc17a3530699a635d2f98f6e libc-2.26.so       /usr/lib64/libc-2.26.so
0x00007f7a51b29000–0x00007f7a51b40f7c 0231966c233a89975bc72a53fd9d6bd2792392bd libpthread-2.26.so /usr/lib64/libpthread-2.26.so
0x00007f7a52ecf000–0x00007f7a53412eb8 <no build ID>                            libswiftCore.so    /usr/lib/swift/linux/libswiftCore.so

[Info  - 8:47:08 PM] Connection to server got closed. Server will restart.
true

Huh, interesting. This is crashing in BuildSystemManager.unregisterForChangeNotifications(for:), probably the force unwrap here https://github.com/apple/sourcekit-lsp/blob/e21aaac23b0e229c2590e4c9892085643755d506/Sources/SKCore/BuildSystemManager.swift#L302. This also means that it probably isn’t related to the contents of the file but your opening/closing/renaming of files

While we definitely shouldn’t crash here, I expect this to happen because of mismatched open/close calls. I would like to check that as well. For that, can you share the entire sourcekit-lsp log from VS Code, not just the crash?

Here’s the PR that should fix the issue, I believe: Don’t crash when unregistering for change notifications of a file that isn’t watched by ahoppen · Pull Request #828 · apple/sourcekit-lsp · GitHub

1 Like

wow, that was fast! thanks Alex!

i tried enabling verbose logging as you demonstrated, and was able to observe a crash in the output panel when deleting a file, but when the server crashes, it erases all the output in the VSCode panel except for the text:

[Error - 12:35:16 AM] Stopping server failed
  Message: Cannot call write after a stream was destroyed
  Code: -32099 

this crash was different from some of the others i encountered in this thread in that the sourcekit-lsp server didn’t restart after it crashed.

here is a log i captured from an instance of the crash when the server did restart afterwards:

[Trace - 12:42:19 AM] Sending notification 'textDocument/didOpen'.
Params: {
    "textDocument": {
        "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient.swift",
        "languageId": "swift",
        "version": 11,
        "text": "import GitHubAPI\nimport HTTPClient\nimport JSON\nimport NIOCore\nimport NIOHPACK\n\n@frozen public\nstruct GitHubClient<Application>\n{\n    @usableFromInline internal\n    let http2:HTTP2Client\n    public\n    let app:Application\n\n    public\n    init(http2:HTTP2Client, app:Application)\n    {\n        self.http2 = http2\n        self.app = app\n    }\n}\nextension GitHubClient:Identifiable where Application:GitHubApplication\n{\n    @inlinable public\n    var id:String { self.app.client }\n\n    @inlinable public\n    var secret:String { self.app.secret }\n}\nextension GitHubClient where Application:GitHubApplication<GitHubApp.Credentials>\n{\n    public\n    func refresh(\n        token:String) async throws -> GitHubApp.Credentials\n    {\n        let request:HPACKHeaders =\n        [\n            \":method\": \"POST\",\n            \":scheme\": \"https\",\n            \":authority\": \"github.com\",\n            \":path\": \"\"\"\n                /login/oauth/access_token?\\\n                grant_type=refresh_token&\\\n                client_id=\\(self.id)&client_secret=\\(self.secret)&refresh_token=\\(token)\n                \"\"\",\n\n            \"accept\": \"application/vnd.github+json\",\n        ]\n\n        return try await self.authenticate(sending: request)\n    }\n}\nextension GitHubClient\n    where Application:GitHubApplication, Application.Credentials:JSONObjectDecodable\n{\n    public\n    func exchange(\n        code:String) async throws -> Application.Credentials\n    {\n        let request:HPACKHeaders =\n        [\n            \":method\": \"POST\",\n            \":scheme\": \"https\",\n            \":authority\": \"github.com\",\n            \":path\": \"\"\"\n                /login/oauth/access_token?\\\n                client_id=\\(self.id)&client_secret=\\(self.secret)&code=\\(code)\n                \"\"\",\n\n            \"accept\": \"application/vnd.github+json\",\n        ]\n\n        return try await self.authenticate(sending: request)\n    }\n\n    private\n    func authenticate(sending request:HPACKHeaders)\n        async throws -> Application.Credentials\n    {\n        let response:HTTP2Client.Facet = try await self.http2.fetch(request)\n\n        switch response.status\n        {\n        case 200?:\n            break\n        case let status:\n            throw AuthenticationError.status(.init(code: status))\n        }\n\n        var json:JSON = .init(utf8: [])\n        for buffer:ByteBuffer in response.buffers\n        {\n            json.utf8 += buffer.readableBytesView\n        }\n\n        do\n        {\n            return try json.decode()\n        }\n        catch let error\n        {\n            throw AuthenticationError.response(error)\n        }\n    }\n}\nextension GitHubClient\n{\n    @inlinable public\n    func connect<T>(with body:(Connection) async throws -> T) async throws -> T\n    {\n        try await self.http2.connect\n        {\n            try await body(Connection.init(http2: $0, app: self.app))\n        }\n    }\n}\nextension GitHubClient<GitHubOAuth.API>\n{\n    @inlinable public\n    func get<Response>(_:Response.Type = Response.self,\n        from endpoint:String,\n        with token:String? = nil) async throws -> Response where Response:JSONDecodable\n    {\n        try await self.connect { try await $0.get(from: endpoint, with: token) }\n    }\n}\n\nimport Base64\nimport GitHubAPI\nimport HTTPClient\nimport JSON\nimport NIOCore\nimport NIOHPACK\nimport UnixTime\n\n"
    }
}


[Trace - 12:42:19 AM] Sending request 'textDocument/documentColor - (121)'.
Params: {
    "textDocument": {
        "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient.swift"
    }
}


[Trace - 12:42:19 AM] Sending request 'textDocument/documentSymbol - (122)'.
Params: {
    "textDocument": {
        "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient.swift"
    }
}


[Trace - 12:42:19 AM] Sending request 'textDocument/semanticTokens/full - (123)'.
Params: {
    "textDocument": {
        "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient.swift"
    }
}


[Trace - 12:42:19 AM] Sending request 'textDocument/codeAction - (124)'.
Params: {
    "textDocument": {
        "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient.swift"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 0,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [],
        "triggerKind": 2
    }
}


[Trace - 12:42:19 AM] Sending request 'textDocument/semanticTokens/range - (125)'.
Params: {
    "textDocument": {
        "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient.swift"
    },
    "range": {
        "start": {
            "line": 91,
            "character": 0
        },
        "end": {
            "line": 135,
            "character": 0
        }
    }
}


[Trace - 12:42:19 AM] Sending notification '$/cancelRequest'.
Params: {
    "id": 122
}


[Trace - 12:42:19 AM] Sending request 'textDocument/documentSymbol - (126)'.
Params: {
    "textDocument": {
        "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient.swift"
    }
}


[Trace - 12:42:19 AM] Sending notification '$/cancelRequest'.
Params: {
    "id": 124
}


[Trace - 12:42:19 AM] Sending request 'textDocument/foldingRange - (127)'.
Params: {
    "textDocument": {
        "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient.swift"
    }
}


[Trace - 12:42:23 AM] Sending notification '$/cancelRequest'.
Params: {
    "id": 127
}


[Trace - 12:42:23 AM] Sending notification '$/cancelRequest'.
Params: {
    "id": 125
}


[Trace - 12:42:23 AM] Sending notification '$/cancelRequest'.
Params: {
    "id": 121
}


[Trace - 12:42:23 AM] Sending notification '$/cancelRequest'.
Params: {
    "id": 126
}


[Trace - 12:42:23 AM] Sending request 'textDocument/documentColor - (128)'.
Params: {
    "textDocument": {
        "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient%3CGitHubOAuth.API%3E.Connection.swift"
    }
}


[Trace - 12:42:23 AM] Sending request 'textDocument/documentSymbol - (129)'.
Params: {
    "textDocument": {
        "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient%3CGitHubOAuth.API%3E.Connection.swift"
    }
}


[Trace - 12:42:23 AM] Sending request 'textDocument/codeAction - (130)'.
Params: {
    "textDocument": {
        "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient%3CGitHubOAuth.API%3E.Connection.swift"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 0,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [],
        "triggerKind": 2
    }
}


[Trace - 12:42:23 AM] Sending request 'textDocument/semanticTokens/range - (131)'.
Params: {
    "textDocument": {
        "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient%3CGitHubOAuth.API%3E.Connection.swift"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 57,
            "character": 34
        }
    }
}


[Trace - 12:42:23 AM] Sending notification '$/cancelRequest'.
Params: {
    "id": 130
}


[Trace - 12:42:23 AM] Sending request 'textDocument/codeAction - (132)'.
Params: {
    "textDocument": {
        "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient%3CGitHubOAuth.API%3E.Connection.swift"
    },
    "range": {
        "start": {
            "line": 21,
            "character": 55
        },
        "end": {
            "line": 21,
            "character": 55
        }
    },
    "context": {
        "diagnostics": [],
        "triggerKind": 2
    }
}


[Trace - 12:42:23 AM] Sending request 'textDocument/foldingRange - (133)'.
Params: {
    "textDocument": {
        "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient%3CGitHubOAuth.API%3E.Connection.swift"
    }
}



*** Program crashed: Illegal instruction at 0x000055911eeea2c3 ***

Thread 0 "sourcekit-lsp":

0  0x00007fcbac401fee __sigsuspend + 62 in libc-2.26.so

Thread 1:

0  0x00007fcbac4bd84c epoll_wait + 92 in libc-2.26.so

Thread 2:

0  0x00007fcbac4bd84c epoll_wait + 92 in libc-2.26.so

Thread 3:

0  0x00007fcbad579377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so

Thread 4:

0  0x00007fcbac4bd84c epoll_wait + 92 in libc-2.26.so

Thread 5:

0  0x00007fcbad579377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so

Thread 6:

0  0x00007fcbac4bd84c epoll_wait + 92 in libc-2.26.so

Thread 7:

0  0x00007fcbad579377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so

Thread 8:

0  0x00007fcbac4bd84c epoll_wait + 92 in libc-2.26.so

Thread 9:

0  0x00007fcbad579377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so

Thread 10:

0  0x00007fcbac4bd84c epoll_wait + 92 in libc-2.26.so

Thread 11:

0  0x00007fcbad579377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so

Thread 12:

0  0x00007fcbac4bd84c epoll_wait + 92 in libc-2.26.so

Thread 13:

0  0x00007fcbad579377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so

Thread 14:

0  0x00007fcab3ecd079 llvm::StringMapImpl::LookupBucketFor(llvm::StringRef) + 9 in libsourcekitdInProc.so

Thread 15:

0  0x00007fcbad57bc10 do_futex_wait + 64 in libpthread-2.26.so

Thread 16:

0 [thunk]      0x00007fcbaeaa336a protocol witness for IteratorProtocol.next() in conformance IndexingIterator<A> + 410 in libswiftCore.so
1 [ra] [thunk] 0x00007fcbaebf85ba protocol witness for _UnicodeParser.parseScalar<A>(from:) in conformance Unicode.UTF16.ForwardParser + 57 in libswiftCore.so
2 [ra]         0x00007fcbaeabf9dc static String._fromCodeUnits<A, B>(_:encoding:repair:) + 1179 in libswiftCore.so

Thread 17:

0  0x00007fcbad57bc10 do_futex_wait + 64 in libpthread-2.26.so

Thread 18 crashed:

0 [system] 0x000055911eeea2c3 closure #1 in BuildSystemManager.unregisterForChangeNotifications(for:) + 259 in sourcekit-lsp at /home/build-user/sourcekit-lsp/<compiler-generated>

Thread 19:

0  0x00007fcbad57bc10 do_futex_wait + 64 in libpthread-2.26.so


Registers:

rax 0x0000000800000003  34359738371
rdx 0x00007fcb8c1a6640  68 20 65 20 91 55 00 00 b0 29 84 71 f9 0f 00 c0  h e ·U··°)·qù··À
rcx 0xfffffffe00000000  18446744065119617024
rbx 0x0000000600000003  25769803779
rsi 0x00007fcae8a903a8  03 00 00 00 00 00 00 00 20 20 00 e8 ca 7f 00 00  ········  ·èÊ···
rdi 0x00007fcaec006370  00 03 07 01 01 03 04 01 02 01 00 00 00 00 00 00  ················
rbp 0x0000000000000000  0
rsp 0x00007fcb9f7fdb50  60 66 1a 8c cb 7f 00 00 ea a1 ee 1e 91 55 00 00  `f··Ë···ê¡î··U··
 r8 0x0000000000000000  0
 r9 0x80000000ffffffff  9223372041149743103
r10 0x0000000100000000  4294967296
r11 0x0000000200000000  8589934592
r12 0x0000000000000000  0
r13 0x00007fcb8411f320  20 7c 1f 8c cb 7f 00 00 03 00 00 00 00 00 00 00   |··Ë···········
r14 0x80007fcae8a903a0  9223512546318287776
r15 0x00007fcb8c1a6660  20 f3 11 84 cb 7f 00 00 30 80 11 84 cb 7f 00 00   ó··Ë···0···Ë···
rip 0x000055911eeea2c3  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):

0x000055911e38f000–0x00005591203428c0 <no build ID>                            sourcekit-lsp          /usr/bin/sourcekit-lsp
0x00007fcab340e000–0x00007fcaba130a70 <no build ID>                            libsourcekitdInProc.so /usr/lib/libsourcekitdInProc.so
0x00007fcbac3ce000–0x00007fcbac57147c 53637569236bdb02fc17a3530699a635d2f98f6e libc-2.26.so           /usr/lib64/libc-2.26.so
0x00007fcbad56c000–0x00007fcbad583f7c 0231966c233a89975bc72a53fd9d6bd2792392bd libpthread-2.26.so     /usr/lib64/libpthread-2.26.so
0x00007fcbae912000–0x00007fcbaee55eb8 <no build ID>                            libswiftCore.so        /usr/lib/swift/linux/libswiftCore.so

[Info  - 12:42:37 AM] Connection to server got closed. Server will restart.

here is a crash with a different trace:

[Trace - 12:53:03 AM] Sending request 'textDocument/diagnostic - (86)'.
Params: {
    "textDocument": {
        "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient.swift"
    }
}


sourcekit: [1:getBufferStamp: 0.0000] failed to stat file: /swift/swift-unidoc/Sources/GitHubClient/GitHubClient<GitHubOAuth.API>.Connection.swift (No such file or directory)
sourcekit: [1:getBufferStamp: 0.0002] failed to stat file: /swift/swift-unidoc/Sources/GitHubClient/GitHubClient<GitHubOAuth.API>.Connection.swift (No such file or directory)
sourcekit: [1:fileContentsForFilesInCompilerInvocation: 0.0002] failed getting file contents for /swift/swift-unidoc/Sources/GitHubClient/GitHubClient<GitHubOAuth.API>.Connection.swift: error opening input file '/swift/swift-unidoc/Sources/GitHubClient/GitHubClient<GitHubOAuth.API>.Connection.swift' (No such file or directory)
[Trace - 12:53:04 AM] Sending request 'textDocument/foldingRange - (87)'.
Params: {
    "textDocument": {
        "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient.Connection.swift"
    }
}


[Trace - 12:53:04 AM] Sending request 'textDocument/codeAction - (88)'.
Params: {
    "textDocument": {
        "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient.Connection.swift"
    },
    "range": {
        "start": {
            "line": 8,
            "character": 0
        },
        "end": {
            "line": 8,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [],
        "triggerKind": 2
    }
}


/swift/swift-unidoc/Sources/GitHubClient/GitHubClient.Connection.swift:1:8: error: no such module 'Base64'
import Base64
       ^
[Trace - 12:53:04 AM] Received response 'textDocument/diagnostic - (86)' in 142ms.
Result: {
    "items": [
        {
            "range": {
                "end": {
                    "line": 108,
                    "character": 41
                },
                "start": {
                    "line": 108,
                    "character": 31
                }
            },
            "source": "sourcekitd",
            "message": "cannot find type 'Connection' in scope",
            "tags": [],
            "severity": 1
        },
        {
            "range": {
                "start": {
                    "line": 112,
                    "character": 27
                },
                "end": {
                    "line": 112,
                    "character": 37
                }
            },
            "source": "sourcekitd",
            "message": "cannot find 'Connection' in scope",
            "tags": [],
            "severity": 1
        }
    ],
    "kind": "full"
}


[Trace - 12:53:04 AM] Sending notification 'workspace/didChangeWatchedFiles'.
Params: {
    "changes": [
        {
            "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient.Connection.swift",
            "type": 1
        },
        {
            "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient%3CGitHubOAuth.API%3E.Connection.swift",
            "type": 3
        }
    ]
}


[Trace - 12:53:04 AM] Received response 'textDocument/foldingRange - (87)' in 30ms.
Result: [
    {
        "endLine": 25,
        "startLine": 9
    },
    {
        "endLine": 24,
        "startLine": 12
    },
    {
        "endLine": 23,
        "startLine": 20
    },
    {
        "endLine": 101,
        "startLine": 27
    },
    {
        "endLine": 100,
        "startLine": 32
    },
    {
        "endLine": 97,
        "startLine": 38
    },
    {
        "endLine": 47,
        "kind": "comment",
        "startLine": 46
    },
    {
        "endLine": 53,
        "startLine": 51
    },
    {
        "endLine": 60,
        "startLine": 56
    },
    {
        "endLine": 59,
        "startLine": 58
    },
    {
        "endLine": 65,
        "startLine": 64,
        "kind": "comment"
    },
    {
        "endLine": 93,
        "startLine": 66
    },
    {
        "endLine": 72,
        "startLine": 70
    },
    {
        "endLine": 81,
        "startLine": 78
    },
    {
        "endLine": 89,
        "startLine": 86
    },
    {
        "endLine": 88,
        "startLine": 87
    }
]


[Trace - 12:53:04 AM] Received response 'textDocument/codeAction - (88)' in 30ms.
Result: []


2023-09-21 00:53:04.401 sourcekit-lsp[22653:5ffff700] [warning]: dependency 'swift-hash' is not used by any target
[Trace - 12:53:04 AM] Received notification 'textDocument/publishDiagnostics'.
Params: {
    "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient.swift",
    "version": 17,
    "diagnostics": []
}


[Trace - 12:53:04 AM] Received request 'workspace/semanticTokens/refresh - (18)'.
Params: {}


[Trace - 12:53:04 AM] Sending response 'workspace/semanticTokens/refresh - (18)'. Processing request took 0ms
No result returned.


[Trace - 12:53:04 AM] Sending request 'textDocument/semanticTokens/full - (89)'.
Params: {
    "textDocument": {
        "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient.Connection.swift"
    }
}


[Trace - 12:53:04 AM] Received response 'textDocument/semanticTokens/full - (89)' in 1ms.
No result returned.


[Trace - 12:53:28 AM] Sending notification 'textDocument/didClose'.
Params: {
    "textDocument": {
        "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient.Connection.swift"
    }
}


[Trace - 12:53:28 AM] Sending request 'textDocument/documentColor - (90)'.
Params: {
    "textDocument": {
        "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient.swift"
    }
}


[Trace - 12:53:28 AM] Sending request 'textDocument/codeAction - (91)'.
Params: {
    "textDocument": {
        "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient.swift"
    },
    "range": {
        "start": {
            "line": 0,
            "character": 0
        },
        "end": {
            "line": 0,
            "character": 0
        }
    },
    "context": {
        "diagnostics": [],
        "triggerKind": 2
    }
}


PLEASE submit a bug report to https://github.com/llvm/llvm-project/issues/ and include the crash backtrace.
[Trace - 12:53:28 AM] Sending notification '$/cancelRequest'.
Params: {
    "id": 91
}


[Trace - 12:53:28 AM] Sending request 'textDocument/foldingRange - (92)'.
Params: {
    "textDocument": {
        "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient.swift"
    }
}


[Trace - 12:53:28 AM] Sending request 'textDocument/semanticTokens/full - (93)'.
Params: {
    "textDocument": {
        "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient.swift"
    }
}


[Trace - 12:53:29 AM] Sending request 'textDocument/hover - (94)'.
Params: {
    "textDocument": {
        "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient.swift"
    },
    "position": {
        "line": 120,
        "character": 23
    }
}


[Trace - 12:53:29 AM] Sending notification '$/cancelRequest'.
Params: {
    "id": 94
}


[Trace - 12:53:29 AM] Sending request 'textDocument/hover - (95)'.
Params: {
    "textDocument": {
        "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient.swift"
    },
    "position": {
        "line": 120,
        "character": 22
    }
}


[Trace - 12:53:29 AM] Sending notification '$/cancelRequest'.
Params: {
    "id": 95
}


[Trace - 12:53:29 AM] Sending request 'textDocument/hover - (96)'.
Params: {
    "textDocument": {
        "uri": "file:///swift/swift-unidoc/Sources/GitHubClient/GitHubClient.swift"
    },
    "position": {
        "line": 120,
        "character": 22
    }
}


[Trace - 12:53:30 AM] Sending notification '$/cancelRequest'.
Params: {
    "id": 96
}



*** Program crashed: Illegal instruction at 0x0000561f802172c3 ***

Thread 0 "sourcekit-lsp":

0  0x00007f174bc54fee __sigsuspend + 62 in libc-2.26.so

Thread 1:

0  0x00007f174bd1084c epoll_wait + 92 in libc-2.26.so

Thread 2:

0  0x00007f174bd1084c epoll_wait + 92 in libc-2.26.so

Thread 3:

0  0x00007f174cdcc377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so

Thread 4:

0  0x00007f174bd1084c epoll_wait + 92 in libc-2.26.so

Thread 5:

0  0x00007f174cdcc377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so

Thread 6:

0  0x00007f174bd1084c epoll_wait + 92 in libc-2.26.so

Thread 7:

0  0x00007f174cdcc377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so

Thread 8:

0  0x00007f174bd1084c epoll_wait + 92 in libc-2.26.so

Thread 9:

0  0x00007f174cdcc377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so

Thread 10:

0  0x00007f174bd1084c epoll_wait + 92 in libc-2.26.so

Thread 11:

0  0x00007f174cdcc377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so

Thread 12:

0  0x00007f174bd1084c epoll_wait + 92 in libc-2.26.so

Thread 13:

0  0x00007f174cdcc377 pthread_cond_wait@@GLIBC_2.3.2 + 503 in libpthread-2.26.so

Thread 14:

0  0x00007f174cdcec10 do_futex_wait + 64 in libpthread-2.26.so

Thread 15:

0  0x00007f174bc9e4e3 _int_malloc + 3379 in libc-2.26.so

Thread 16:

0              0x00007f174e560ec0 swift::metadataimpl::ValueWitnesses<swift::metadataimpl::NativeBox<unsigned short, 2ul, 2ul, 2ul> >::initializeWithCopy(swift::OpaqueValue*, swift::OpaqueValue*, swift::TargetMetadata<swift::InProcess> const*) in libswiftCore.so
1 [ra] [thunk] 0x00007f174e44b5ba protocol witness for _UnicodeParser.parseScalar<A>(from:) in conformance Unicode.UTF16.ForwardParser + 57 in libswiftCore.so
2 [ra]         0x00007f174e3129dc static String._fromCodeUnits<A, B>(_:encoding:repair:) + 1179 in libswiftCore.so

Thread 17:

0  0x00007f174cdcec10 do_futex_wait + 64 in libpthread-2.26.so

Thread 18 crashed:

0 [system] 0x0000561f802172c3 closure #1 in BuildSystemManager.unregisterForChangeNotifications(for:) + 259 in sourcekit-lsp at /home/build-user/sourcekit-lsp/<compiler-generated>


Registers:

rax 0x0000000800000003  34359738371
rdx 0x00007f17242e60a0  68 f0 97 81 1f 56 00 00 26 fc 8a e4 e2 0f 00 c0  hð···V··&ü·äâ··À
rcx 0xfffffffe00000000  18446744065119617024
rbx 0x0000000600000003  25769803779
rsi 0x00007f16cc002ad8  03 00 00 00 00 00 00 00 00 80 00 cc 16 7f 00 00  ···········Ì····
rdi 0x1e1522e234296a9a  2167677150581844634
rbp 0x0000000000000000  0
rsp 0x00007f173f7feb50  c0 60 2e 24 17 7f 00 00 ea 71 21 80 1f 56 00 00  À`.$····êq!··V··
 r8 0xfbcbb2649bfc06ff  18143791668975634175
 r9 0x80000000ffffffff  9223372041149743103
r10 0x0000000100000000  4294967296
r11 0x0000000200000000  8589934592
r12 0x0000000000000000  0
r13 0x00007f1738003f40  38 47 6d 24 17 7f 00 00 03 00 00 00 00 00 00 00  8Gm$············
r14 0x80007f16cc002ad0  9223511772743346896
r15 0x00007f17242e60c0  40 3f 00 38 17 7f 00 00 90 40 00 38 17 7f 00 00  @?·8·····@·8····
rip 0x0000561f802172c3  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 (67 omitted):

0x0000561f7f6bc000–0x0000561f8166f8c0 <no build ID>                            sourcekit-lsp      /usr/bin/sourcekit-lsp
0x00007f174bc21000–0x00007f174bdc447c 53637569236bdb02fc17a3530699a635d2f98f6e libc-2.26.so       /usr/lib64/libc-2.26.so
0x00007f174cdbf000–0x00007f174cdd6f7c 0231966c233a89975bc72a53fd9d6bd2792392bd libpthread-2.26.so /usr/lib64/libpthread-2.26.so
0x00007f174e165000–0x00007f174e6a8eb8 <no build ID>                            libswiftCore.so    /usr/lib/swift/linux/libswiftCore.so

[Info  - 12:54:08 AM] Connection to server got closed. Server will restart.

I really wish, we had a full stack trace of what’s causing the crash. It looks like VS Code is just sending an open, so something must be de-registering the file internally. Could you try setting SOURCEKIT_LOGGING to 3 in the sourcekit-lsp environment variables and then attach the log output again? I hope that that might give me a clue about what’s going wrong.

"swift.swiftEnvironmentVariables": {
  "SOURCEKIT_LOGGING": "3"
}

okay, i have finally got at least one of the crashes isolated down to a minimal reproducer. details in this GitHub issue: