jpsim / SourceKitten

An adorable little framework and command line tool for interacting with SourceKit.
MIT License
2.31k stars 226 forks source link

Linux: SourceKittenFramework/library_wrapper.swift:31: Fatal error: Loading libsourcekitdInProc.so failed #792

Closed kaankoken closed 1 year ago

kaankoken commented 1 year ago

I am using Swiftlint package on linux machine for CI (gh action) with pre-commit. It seems that cannot loading the the wrapper.

Issue on Swiftlint

Error: Program crashed: Illegal instruction at 0x00007fb3db563470

Error with stacktrace ```bash Run pre-commit/action@v3.0.0 with: extra_args: --all-files Run python -m pip install pre-commit python -m pip install pre-commit shell: /usr/bin/bash --noprofile --norc -e -o pipefail {0} Defaulting to user installation because normal site-packages is not writeable Collecting pre-commit Downloading pre_commit-3.4.0-py2.py3-none-any.whl (203 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 203.7/203.7 KB 4.2 MB/s eta 0:00:00 Collecting virtualenv>=20.10.0 Downloading virtualenv-20.24.5-py3-none-any.whl (3.7 MB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 3.7/3.7 MB 16.5 MB/s eta 0:00:00 Requirement already satisfied: pyyaml>=5.1 in /usr/lib/python3/dist-packages (from pre-commit) (5.4.1) Collecting cfgv>=2.0.0 Downloading cfgv-3.4.0-py2.py3-none-any.whl (7.2 kB) Collecting nodeenv>=0.11.1 Downloading nodeenv-1.8.0-py2.py3-none-any.whl (22 kB) Collecting identify>=1.0.0 Downloading identify-2.5.30-py2.py3-none-any.whl (98 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 98.9/98.9 KB 20.2 MB/s eta 0:00:00 Requirement already satisfied: setuptools in /usr/lib/python3/dist-packages (from nodeenv>=0.11.1->pre-commit) (59.6.0) Collecting platformdirs<4,>=3.9.1 Downloading platformdirs-3.11.0-py3-none-any.whl (17 kB) Collecting filelock<4,>=3.12.2 Downloading filelock-3.12.4-py3-none-any.whl (11 kB) Collecting distlib<1,>=0.3.7 Downloading distlib-0.3.7-py2.py3-none-any.whl (468 kB) ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ 468.9/468.9 KB 25.6 MB/s eta 0:00:00 Installing collected packages: distlib, platformdirs, nodeenv, identify, filelock, cfgv, virtualenv, pre-commit Successfully installed cfgv-3.4.0 distlib-0.3.7 filelock-3.12.4 identify-2.5.30 nodeenv-1.8.0 platformdirs-3.11.0 pre-commit-3.4.0 virtualenv-20.24.5 Run python -m pip freeze --local argcomplete==3.1.2 cfgv==3.4.0 distlib==0.3.7 filelock==3.12.4 identify==2.5.30 nodeenv==1.8.0 packaging==23.2 pipx==1.2.0 platformdirs==3.11.0 pre-commit==3.4.0 userpath==1.9.1 virtualenv==20.24.5 Run actions/cache@v3 Cache not found for input keys: pre-commit-3||389ef66d5ad40af641fc010afd314be94b37f855caca837849b251e37c968a28 Run pre-commit run --show-diff-on-failure --color=always --all-files [INFO] Initializing environment for https://github.com/pre-commit/pre-commit-hooks. [INFO] Initializing environment for https://github.com/nicklockwood/SwiftFormat. [INFO] Initializing environment for https://github.com/realm/SwiftLint. [INFO] Installing environment for https://github.com/pre-commit/pre-commit-hooks. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes... [INFO] Installing environment for https://github.com/nicklockwood/SwiftFormat. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes... [INFO] Installing environment for https://github.com/realm/SwiftLint. [INFO] Once installed this environment will be reused. [INFO] This may take a few minutes... check yaml...............................................................Passed fix end of files.........................................................Passed trim trailing whitespace.................................................Passed detect private key.......................................................Passed check for merge conflicts................................................Passed check toml...............................................................Passed SwiftFormat..............................................................Passed SwiftLint................................................................Failed - hook id: swiftlint - exit code: -4 SourceKittenFramework/library_wrapper.swift:31: Fatal error: Loading libsourcekitdInProc.so failed 💣 Program crashed: Illegal instruction at 0x00007fb3db563470 Thread 0 "swiftlint": 0 0x00007fb3da44280a in libc.so.6 Thread 1 crashed: 0 0x00007fb3db563470 _assertionFailure(_:_:file:line:flags:) + 384 in libswiftCore.so Thread 2: 0 0x00007fb3da525fde in libc.so.6 Thread 3: 0 0x00007fb3da491197 in libc.so.6 Thread 4: 0 0x00007fb3da518e7e in libc.so.6 Thread 5: 0 0x00007fb3da51b7ed in libc.so.6 Thread 6: 0 0x00007fb3da491197 in libc.so.6 Registers: rax 0x0000000200000003 8589934595 rdx 0x00007fb3d010fe20 58 0d 96 db b3 7f 00 00 03 00 00 00 00 00 00 00 X··Û³··········· rcx 0xfffffffe00000000 18446744065119617024 rbx 0x0000000000000003 3 rsi 0x00007fb3d010fe28 03 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00 ········@······· rdi 0x00007fb3d00008e0 06 00 07 00 06 00 05 00 06 00 06 00 06 00 01 00 ················ rbp 0x0000000000000025 37 rsp 0x00007fb3d52c30a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ················ r8 0x00007fb3d008e730 ce be 2e 2b b4 7f 00 00 7a 9c 0b 7e 1d de fd c4 ξ.+´···z··~·ÞýÄ r9 0x00007fb3d52c2df0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ················ r10 0x0000000000000000 0 r11 0xc4fdde1d7e0b9c7a 14194745818791779450 r12 0x0000000000000000 0 r13 0x0000000000000002 2 r14 0x00005601477b5579 46 61 74 61 6c 20 65 72 72 6f 72 00 6f 66 66 73 Fatal error·offs r15 0x000000000000000b 11 rip 0x00007fb3db563470 0f 0b 48 83 ec 08 48 8d 05 b3 60 41 00 48 8d 3d ··H·ì·H··³`A·H·= rflags 0x0000000000010246 ZF PF cs 0x0033 fs 0x0000 gs 0x0000 Images (52 omitted): 0x00007fb3da400000–0x00007fb3da5bc501 229b7dc509053fe4df5e29e8629911f0c3bc66dd libc.so.6 /usr/lib/x86_64-linux-gnu/libc.so.6 0x00007fb3db400000–0x00007fb3db93dd68 libswiftCore.so /usr/share/swift/usr/lib/swift/linux/libswiftCore.so SourceKittenFramework/library_wrapper.swift:31: Fatal error: Loading libsourcekitdInProc.so failed 💣 Program crashed: Illegal instruction at 0x00007fd9d2963470 Thread 0 "swiftlint": 0 0x00007fd9d164280a in libc.so.6 Thread 1 crashed: 0 0x00007fd9d2963470 _assertionFailure(_:_:file:line:flags:) + 384 in libswiftCore.so Thread 2: 0 0x00007fd9d1725fde in libc.so.6 Thread 3: 0 0x00007fd9d1691197 in libc.so.6 Thread 4: 0 0x00007fd9d1718e7e in libc.so.6 Thread 5: 0 0x00007fd9d171b7ed in libc.so.6 Thread 6: 0 0x00007fd9d1691197 in libc.so.6 Registers: rax 0x0000000200000003 8589934595 rdx 0x00007fd9c4138680 58 0d d6 d2 d9 7f 00 00 03 00 00 00 00 00 00 00 X·ÖÒÙ··········· rcx 0xfffffffe00000000 18446744065119617024 rbx 0x0000000000000003 3 rsi 0x00007fd9c4138688 03 00 00 00 00 00 00 00 40 00 00 00 00 00 00 00 ········@······· rdi 0x00007fd9c40008e0 06 00 07 00 06 00 05 00 06 00 06 00 06 00 01 00 ················ rbp 0x0000000000000025 37 rsp 0x00007fd9cc4c30a0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ················ r8 0x00007fd9c408e750 6e be 8e 39 de 7f 00 00 9f 37 b9 a4 16 f5 4c 28 n¾·9Þ····7¹¤·õL( r9 0x00007fd9cc4c2df0 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 ················ r10 0x0000000000000000 0 r11 0x284cf516a4b9379f 2903965337348814751 r12 0x0000000000000000 0 r13 0x0000000000000002 2 r14 0x0000562c8db00579 46 61 74 61 6c 20 65 72 72 6f 72 00 6f 66 66 73 Fatal error·offs r15 0x000000000000000b 11 rip 0x00007fd9d2963470 0f 0b 48 83 ec 08 48 8d 05 b3 60 41 00 48 8d 3d ··H·ì·H··³`A·H·= rflags 0x0000000000010246 ZF PF cs 0x0033 fs 0x0000 gs 0x0000 Images (52 omitted): 0x00007fd9d1600000–0x00007fd9d17bc501 229b7dc509053fe4df5e29e8629911f0c3bc66dd libc.so.6 /usr/lib/x86_64-linux-gnu/libc.so.6 0x00007fd9d2800000–0x00007fd9d2d3dd68 libswiftCore.so /usr/share/swift/usr/lib/swift/linux/libswiftCore.so ```
jpsim commented 1 year ago

You'll need to have all the shared libraries available where SwiftLint expects them to be. You can inspect the Docker image or the script we use to build it to find out exactly what those are: https://github.com/realm/SwiftLint/blob/main/Dockerfile

The Linux binary isn't designed to be portable because of this dependency on shared libraries. So your options are:

  1. Use the Docker image
  2. Copy the share library layout we use to build the Linux binary very carefully for your own environment
  3. Build from source on your specific Linux environment