Fix reversed compare_exchange check.
We were incorrectly stopping a retry-loop when compare_exchange_strong
returned true instead of false. This could lead to races if multiple
threads tried to pause allocations simultaneously.
Test: ./test.py --host
Bug: 146436130
Change-Id: I46ab86010d24148d640af0c51a5268b3eef0d300
diff --git a/openjdkjvmti/alloc_manager.cc b/openjdkjvmti/alloc_manager.cc
index f5e4af6..7660539 100644
--- a/openjdkjvmti/alloc_manager.cc
+++ b/openjdkjvmti/alloc_manager.cc
@@ -165,7 +165,7 @@
IncrListenerInstall(self);
do {
PauseForAllocation(self, []() { return "request to pause allocations on other threads"; });
- } while (allocations_paused_thread_.compare_exchange_strong(
+ } while (!allocations_paused_thread_.compare_exchange_strong(
null_thr, self, std::memory_order_seq_cst));
// Make sure everything else can see this and isn't in the middle of final allocation.
// Force every thread to either be suspended or pass through a barrier.