Skip to content

Fix missing release semantics in VolatilePtr#124096

Open
github-actions[bot] wants to merge 1 commit intomainfrom
backport/pr-124070-to-main
Open

Fix missing release semantics in VolatilePtr#124096
github-actions[bot] wants to merge 1 commit intomainfrom
backport/pr-124070-to-main

Conversation

@github-actions
Copy link
Contributor

@github-actions github-actions bot commented Feb 6, 2026

VolatilePtr inherits from Volatile<P>, which defines operator= to call VolatileStore() with release semantics (stlr on ARM64). However, VolatilePtr did not declare its own operator=, so the compiler-generated copy/move assignment operator hid the base class operator= and performed plain stores (str) instead, bypassing the memory barrier entirely.

Fix by adding a using declaration to bring Volatile<P>::operator= into scope, and an explicit copy assignment operator (which the using declaration cannot suppress the compiler from generating).

VolatilePtr inherits from Volatile<P>, which defines operator=(P val)
to call VolatileStore() with release semantics (stlr on ARM64). However,
VolatilePtr did not declare its own operator=, so the compiler-generated
copy/move assignment operator hid the base class operator= and performed
plain stores (str) instead, bypassing the memory barrier entirely.

This affected all VolatilePtr assignments including DeadlockAwareLock's
m_pHoldingThread and Thread's m_pBlockingLock fields, which were being
written without release semantics despite being read with acquire
semantics (ldapr) on the other side.

Fix by adding a using declaration to bring Volatile<P>::operator= into
scope, and an explicit copy assignment operator (which the using
declaration cannot suppress the compiler from generating).
@github-actions github-actions bot added the needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners label Feb 6, 2026
@hoyosjs hoyosjs changed the title [main] Fix missing release semantics in VolatilePtr Fix missing release semantics in VolatilePtr Feb 6, 2026
@davidwrighton
Copy link
Member

I think this is a good fix to get into main for now, while I work on more completely revamping Volatile/VolatilePtr to have fewer dangerous apis that are unexpectedly used. This is also a change suitable for backport for existing customers which have problems.

@hoyosjs
Copy link
Member

hoyosjs commented Feb 7, 2026

@davidwrighton - can you please approve?

@hoyosjs hoyosjs enabled auto-merge (squash) February 7, 2026 01:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

needs-area-label An area label is needed to ensure this gets routed to the appropriate area owners

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants