test(os): join threads to avoid race/use-after-free in osSemaphoreTests#35055
test(os): join threads to avoid race/use-after-free in osSemaphoreTests#35055guanshengliang merged 2 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates osSemaphoreTests to avoid races/use-after-free by no longer detaching producer/waiter threads that still reference stack-allocated semaphores.
Changes:
- Replace
std::thread(...).detach()with namedstd::threadvariables. - Join all spawned threads before destroying the semaphore instances.
- Apply the same pattern across functional and performance-oriented semaphore tests.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
Code Review
This pull request improves the reliability of the semaphore tests by replacing detached threads with named thread objects that are explicitly joined. This ensures that background threads finish their execution before the semaphores they reference are destroyed. The review feedback correctly identifies unnecessary variable captures in lambda expressions within the performance tests, which should be removed to improve code clarity.
Description
Issue(s)
Checklist
Please check the items in the checklist if applicable.