From: Ivan Maidanski Date: Fri, 3 Nov 2017 18:30:23 +0000 (+0300) Subject: Fix double lock in a_set(f(a_get())) expression in gctest X-Git-Tag: v8.0.0~521 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=0f5a88d53ba02137b72a6fccfdaeaadd1f908d2f;p=gc Fix double lock in a_set(f(a_get())) expression in gctest (fix commit 8f5746e) * tests/test.c [!AO_HAVE_store_release] (AO_store_release): Replace macro with a static function definition (so, new_val argument is evaluated before acquiring the lock). --- diff --git a/tests/test.c b/tests/test.c index 3a208f89..453bfe73 100644 --- a/tests/test.c +++ b/tests/test.c @@ -187,8 +187,13 @@ } #endif #ifndef AO_HAVE_store_release -# define AO_store_release(p, v) \ - (void)(FINALIZER_LOCK(), *(p) = (v), FINALIZER_UNLOCK(), 0) + /* Not a macro as new_val argument should be evaluated before the lock. */ + static void AO_store_release(volatile AO_t *addr, AO_t new_val) + { + FINALIZER_LOCK(); + *addr = new_val; + FINALIZER_UNLOCK(); + } #endif #ifndef AO_HAVE_fetch_and_add1 # define AO_fetch_and_add1(p) ((*(p))++)