Skip to content

Commit 310000a

Browse files
committed
tests: adapt closure-capture-macro-introduced fanout to thread-limit
The 10-future sub-test in closure-capture-macro-introduced trips MTH001 on GHA runners (3-4 CPUs) because the default host thread_limit equals cpu_count and the test spawned 10 simultaneous futures unconditionally. The invariant under test is "N macro-introduced closures each capture their own per-iteration i" -- N is a parameter, not the property. Any N >= 2 exercises the closure-capture fix this regression test guards. Adapt N to (- (mino-thread-limit) 1) clamped to [2, 10] so the test scales to runner capacity and keeps its bug-catching intent on every host. Same shape as the T9 probe fix in mino-tests v0.8.1. Local suite green: 1274 tests, 4557 assertions, 0 failed. release-gate 17/17.
1 parent 06f07e5 commit 310000a

3 files changed

Lines changed: 49 additions & 5 deletions

File tree

CHANGELOG.md

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,42 @@
11
# Changelog
22

3+
## v0.255.12 — Fix: Adapt closure-capture-macro-introduced fanout to thread-limit
4+
5+
With the v0.255.11 pthread_join deadlock cleared, CI got past the
6+
`transient-survives-gc-yield` hang and reached the next latent issue:
7+
`closure-capture-macro-introduced` in `tests/bc_closure_test.clj`
8+
spawns 10 simultaneous futures unconditionally. The default host
9+
`thread_limit` is `cpu_count`, and GitHub-hosted runners are 3-4 CPUs
10+
(macos-14, ubuntu-24.04, ubuntu-24.04-arm), so the 10-way fanout
11+
trips `MTH001` (thread-limit-exceeded) before the test can verify
12+
the closure-capture invariant.
13+
14+
The invariant under test is "N macro-introduced closures each capture
15+
their own per-iteration `i`" — and N is a parameter, not the property
16+
under test. Any N ≥ 2 exercises the bug fix this regression test
17+
guards. The fix adapts the fanout to `(- (mino-thread-limit) 1)`,
18+
clamped to `[2, 10]`, so:
19+
20+
- Local dev (12+ CPUs): N=10, same as before.
21+
- GHA macos-14 / ubuntu-24.04 (3-4 CPUs): N=3, the test runs and
22+
asserts.
23+
- Embedder with `mino_set_thread_limit(S, 1)`: N=2, still meaningful.
24+
25+
Same shape as the T9 probe fix in `mino-tests` v0.8.1. The local
26+
suite reports 1274 tests, 4557 assertions, 0 failed on this branch.
27+
28+
### Verification
29+
30+
- `./mino tests/run.clj` green locally (1274 tests, 4557 assertions).
31+
- `release-gate` 17/17 green.
32+
- CI matrix expected green on the v0.255.12 push (the original hang
33+
cleared in v0.255.11; the thread-limit failure cleared here).
34+
35+
### Files
36+
37+
- `tests/bc_closure_test.clj` — adapt N to host thread limit.
38+
- `src/mino.h` — `MINO_VERSION_PATCH` bumped to 12.
39+
340
## v0.255.11 — Fix: Yield state_lock Around pthread_join in Future Sweep
441

542
The actual cause of the v0.255.x CI hang, pinpointed by v0.255.10's

src/mino.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
*/
2929
#define MINO_VERSION_MAJOR 0
3030
#define MINO_VERSION_MINOR 255
31-
#define MINO_VERSION_PATCH 11
31+
#define MINO_VERSION_PATCH 12
3232

3333
/*
3434
* Human-readable version string of the *linked* runtime, e.g. "0.48.0".

tests/bc_closure_test.clj

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -150,11 +150,18 @@
150150
(future (deliver p (* i i)))
151151
(recur (inc i))))
152152
(is (= 0 @p))))
153-
(testing "10 futures x 10 promises via dotimes deliver to distinct slots"
154-
(let [ps (vec (repeatedly 10 promise))]
155-
(dotimes [i 10]
153+
(testing "N futures x N promises via dotimes deliver to distinct slots"
154+
;; The closure-capture invariant doesn't depend on N; any N >= 2
155+
;; that fires distinct futures with distinct captured i exercises
156+
;; the macro-introduced-closure path. Adapt N to the host thread
157+
;; grant so 3-4 CPU CI runners don't hit MTH001 before the test
158+
;; can verify the invariant. Clamp [2, 10].
159+
(let [n (max 2 (min 10 (- (mino-thread-limit) 1)))
160+
ps (vec (repeatedly n promise))]
161+
(dotimes [i n]
156162
(future (deliver (nth ps i) (* i i))))
157-
(is (= [0 1 4 9 16 25 36 49 64 81] (mapv deref ps)))))
163+
(is (= (mapv (fn [i] (* i i)) (range n))
164+
(mapv deref ps)))))
158165
(testing "delay inside self-tail-call captures per-iteration param"
159166
(let [cls (atom [])]
160167
(defn G-delay [i]

0 commit comments

Comments
 (0)