Hunting for data races in document_stream (#1323)
* Adding matching tests. * Actually adding thread testing actions.
This commit is contained in:
parent
d9c4191e8a
commit
bc4087ac96
|
@ -0,0 +1,27 @@
|
||||||
|
name: Ubuntu 18.04 CI (GCC 7) with Thread Sanitizer
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ubuntu-build:
|
||||||
|
runs-on: ubuntu-18.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: dependencies/.cache
|
||||||
|
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
||||||
|
- name: Use cmake
|
||||||
|
run: |
|
||||||
|
mkdir build &&
|
||||||
|
cd build &&
|
||||||
|
cmake -DSIMDJSON_SANITIZE_THREADS=ON .. &&
|
||||||
|
cmake --build . --target document_stream_tests --target parse_many_test &&
|
||||||
|
ctest --output-on-failure -R parse_many_test &&
|
||||||
|
ctest --output-on-failure -R document_stream_tests
|
|
@ -0,0 +1,27 @@
|
||||||
|
name: Ubuntu 20.04 CI (GCC 9) with Thread Sanitizer
|
||||||
|
|
||||||
|
on:
|
||||||
|
push:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
pull_request:
|
||||||
|
branches:
|
||||||
|
- master
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ubuntu-build:
|
||||||
|
runs-on: ubuntu-20.04
|
||||||
|
steps:
|
||||||
|
- uses: actions/checkout@v2
|
||||||
|
- uses: actions/cache@v2
|
||||||
|
with:
|
||||||
|
path: dependencies/.cache
|
||||||
|
key: ${{ hashFiles('dependencies/CMakeLists.txt') }}
|
||||||
|
- name: Use cmake
|
||||||
|
run: |
|
||||||
|
mkdir build &&
|
||||||
|
cd build &&
|
||||||
|
cmake -DSIMDJSON_SANITIZE_THREADS=ON .. &&
|
||||||
|
cmake --build . --target document_stream_tests --target parse_many_test &&
|
||||||
|
ctest --output-on-failure -R parse_many_test &&
|
||||||
|
ctest --output-on-failure -R document_stream_tests
|
|
@ -27,6 +27,15 @@ if(SIMDJSON_SANITIZE)
|
||||||
endif()
|
endif()
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
|
if(SIMDJSON_SANITIZE_THREADS)
|
||||||
|
target_compile_options(simdjson-flags INTERFACE -fsanitize=thread -fsanitize=undefined -fno-sanitize-recover=all)
|
||||||
|
target_link_libraries(simdjson-flags INTERFACE -fsanitize=thread -fsanitize=undefined -fno-sanitize-recover=all)
|
||||||
|
|
||||||
|
# Ubuntu bug for GCC 5.0+ (safe for all versions)
|
||||||
|
if (CMAKE_COMPILER_IS_GNUCC)
|
||||||
|
target_link_libraries(simdjson-flags INTERFACE -fuse-ld=gold)
|
||||||
|
endif()
|
||||||
|
endif()
|
||||||
|
|
||||||
if (NOT CMAKE_BUILD_TYPE)
|
if (NOT CMAKE_BUILD_TYPE)
|
||||||
message(STATUS "No build type selected, default to Release")
|
message(STATUS "No build type selected, default to Release")
|
||||||
|
|
|
@ -24,7 +24,7 @@ inline void stage1_worker::start_thread() {
|
||||||
return; // This should never happen but we never want to create more than one thread.
|
return; // This should never happen but we never want to create more than one thread.
|
||||||
}
|
}
|
||||||
thread = std::thread([this]{
|
thread = std::thread([this]{
|
||||||
while(can_work) {
|
while(true) {
|
||||||
std::unique_lock<std::mutex> thread_lock(locking_mutex);
|
std::unique_lock<std::mutex> thread_lock(locking_mutex);
|
||||||
cond_var.wait(thread_lock, [this]{return has_work || !can_work;});
|
cond_var.wait(thread_lock, [this]{return has_work || !can_work;});
|
||||||
if(!can_work) {
|
if(!can_work) {
|
||||||
|
|
Loading…
Reference in New Issue