]> granicus.if.org Git - gc/commit
Fix data race in GC_init_explicit_typing
authorIvan Maidanski <ivmai@mail.ru>
Tue, 1 Sep 2015 06:57:38 +0000 (09:57 +0300)
committerIvan Maidanski <ivmai@mail.ru>
Mon, 18 Dec 2017 21:29:28 +0000 (00:29 +0300)
commite52ef4b2c54ce163c5aa496b0e2acdf6e89816c9
treec7e963142b12639fada3cd3258ba741d41b5cdf7
parentacadba06e9e4b52fb249862673ba1334a9f1f089
Fix data race in GC_init_explicit_typing
(Cherry-pick commits 69527f2c0492a7 from 'release-7_4' branch.)

* typd_mlc.c: Force include atomic_ops.h if
GC_FORCE_INCLUDE_ATOMIC_OPS (by default it is included if
PARALLEL_MARK or pthreads are used).
* typd_mlc.c (GC_explicit_typing_initialized): Use volatile AO_t if
AO_load_acquire() and AO_store_release() are both available.
* typd_mlc.c (GC_init_explicit_typing): Move locking (and
GC_explicit_typing_initialized access) outside to the caller
(GC_make_descriptor); remove comment; remove "register" keyword for
local variable.
* typd_mlc.c (GC_make_descriptor): Use AO_load_acquire (if available)
to fetch GC_explicit_typing_initialized value and AO_store_release to
set GC_explicit_typing_initialized (to avoid data race and avoid lock
acquiring on each call); otherwise use locked checking of
GC_explicit_typing_initialized.
* typd_mlc.c (GC_explicit_typing_initialized,
GC_malloc_explicitly_typed_ignore_off_page,
GC_calloc_explicitly_typed): Add assertion on
GC_explicit_typing_initialized is true.
typd_mlc.c