1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
//! Reproducer for the rayon/zk-alloc interaction bug documented in
//! leanMultisig commit f5e2299b. Pulls Tom's regression test verbatim and
//! adds a few stress variants to characterize how reliably the bug fires.
//!
//! Mechanism:
//! 1. rayon::join from a non-worker thread routes through the global
//! `crossbeam_deque::Injector`, which is a linked list of fixed-size
//! blocks (BLOCK_CAP = 63 slots).
//! 2. If a fresh injector block is allocated *during* an arena phase,
//! the block lives in the arena slab.
//! 3. The next `begin_phase()` recycles the slab. Rayon still holds a
//! pointer to that block; the next push writes a JobRef over whatever
//! the application has allocated on top — silent corruption.
//!
//! These tests use #[global_allocator] so that rayon's allocations route
//! through ZkAllocator (otherwise they go to the system allocator and
//! can't be corrupted).
use *;
static A: ZkAllocator = ZkAllocator;
/// Tom's original MRE.