From: kosaki.motohiro@... Date: 2015-02-19T22:19:16+00:00 Subject: [ruby-core:68193] [Ruby trunk - Bug #10867] An ATOMIC_GET operation should be written and used. Issue #10867 has been updated by Motohiro KOSAKI. No. If you need a synchronization, you must not use rb_atomic_t. That's a bug. ---------------------------------------- Bug #10867: An ATOMIC_GET operation should be written and used. https://bugs.ruby-lang.org/issues/10867#change-51563 * Author: Steven Stewart-Gallus * Status: Feedback * Priority: Normal * Assignee: * ruby -v: 2.2.0 * Backport: 2.0.0: UNKNOWN, 2.1: UNKNOWN, 2.2: UNKNOWN ---------------------------------------- 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. -- https://bugs.ruby-lang.org/