Skip to content

Commit

Permalink
ci: Add thread sanitizer to CI (eclipse-che4z#78)
Browse files Browse the repository at this point in the history
* change the order of allocation/destruction in workspace_manager_impl

The debugging thread may access debug_event _consumers_, so it should be destroyed first

* avoid data races when calling request_manager::is_running

* test fix: debugger should be disconnected before destruction

* add thread sanitizer to CI and VS configurations
  • Loading branch information
michalbali256 authored Aug 19, 2020
1 parent 0e1f47d commit f293d73
Show file tree
Hide file tree
Showing 6 changed files with 55 additions and 5 deletions.
19 changes: 17 additions & 2 deletions .github/workflows/Check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ on:
- development

jobs:
clang:
clang-asan:
name: Clang ASAN, UBSAN
runs-on: ubuntu-18.04

Expand All @@ -34,7 +34,22 @@ jobs:
- name: Requirements install
run: sudo apt-get update && sudo apt-get install uuid-dev ninja-build libc++-8-dev libc++abi-8-dev
- name: Configure
run: mkdir build && cd build && cmake -G Ninja -DBUILD_VSIX=Off -DCMAKE_C_COMPILER=clang-8 -DCMAKE_CXX_COMPILER=clang++-8 -DCMAKE_CXX_FLAGS="-fsanitize=address,undefined,fuzzer-no-link" ../
run: mkdir build && cd build && cmake -G Ninja -DBUILD_VSIX=Off -DCMAKE_C_COMPILER=clang-8 -DCMAKE_CXX_COMPILER=clang++-8 -DCMAKE_CXX_FLAGS="-fsanitize=address,undefined" ../
- name: Build
run: cd build && cmake --build .
- name: Test
run: cd build/bin && ./server_test && ./library_test

clang-tsan:
name: Clang TSAN
runs-on: ubuntu-18.04

steps:
- uses: actions/checkout@v1
- name: Requirements install
run: sudo apt-get update && sudo apt-get install uuid-dev ninja-build libc++-8-dev libc++abi-8-dev
- name: Configure
run: mkdir build && cd build && cmake -G Ninja -DBUILD_VSIX=Off -DCMAKE_C_COMPILER=clang-8 -DCMAKE_CXX_COMPILER=clang++-8 -DCMAKE_CXX_FLAGS="-fsanitize=thread" ../
- name: Build
run: cd build && cmake --build .
- name: Test
Expand Down
30 changes: 30 additions & 0 deletions CMakeSettings.json
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,36 @@
"addressSanitizerRuntimeFlags": "detect_leaks=0",
"variables": []
},
{
"name": "WSL-Clang-Release-TSAN",
"generator": "Ninja",
"configurationType": "RelWithDebInfo",
"buildRoot": "${projectDir}\\build\\${name}",
"installRoot": "${projectDir}\\install\\${name}",
"cmakeExecutable": "/usr/bin/cmake",
"cmakeCommandArgs": "-DCMAKE_CXX_COMPILER=clang++-8 -DCMAKE_C_COMPILER=clang-8 -DCMAKE_CXX_FLAGS=\"-fsanitize=thread\"",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "linux_x64" ],
"wslPath": "${defaultWSLPath}",
"addressSanitizerRuntimeFlags": "detect_leaks=0",
"variables": []
},
{
"name": "WSL-Clang-Debug-TSAN",
"generator": "Ninja",
"configurationType": "Debug",
"buildRoot": "${projectDir}\\build\\${name}",
"installRoot": "${projectDir}\\install\\${name}",
"cmakeExecutable": "/usr/bin/cmake",
"cmakeCommandArgs": "-DCMAKE_CXX_COMPILER=clang++-8 -DCMAKE_C_COMPILER=clang-8 -DCMAKE_CXX_FLAGS=\"-fsanitize=thread\"",
"buildCommandArgs": "",
"ctestCommandArgs": "",
"inheritEnvironments": [ "linux_x64" ],
"wslPath": "${defaultWSLPath}",
"addressSanitizerRuntimeFlags": "detect_leaks=0",
"variables": []
},
{
"name": "WSL-Clang-Fuzzer",
"generator": "Ninja",
Expand Down
6 changes: 5 additions & 1 deletion language_server/src/request_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ void request_manager::end_worker()
worker_.join();
}

bool request_manager::is_running() const { return !requests_.empty(); }
bool request_manager::is_running()
{
std::unique_lock<std::mutex> lock(q_mtx_);
return !requests_.empty();
}

void request_manager::handle_request_(const std::atomic<bool>* end_loop)
{
Expand Down
2 changes: 1 addition & 1 deletion language_server/src/request_manager.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class request_manager
void add_request(server* server, json message);
void finish_server_requests(server* server);
void end_worker();
bool is_running() const;
bool is_running();

private:
std::atomic<bool> end_worker_;
Expand Down
1 change: 1 addition & 0 deletions language_server/test/dap/feature_launch_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,7 @@ TEST_F(feature_launch_test, step)

methods["continue"]("47"_json, json());
resp_provider.wait_for_exited();
ws_mngr.disconnect();
}

std::string file_breakpoint = R"( LR 1,1
Expand Down
2 changes: 1 addition & 1 deletion parser_library/src/workspace_manager_impl.h
Original file line number Diff line number Diff line change
Expand Up @@ -281,9 +281,9 @@ class workspace_manager::impl : public diagnosable_impl, public debugging::debug

private:
debugging::debug_config debug_cfg_;
std::unique_ptr<debugging::debugger> debugger_;
std::set<debug_event_consumer*> debug_event_consumers_;
std::unique_ptr<debugging::debug_lib_provider> debug_lib_provider_;
std::unique_ptr<debugging::debugger> debugger_;

// Inherited via debug_event_consumer_s
virtual void stopped(const std::string& reason, const std::string& addtl_info) override
Expand Down

0 comments on commit f293d73

Please sign in to comment.