Skip to content

Synchronize GwpAsanState error recording across concurrent threads. - #1792

Closed
copybara-service[bot] wants to merge 1 commit into
masterfrom
test_1011015763
Closed

copybara-service[bot] wants to merge 1 commit into
masterfrom
test_1011015763

Conversation

@copybara-service

Copy link
Copy Markdown

Synchronize GwpAsanState error recording across concurrent threads.

GwpAsanState stored its fields as non-atomic members and overwrote them unconditionally on every Record* call. If two threads triggered GWP-ASan errors concurrently before process termination, they raced on type_, faulting_address_, and alloc_stack_/dealloc_stack_, corrupting the crash state read by the crash handler.

Gate Record* calls with Claim() (recording_.exchange(true, std::memory_order_acq_rel)) so the first crashing thread wins, and publish type_ with std::memory_order_release only after CopyStack finishes so error_type() (std::memory_order_acquire) observes complete stack traces.

`GwpAsanState` stored its fields as non-atomic members and overwrote them unconditionally on every `Record*` call. If two threads triggered GWP-ASan errors concurrently before process termination, they raced on `type_`, `faulting_address_`, and `alloc_stack_`/`dealloc_stack_`, corrupting the crash state read by the crash handler.

Gate `Record*` calls with `Claim()` (`recording_.exchange(true, std::memory_order_acq_rel)`) so the first crashing thread wins, and publish `type_` with `std::memory_order_release` only after `CopyStack` finishes so `error_type()` (`std::memory_order_acquire`) observes complete stack traces.

PiperOrigin-RevId: 1011015763
@copybara-service copybara-service Bot closed this Nov 2, 2026
@copybara-service
copybara-service Bot deleted the test_1011015763 branch November 2, 2026 16:24
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.

1 participant