From 446a729aa6c3c718bfc5541546b3c21556041a50 Mon Sep 17 00:00:00 2001 From: Nathaniel Filardo Date: Tue, 12 May 2020 03:15:25 +0000 Subject: [PATCH] test/contention: acquire+release contention[].exchange It is important, in test_tasks_f, that the store of the size to the allocated block be made visible to other processors before the store of the pointer itself. Otherwise, other cores are justified in reading junk. This manifests on PowerPC as tripping the "Deallocating with incorrect size supplied" assertion in alloc.h:/check_size because the value read from the allocated block may not be a size but rather an internal queue pointer, which is implausibly large, as sizes go. --- src/test/perf/contention/contention.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/test/perf/contention/contention.cc b/src/test/perf/contention/contention.cc index 845c4d2ab..7506052fe 100644 --- a/src/test/perf/contention/contention.cc +++ b/src/test/perf/contention/contention.cc @@ -86,7 +86,7 @@ void test_tasks_f(size_t id) *res = size; size_t* out = - contention[n % swapsize].exchange(res, std::memory_order_relaxed); + contention[n % swapsize].exchange(res, std::memory_order_acq_rel); if (out != nullptr) {