Project

General

Profile

Actions

Feature #10867

closed

An ATOMIC_GET operation should be written and used.

Added by sstewartgallus (Steven Stewart-Gallus) about 9 years ago. Updated over 4 years ago.

Status:
Feedback
Assignee:
-
Target version:
-
[ruby-core:68173]

Description

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 9 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 9 years ago

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

Actions #4

Updated by jeremyevans0 (Jeremy Evans) over 4 years ago

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

Also available in: Atom PDF

Like0
Like0Like0Like0Like0