mirror of
https://github.com/jemalloc/jemalloc.git
synced 2026-07-24 13:53:11 +00:00
Better trigger race condition in bin_batching unit test
This commit is contained in:
@@ -45,9 +45,16 @@ increment_push_failure(size_t push_idx) {
|
|||||||
atomic_fetch_add_zu(&push_failure_count, 1, ATOMIC_RELAXED);
|
atomic_fetch_add_zu(&push_failure_count, 1, ATOMIC_RELAXED);
|
||||||
} else {
|
} else {
|
||||||
assert_zu_lt(push_idx, 4, "Only 4 elems");
|
assert_zu_lt(push_idx, 4, "Only 4 elems");
|
||||||
volatile int x = 10000;
|
volatile size_t x = 10000;
|
||||||
while (--x) {
|
while (--x) {
|
||||||
/* Spin for a while, to try to provoke a failure. */
|
/* Spin for a while, to try to provoke a failure. */
|
||||||
|
if (x == push_idx) {
|
||||||
|
#ifdef _WIN32
|
||||||
|
SwitchToThread();
|
||||||
|
#else
|
||||||
|
sched_yield();
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user