1
0
Fork 0
forked from suyu/suyu
suyu/src/tests
ReinUsesLisp 3fdb42e0b4 tests: Fix data race in fibers test
Previous to this commit, the tests were using operator[] from
unordered_map to query elements but this silently inserts empty elements
when they don't exist. If all threads were executed without concurrency,
this wouldn't be an issue, but the same unordered_map could be written
from two threads at the same time. This is a data race and makes some
previously inserted elements invisible for a short period of time,
causing them to insert and return an empty element. This default
constructed element (a zero) was used to index an array of fibers that
asserted when one of them was nullptr, shutting the test session off.

To address this issue, lock on thread id reads and writes. This could be
a shared mutex to allow concurrent reads, but the definition of
std::this_thread::get_id is fuzzy when using non-standard techniques
like fibers. I opted to use a standard mutex.

While we are at it, fix the included headers.
2020-10-28 01:41:24 -03:00
..
common tests: Fix data race in fibers test 2020-10-28 01:41:24 -03:00
core tests/core_timing: Remove pragma optimize(off) 2020-08-03 11:12:55 -04:00
CMakeLists.txt General: Recover Prometheus project from harddrive failure 2020-06-27 11:35:06 -04:00
tests.cpp externals: Update catch to 2.3.0 2018-08-07 19:26:13 -04:00