Skip to content

Fix swapped CAS arguments breaking the one-time-init guard - #247

Open
eparshut wants to merge 1 commit into
intel:masterfrom
eparshut:sync_val_compare_and_swap
Open

Fix swapped CAS arguments breaking the one-time-init guard#247
eparshut wants to merge 1 commit into
intel:masterfrom
eparshut:sync_val_compare_and_swap

Conversation

@eparshut

@eparshut eparshut commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

On non-Windows platforms __itt_interlocked_compare_exchange passed exchange as oldval and comperand as newval to __sync_val_compare_and_swap, which takes (ptr, oldval, newval) - the reverse of InterlockedCompareExchange.

The compare never matched, so every thread won the ITT_MUTEX_INIT_AND_LOCK race and re-ran __itt_mutex_init() on an already-locked mutex (UB; aborts with a glibc assertion), and ITT_MUTEX_DESTROY never fired.

Fixes #245

@eparshut
eparshut requested a review from a team September 4, 2026 13:08
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.

Linux: swapped arguments to __sync_val_compare_and_swap make the one-time-init guard a no-op

1 participant