Skip to content

ci: collect state_exec's cycles at exit instead of suppressing them in LSan - #877

Merged
transfix merged 5 commits into
masterfrom
ci/lsan-collect-cycles
Oct 30, 2026
Merged

transfix merged 5 commits into
masterfrom
ci/lsan-collect-cycles

Conversation

@transfix

@transfix transfix commented Oct 29, 2026 •

Copy link
Copy Markdown
Owner

.github/sanitizers/lsan.supp hid every LeakSanitizer report in five fixtures (AsyncEvaluatorTest, AsyncCrossEvaluatorTest, ProducerConsumerTest, E2EIntegrationTest, MigrationIntegrationTest.MigrateProcessBetweenNodes). The leaks were state_exec reference cycles: a closure bound in the scope it captured holds that scope, which holds it. Only collect_cycles() (heap.h) frees such a cycle, and these tests finish before a collection is due. The suppressions would also have hidden a real leak in those fixtures.

  • state_exec_async_test and state_exec_integration_test each run collect_cycles() in a gtest global environment's TearDown, as state_exec_locks_test does since state_exec locks L0: state-incr, state-cas and state-swap #860. The five entries are removed.
  • Library fix. The first CI run showed the integration test clean but the async test still leaking its 76,848 bytes. Only the stackless evaluator registered a closure's captured scope with the cycle tracker (track_captured_env). The recursive evaluator and async_evaluator didn't, so their cycles were invisible to the collector and leaked for any host using them, not only these tests. Both do_lambdas now register the scope; defun and class methods go through them too. A local probe confirms an async defun is tracked and that one collection frees its cycle.

Testing:

  • Windows Release: state_exec async (77), evaluator (48), exceptions (18), gaps (94), heap (21) and integration (104) pass. In state_exec_scheduler_test (163 pass), two timing tests failed under full machine load and pass when rerun alone, 3 times each.
  • The check that matters is this PR's sanitizers / asan-ubsan job, which runs both binaries with no suppressions.

…n LSan

lsan.supp hid every leak in five fixtures of state_exec_async_test and
state_exec_integration_test: the reference cycles their programs leave
(a closure and the scope it captured), which only collect_cycles() frees
and which these short tests never reach. A suppression would also hide a
real leak there. Each binary now runs collect_cycles() in a gtest global
environment's TearDown, as state_exec_locks_test does, and the entries go.
Every fixture evaluates on the main thread, whose registry that collection
walks.
…losure captures

Only the stackless evaluator called track_captured_env when it made a
closure, so a defun or lambda bound back into its scope by the recursive
evaluator or async_evaluator was a cycle the collector never saw: it leaked
even for a host that collects. #877's asan-ubsan run showed it, the 76,848
bytes of state_exec_async_test that lsan.supp used to hide, all from those
two evaluators. Both do_lambdas (defun and methods go through them) now
register the captured scope, as the stackless evaluator does.
@transfix
transfix merged commit 27d03f7 into master Oct 30, 2026
45 of 46 checks passed
@transfix
transfix deleted the ci/lsan-collect-cycles branch October 30, 2026 17:03
transfix added a commit that referenced this pull request Nov 4, 2026
state_exec_exceptions_test, state_exec_async_calls_test and state_exec_data_steps_test joined the ASan+UBSan leg with Stage 0 and leaked their programs' closure/scope cycles at exit (every report an indirect leak: cycles, no direct leak). Like #877's binaries, each runs collect_cycles() in a global gtest environment's TearDown.
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