Skip to content

Add write barriers for generational GC - #23

Merged
plajjan merged 2 commits into
mainfrom
write-barriers
Nov 9, 2026
Merged

plajjan merged 2 commits into
mainfrom
write-barriers

Conversation

@plajjan

@plajjan plajjan commented Nov 9, 2026

Copy link
Copy Markdown
Contributor

This makes the C extension correct in Acton's generational GC mode and runs the write-barrier checker in CI. It needs the barrier API of actonlang/acton#3390 (acton_malloc_rescanned and ACTON_STORE). That PR is merged, but the tip release that CI installs does not have it yet, so the first CI run of this PR fails to compile. CI runs again once the tip release has actonlang/acton#3390.

The checker found pointer stores without a barrier in this package. On the gate of actonlang/acton#3390 (AMD Ryzen 9 5950X, Linux), a program that links this package exited with status 70 on a store by libuv into the handle queue of a uv_poll_t that src/lib.ext.c allocated as plain GC memory. In this repository, acton test --gc-check on main exits with status 70 in every run, in PipeOrderTester, on the stores into the channel write queues. 5 of its 36 reports were of the kind where the collector would free an object that is still in use.

The test suite alone does not find a uv handle in plain GC memory: with only the client poll put back on acton_calloc, 50 runs of acton test --gc-check passed. src/fanout.act, with many concurrent connections, finds it, so CI also runs it under the checker.

Tested with Acton built from the head of actonlang/acton#3390, 7c248ccfa, on an Apple M4 Pro with macOS 15.7.9 and OpenSSH 9.9p2. acton test --tag openssh passed 5 runs in ordinary mode and 20 runs in generational mode. acton test --gc-check passed 100 runs, 10 more runs with --min-time 2000 --max-time 10000 and 20 runs with --fast, with no checker report. The example programs passed in ordinary, generational and checker mode. With only the client poll put back on acton_calloc, fanout under ACTON_GC_CHECK=1 exited with status 70 in 5 of 5 debug runs and 5 of 5 --fast runs.

The write-barrier checker of Acton's generational GC mode found pointer
stores without a barrier: libuv's stores into the uv handles, and our
stores into the channel write queues. In generational mode such a store
can let the collector free an object that is still in use.
@plajjan
plajjan merged commit 7c34cff into main Nov 9, 2026
1 of 3 checks passed
@plajjan
plajjan deleted the write-barriers branch November 9, 2026 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant