FhSim  3.1.0
Marine systems simulation
Loading...
Searching...
No Matches
0101 — BatchPool.StopWorkers_JoinsTheThreads is flaky under load
ID 0101
Class TEST
Severity 1
Status ready

Models: —

Found: 2026-10-24

Evidence

Seen once in feature fhsim-review-fixes, in a full ctest run while two other fhsim builds loaded the machine: BatchPool.StopWorkers_JoinsTheThreads failed with a thread count of 1 where 2 was expected. It passed in every rerun, alone and in the full suite. A second full -j6 run once failed the fhsim gtest entry at about 4 s, with no output saved; probably the same test.

tests/core/fhUtilities/BatchPool_test.cpp:270-280:

const std::size_t before = ThreadCount();
BatchPool pool(3);
...
ASSERT_EQ(ThreadCount(), before + 3);
pool.StopWorkers();
EXPECT_EQ(ThreadCountOnceDroppedTo(before), before);

ThreadCount() reads /proc/self/task. A thread that an earlier test joined can still be listed for a short while (the test file already notes this), so before can be read too high or too low depending on when the kernel drops it. Not reproduced; this is the likely cause, not a proven one.

Effect

A red fast tier with no code defect; no user effect.

Possible fix

Sample before only after the count is stable (poll ThreadCount() until two reads agree, with a short bound), as ThreadCountOnceDroppedTo already does for the after side.

Test that would prove it

Run the test 1000 times under stress --cpu 32 (or with other test binaries in parallel) before and after the change.

Risk

Low; test-only change.