[debian-mysql] Bug#864774: mariadb-10.1: make_atomic_add_body from c11_atomics.patch has incorrect behavior
James Cowgill
jcowgill at debian.org
Wed Jun 14 14:12:43 UTC 2017
Source: mariadb-10.1
Version: 10.1.23-8
Severity: important
Tags: patch
Hi,
While doing some testing for upstream, I had to apply a slightly
modified version of c11_atomics.patch to get 10.2 to build on MIPS.
However although MariaDB builds after that, it immediately aborts near
some atomics related code.
I discovered that the implementation of make_atomic_add_body in
incorrect in c11_atomics.patch. At the moment we have this:
+#define make_atomic_add_body(S) \
+ __atomic_add_fetch(a, v, __ATOMIC_SEQ_CST)
From the documentation of make_atomic_add, it looks like v should be set
to the previous value of *a which is not done here. The correct
implementation is:
+#define make_atomic_add_body(S) \
+ v= __atomic_fetch_add(a, v, __ATOMIC_SEQ_CST)
This is very similar to the operation used for the native GCC atomics above.
While this bug causes 10.2 to completely break on MIPS, I haven't seen
10.1 break. It may be that this code isn't used anywhere important in
10.1, but I still think it would be good to fix this before finding out
some obscure place it does break.
Thanks,
James
-------------- next part --------------
diff -Nru mariadb-10.1-10.1.24/debian/patches/c11_atomics.patch mariadb-10.1-10.1.24/debian/patches/c11_atomics.patch
--- mariadb-10.1-10.1.24/debian/patches/c11_atomics.patch 2017-06-07 01:23:44.000000000 +0100
+++ mariadb-10.1-10.1.24/debian/patches/c11_atomics.patch 2017-06-14 14:03:27.000000000 +0100
@@ -59,7 +59,7 @@
+#elif defined(HAVE_GCC_C11_ATOMICS)
+
+#define make_atomic_add_body(S) \
-+ __atomic_add_fetch(a, v, __ATOMIC_SEQ_CST)
++ v= __atomic_fetch_add(a, v, __ATOMIC_SEQ_CST)
+#define make_atomic_fas_body(S) \
+ v= __atomic_exchange_n(a, v, __ATOMIC_SEQ_CST)
+#define make_atomic_cas_body(S) \
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <http://lists.alioth.debian.org/pipermail/pkg-mysql-maint/attachments/20170614/fb1201aa/attachment.sig>
More information about the pkg-mysql-maint
mailing list