Feature #10867

An ATOMIC_GET operation should be written and used.

Added by sstewartgallus (Steven Stewart-Gallus) about 6 years ago. Updated over 1 year ago.

Target version:


In some cases rb_atomic_t types are retrieved without synchronization.
Most cases in the code seem very innocuous and unlikely to cause bugs
but an evil optimizing compiler could potentially do bad things
(especially with link time optimization). Now, the raw machine code
is probably going to be safe on architectures such as x86 but the
compiler might drag the code around and mess it up. A very easy
temporary solution might be to redefine rb_atomic_t to be volatile.
Technically, according to the C11 standard such accesses don't count
as synchronized or atomic but in practise that would prevent compilers
from moving accesses around. I would prefer if an ATOMIC_GET define
is made and used instead though.

Updated by nobu (Nobuyoshi Nakada) about 6 years ago

  • Status changed from Open to Feedback

Won't atomic operations using gcc's __atomic/__sync built-ins or other platform-provided functions make such barriers?

Updated by kosaki (Motohiro KOSAKI) about 6 years ago

If you need a synchronization, you must not use rb_atomic_t. That's a bug.


Updated by jeremyevans0 (Jeremy Evans) over 1 year ago

  • Backport deleted (2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN)
  • ruby -v deleted (2.2.0)
  • Tracker changed from Bug to Feature

Also available in: Atom PDF