Skip to content

Fix multithreaded test harness teardown races - #376

Merged
ermig1979 merged 1 commit into
masterfrom
cursor/localize-ci-test-crash-dceb
Jun 8, 2026
Merged

Fix multithreaded test harness teardown races#376
ermig1979 merged 1 commit into
masterfrom
cursor/localize-ci-test-crash-dceb

Conversation

@ermig1979

Copy link
Copy Markdown
Owner

Summary

  • Serialize Test::Log state mutations and output so skipped messages, thread names, and file/stdout writes are safe under threaded tests.
  • Replace per-worker Linux signal handler install/restore with a shared ref-counted scope and a thread-local valid-jump guard.

Testing

  • cmake ./prj/cmake -B build-debug-ci -DCMAKE_BUILD_TYPE=Debug -DCMAKE_CXX_COMPILER=g++ -DCMAKE_C_COMPILER=gcc -DSIMD_TOOLCHAIN="g++" -DSIMD_TARGET="" -DSIMD_AVX512VNNI=ON -DSIMD_AVX512BF16=ON -DSIMD_AMXBF16=ON -DSIMD_TEST_FLAGS="-march=native" -DSIMD_SHARED=ON && cmake --build build-debug-ci --parallel$(nproc)
  • LD_LIBRARY_PATH="/workspace/build-debug-ci:$LD_LIBRARY_PATH" ./Test "-r=.." -m=a -tt=4 "-ot=log_Debug_sobel_verify.txt" -ts=1 -mt=1 -w=640 -h=480 -c=256 -fi=Sobel
  • LD_LIBRARY_PATH="/workspace/build-debug-ci:$LD_LIBRARY_PATH" ./Test "-r=.." -m=a -tt=$(nproc) "-ot=log_Debug_broad_verify.txt" -ts=5 -mt=1 -w=640 -h=480 -c=256 -fe=SynetConvolution8i -fe=SynetQuantizedConvolution
  • Warning: the exact unfiltered CI command exits early on this VM with SIGILL in SynetConvolution8iForwardAutoTest, so local validation used the broad filtered run above to reach the reported post-success teardown path.
Open in Web Open in Cursor 

Co-authored-by: Ihar Yermalayeu <ermig1979@gmail.com>
@ermig1979
ermig1979 marked this pull request as ready for review June 8, 2026 10:45
Copilot AI review requested due to automatic review settings June 8, 2026 10:45

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR aims to harden the multithreaded test harness teardown path by making logging state mutations/output thread-safe and by reducing races around Linux signal handler installation/restoration during parallel test execution.

Changes:

  • Added a mutex to serialize Test::Log configuration mutations and Write() output/state tracking across threads.
  • Replaced per-worker Linux signal handler install/restore with a shared, ref-counted SignalScope, plus a thread-local “valid jump” guard for setjmp/longjmp usage.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/Test/TestLog.cpp Serializes log configuration changes and Write() output/state with a mutex.
src/Test/Test.cpp Introduces shared Linux signal handler scope and a thread-local validity guard for setjmp/longjmp to avoid teardown races.

Comment thread src/Test/TestLog.cpp
Comment on lines 47 to 52
void Log::SetLogFile(String name)
{
std::lock_guard<std::mutex> lock(_mutex);
CreatePathIfNotExist(name, true);
_file.open(name);
}
Comment thread src/Test/Test.cpp
Comment on lines 563 to +566
#if defined(__linux__)
static __thread jmp_buf s_threadData;
static __thread bool s_threadDataValid;
static std::mutex s_signalMutex;
Comment thread src/Test/Test.cpp
Comment on lines 759 to +762
#if defined(__linux__)
__thread jmp_buf Task::s_threadData;
__thread bool Task::s_threadDataValid = false;
std::mutex Task::s_signalMutex;
@ermig1979
ermig1979 merged commit 7783586 into master Jun 8, 2026
25 checks passed
@ermig1979
ermig1979 deleted the cursor/localize-ci-test-crash-dceb branch July 1, 2026 11:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants