Commit 8b0a934
async: free worker ctx->last_diag before free(ctx) so throws don't leak
When a future's body threw with no enclosing try, prim_throw_classified
installed a diag into the worker's per-thread ctx->last_diag. The
diag's cached_map got captured into impl->exception (reachable from
the future on the GC heap), but worker_run's free(ctx) at exit
discarded the diag struct pointer without diag_free'ing it. Leak was
~160 bytes per throwing future.
Pre-existing latent: macOS clang ASan ships without LSan, so it
never surfaced locally. ubuntu gcc-asan + LSan default-on caught it
when v0.255.18's new async test added a throwing future.
worker_run now calls diag_free(ctx->last_diag) before free(ctx). The
diag's malloc'd kind/code/message/notes/spans/frames all reclaim;
the Mino cached_map stays GC-reachable.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 1949eae commit 8b0a934
3 files changed
Lines changed: 36 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
3 | 26 | | |
4 | 27 | | |
5 | 28 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
28 | 28 | | |
29 | 29 | | |
30 | 30 | | |
31 | | - | |
| 31 | + | |
32 | 32 | | |
33 | 33 | | |
34 | 34 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
377 | 377 | | |
378 | 378 | | |
379 | 379 | | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
| 383 | + | |
| 384 | + | |
| 385 | + | |
| 386 | + | |
| 387 | + | |
| 388 | + | |
| 389 | + | |
| 390 | + | |
| 391 | + | |
380 | 392 | | |
381 | 393 | | |
382 | 394 | | |
| |||
0 commit comments