Commit 24ed5fd
committed
fix(core): resolve TSAN data race in start_timeout_timer weak_ptr destruction
Release state_weak explicitly while the strong reference s is still alive
to prevent a ThreadSanitizer-detected data race on the shared_ptr control
block. Previously, the captured weak_ptr was destroyed as part of the lambda
closure after s went out of scope, causing a concurrent operator delete
(from ~weak_ptr on zero weak count) to race with the token destructor's
__release_shared read on the same control block address.
By calling state_weak.reset() before s is released, the weak ref-count
decrement occurs while a strong reference still exists, ensuring the control
block is freed deterministically on the main thread rather than racing with
the timer thread.
Fixes: ThreadSanitizer warning in enhanced_cancellation_token_test.LinkedWithTimeoutParentCancel1 parent d084254 commit 24ed5fd
1 file changed
Lines changed: 8 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
476 | 476 | | |
477 | 477 | | |
478 | 478 | | |
479 | | - | |
| 479 | + | |
480 | 480 | | |
481 | 481 | | |
482 | 482 | | |
| |||
544 | 544 | | |
545 | 545 | | |
546 | 546 | | |
| 547 | + | |
| 548 | + | |
| 549 | + | |
| 550 | + | |
| 551 | + | |
| 552 | + | |
| 553 | + | |
547 | 554 | | |
548 | 555 | | |
549 | 556 | | |
| |||
0 commit comments