Skip to content

Fix multithreaded shutdown thread safety issues - #5960

Open
ngoldbaum wants to merge 9 commits into
OpenMathLib:developfrom
ngoldbaum:shutdown-release-race
Open

Fix multithreaded shutdown thread safety issues#5960
ngoldbaum wants to merge 9 commits into
OpenMathLib:developfrom
ngoldbaum:shutdown-release-race

Conversation

@ngoldbaum

@ngoldbaum ngoldbaum commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Fixes #5954.

The first commit adds a failing test that stress-tests multithreaded shutdown.

The later commits fixes the bug by adding the missing locking that only alloc_mmap currently has to a centralized helper shared by all the allocator backends and adds locking for the windows allocator case.

To fully fix this I also needed to add some more shutdown logic that is needed to prevent the cleanup logic (which acquires locks) from firing if shutdown is in progress. It uses RtlDllShutdownInProgress for this, there's also an explanatory comment.

@ngoldbaum
ngoldbaum force-pushed the shutdown-release-race branch 2 times, most recently from f8ff54e to 6d48fdb Compare August 5, 2026 00:14
@ngoldbaum
ngoldbaum force-pushed the shutdown-release-race branch from 6d48fdb to 6e5c525 Compare August 5, 2026 01:17
@ngoldbaum
ngoldbaum marked this pull request as ready for review August 5, 2026 14:41
@martin-frbg

Copy link
Copy Markdown
Collaborator

Jenkins error (on zarch) is

make[1]: Entering directory '/home/alfred/jenkins/workspace/OpenBLAS-Z_PR-5960/cpp_thread_test'
Makefile:48: *** missing 'endif'.  Stop.

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.

Windows shutdown may race triggering crashes or hangs on workloads that oversaturate the CPU

2 participants