Skip to content

libsourcekitdInProc.so crashes on OStream_write #67975

Open
@kabiroberai

Description

@kabiroberai

Description

In some configurations, SourceKit on Linux fails to cache modules (while emitting SIL?), crashing with the following error:

/usr/local/swift/bin/sourcekit-lsp: symbol lookup error: /usr/local/swift/lib/libsourcekitdInProc.so:
undefined symbol: _Z13OStream_write14BridgedOStreamN4llvm9StringRefE

The function in question is defined here
https://github.com/apple/swift/blob/b914fc05d881a1d672684b50e98334d5fb203713/lib/Basic/BasicBridging.cpp#L22-L25

And used here
https://github.com/apple/swift/blob/b914fc05d881a1d672684b50e98334d5fb203713/SwiftCompilerSources/Sources/SIL/Function.swift#L266-L286

I was able to confirm that pre-building a module cache with swiftc stops the crash from occurring. Running nm on libsourcekitdInProc.so, it seems like the symbol is unresolved:

/usr/local/swift/lib$ nm libsourcekitdInProc.so | grep OStream_write
                 U _Z13OStream_write14BridgedOStreamN4llvm9StringRefE

Interestingly, other libraries (and swiftc) static-link the symbol from libBasic just fine so I'm not sure what's special about sourcekitdInProc.

Steps to reproduce

  1. Use sourcekit-lsp with a non-prebuilt module in the search path (such as by passing -Xswiftc -I/path/to/module)
  2. When the editor opens the file and loads type info, observe that sourcekit-lsp crashes.

Expected behavior

libsourcekitdInProc.so should not cause a crash.

Environment

  • Swift compiler version info: Swift version 5.9-dev (LLVM bf1b8ef1742ad70, Swift 627525c)
  • Linux version: Ubuntu Jammy 22.04.3 LTS

Note that I was able to repro this as far back as Swift 5.7.3 (didn't test anything earlier than that).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions