Describe the bug
I run the tests with the thread sanitizer. The test_bfs takes forever to finish, which indicates that there might be some problem in concurrency_breadth_first_search. When I set num_threads to 1, the problem does not occur.
This seems to be the problematic code:
|
next_level_cond.notify_all(); |
|
} else { |
|
// not to wait if last worker reachs last statement before notify |
|
// all or even further |
|
std::unique_lock<std::mutex> next_level_lock(next_level_mutex); |
|
next_level_cond.wait(next_level_lock, [&level, cur_level]() { |
I think the problem is that the thread will not get notified by notify_all(), if it is not already in wait().
To Reproduce
Steps to reproduce the behavior:
- Replace
|
if(SANITIZE) |
|
add_compile_options( |
|
-fsanitize=address |
|
-fsanitize=leak |
|
) |
|
add_link_options( |
|
-fsanitize=address |
|
-fsanitize=leak |
|
) |
|
endif(SANITIZE) |
with
if(SANITIZE)
add_compile_options(
-fsanitize=thread
)
add_link_options(
-fsanitize=thread
)
endif(SANITIZE)
- Run the build with
-DSANITIZE=ON and run the tests (cf. you might need this).
Expected behavior
test_bfs takes reasonable amour of time.
Describe the bug
I run the tests with the thread sanitizer. The
test_bfstakes forever to finish, which indicates that there might be some problem inconcurrency_breadth_first_search. When I setnum_threadsto 1, the problem does not occur.This seems to be the problematic code:
CXXGraph/include/CXXGraph/Graph/Algorithm/BestFirstSearch_impl.hpp
Lines 230 to 235 in 376d91b
I think the problem is that the thread will not get notified by
notify_all(), if it is not already inwait().To Reproduce
Steps to reproduce the behavior:
CXXGraph/CMakeLists.txt
Lines 26 to 35 in 376d91b
with
-DSANITIZE=ONand run the tests (cf. you might need this).Expected behavior
test_bfstakes reasonable amour of time.