Repository navigation
docs(gc)+cli: cwist_gc_scope_flush contract and hazard warnings (#347) - #348
Merged
Merged
Conversation
…ependency (#347) The gc.h comment told callers to flush at the end of each request. That is unsafe: a flush retires every block the thread still tracks, live or not, and request-serving threads never enter an epoch, so reclaim frees retired blocks even while they are in use. It also only frees anything when reclamation is driven, which a full-GC process does not do on its own. fly.board followed the old advice from a middleware. - gc.h: cwist_gc_scope_flush() now states the precondition (no live tracked block on the thread), where it is and is not OK, and the reclaim dependency; cwist_conn_registry_flush() warns that it closes connections other threads are serving; cwist_conn_registry_untrack() no longer claims it only searches the caller's list (#344 changed that). - docs/GC.md and docs/ko/GC.md: new section 7, "Explicit flushes and reclamation", and a corrected teardown-safety row in the summary.
…ed (#347) cwist audit and cwist watcher now flag application calls to cwist_gc_scope_flush, cwist_ebr_free, cwist_gc_scope_disown/untrack, cwist_conn_registry_flush and cwist_conn_registry_sweep_all. Each warning states the API's contract and points at docs/GC.md section 7; marking the call site 'cwist-ack: <api>' (same line or the line above) silences it once someone has checked the call against the contract. CWIST's own tree is not scanned. watcher reports at startup and on every changed .c/.h file; audit --json sends the warnings to stderr so its stdout stays valid JSON. scripts/ci/test_cli_hazards.py covers detection, the ack marker, comment and prefix false positives, and skipping CWIST's own sources.
3 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Addresses the documentation and tooling items of #347.
Why
The
cwist_gc_scope_flush()comment ingc.htold callers to flush "at the end of each unit of work … (a request, a queued job)". fly.board followed that advice from a request middleware. That is unsafe for two reasons:The middleware has since been removed from fly.board (gg582/fly.board@db27855) and redeployed.
Docs (
aab01576)gc.h:cwist_gc_scope_flush()now states its precondition (the thread holds no live tracked block), lists where it is and is not OK to call, and explains the reclaim dependency.cwist_conn_registry_flush()now warns that it closes connections other threads are still serving.cwist_conn_registry_untrack()no longer claims it searches only the caller's list (segfault (UAF) in cwist_http_header_get (http.c:1575): forked connection handlers die mid-request, clients see timeouts #344 changed that).docs/GC.mdanddocs/ko/GC.md: new section 7, Explicit flushes and reclamation, with an OK / not-OK table and the ack marker. The summary table's teardown-safety row is corrected: epoch deferral protects only readers insidettak_epoch_enter().CLI (
8c9f3374)cwist auditandcwist watcherwarn on application calls to:cwist_gc_scope_flushcwist_ebr_freecwist_gc_scope_disown/cwist_gc_scope_untrackcwist_conn_registry_flushcwist_conn_registry_sweep_allcwist-ack: <api>on the same line or the line above silences the warning. A single marker can list several APIs.cwist audit srcin this repo shows only the multiport warning it already showed.watcherreports once at startup, then again for each changed.c/.hfile.audit --jsonwrites the warnings to stderr, so stdout stays valid JSON.Tests
scripts/ci/test_cli_hazards.py, 9 cases: detection in.c/.h, ack on the same line or the line above, a wrong-API ack, a multi-API ack, comment and prefix false positives, skipping CWIST's own tree, and the report text. It is picked up by the existingunittest discover -s scripts/ci -p 'test_*.py'CI step.test_malloc_gate.pystill passes.watcher --oncewarns once, and the warning goes away after acking.Not in this PR: the third #347 item, deciding whether full GC should drive reclaim itself.