Open swift-ci opened 5 years ago
I can reproduce this from 18.10 running in docker.
This reproduces on 18.04 as well. Maybe the libIndexStore
from the 5.0 toolchain isn't working on Linux.
This reproduces in master branch development snapshots as well. I tested some historical snapshots and found:
OKAY: swift-DEVELOPMENT-SNAPSHOT-2019-03-17-a
CRASH: swift-DEVELOPMENT-SNAPSHOT-2019-03-25-a
The crash is not coming from the compiled code, but from the runtime libraries. If I run sourcekit-lsp built with 03-17-a using the runtime libraries from 03-25-a is also crashes, and if I run code built with 03-25-a using the 03-17-a libraries it does not crash.
I believe this was triggered by a change to libdispatch, based on the stack trace and the fact there were some huge changes to dispatch in this time period. Note these are on both master and 5.0 branches.
7e7677b Merge pull request #​466 from apple/kwt-ubuntu1804-clang-workaround
6c5b3ba Merge pull request #​465 from triplef/fix-gettid-android
319bd33 Merge pull request #​452 from drodriguez/fix-regex-windows
6e1825a Merge pull request #​458 from triplef/fix-missing-queue-defs
cbd70d1 Merge pull request #​461 from tachoknight/master
592749b Merge branch 'master' of https://github.com/apple/swift-corelibs-libdispatch
9d485ca Merge pull request #​459 from triplef/fix-sched-yield-android
ef9364c Merge pull request #​463 from triplef/fix-printf-dsma-value
f20349f Merge pull request #​457 from triplef/fix-signatures
7a74af4 Merge pull request #​460 from triplef/fix-cmake-private-install
60fdf80 Merge pull request #​448 from triplef/fix-printf-ptr
4659503 Merge pull request #​453 from compnerd/windows-improvements
d44acc0 Merge pull request #​447 from apple/kwt-test-darwin-libdispatch-1121-merge-master
We already had a compile-time crash in clang related to #447 (worked around in #466).
This seems to be triggered by the QoS we're trying to set. On Linux we don't have `qos.h`, so we use the old DISPATCH_QUEUE_PRIORITY_LOW, which is documented as being equivalent to UTILITY.
Here's a reproducer (I have the toolchain installed in \~/swift, so you may need to fix the paths). This reproduces with any recent master development toolchain. It fails while copying the 3rd block.
$ cat test.cpp
#include <dispatch/dispatch.h>
#include <Block.h>
#include <stdio.h>
int main() {
auto q = dispatch_queue_create("myqueue", 0);
dispatch_async(q, ^{
puts("myBlock1\n");
});
dispatch_async(q, dispatch_block_create(DISPATCH_BLOCK_INHERIT_QOS_CLASS, ^{
puts("myBlock2\n");
}));
dispatch_async(q, dispatch_block_create_with_qos_class(DISPATCH_BLOCK_INHERIT_QOS_CLASS, DISPATCH_QUEUE_PRIORITY_LOW, 0, ^{
puts("myBlock3\n");
}));
dispatch_main();
}
$ ~/swift/usr/bin/clang test.cpp -I ~/swift/usr/lib/swift/ -I ~/swift/usr/lib/swift/Block/ -fblocks -ldispatch -lBlocksRuntime -L ~/swift/usr/lib/ -o test
$ LD_LIBRARY_PATH=$HOME/swift/usr/lib ./test
myBlock1
myBlock2
Illegal instruction
I put a workaround into indexstore-db (https://github.com/apple/indexstore-db/pull/27), so if anyone is hitting this in sourcekit-lsp, please update to the latest master (or swift-5.1-branch) and try again (make sure to `swift package update` to get the latest indexstore-db version).
Attachment: Download
Environment
OS: Ubuntu 18.04 and 18.10 64-bit toolchain: swift-5.0-RELEASE-ubuntu18.04Additional Detail from JIRA
| | | |------------------|-----------------| |Votes | 0 | |Component/s | libdispatch, SourceKit-LSP | |Labels | Bug | |Assignee | ktopley-apple (JIRA) | |Priority | Medium | md5: 973ab2af9bcd0cc9584a10897d3e9f9eIssue Description:
When I open a package directory in Visual Studio Code, the language server crashes immediately. If package was never built, or I delete the .build directory, the language server works perfectly.
Steps to reproduce:
More info about how I got here is in this thread: https://forums.swift.org/t/using-sourcekit-lsp-on-ubuntu-18-10/22598
lldb output: