Skip to content

NSE 2.5.2: idempotent trace table, no leak on a cancelled spawn - #42

Merged
onyks-os merged 2 commits into
mainfrom
fix/2.5.2
Nov 27, 2026
Merged

onyks-os merged 2 commits into
mainfrom
fix/2.5.2

Conversation

@onyks-os

Copy link
Copy Markdown
Owner

Fixed

  • RuleEngine.load() no longer accumulates NSE's trace rules. nft -f appends to existing chains, so every load added another meta nftrace set 1, and a load without trace_output kept an earlier output chain. The trace block now starts with table inet nse_trace + delete table inet nse_trace in the same transaction.
  • Cancelling spawn_process() mid-creation no longer leaks part of the launch chain. A cancel before create_subprocess_exec() returned reached asyncio, which kills only the group leader. This was the intermittent test_cancelling_the_start_leaves_nothing_running failure: 7/1200 on GitHub runners (dash as /bin/sh), each leftover a sleep 30 with ppid=1 in the leader's group. Creation is now shielded, and on a cancel the whole group is killed.

Added

  • When readiness is not proven, TraceReadiness.problems says whether inet nse_trace is missing (e.g. after flush ruleset) or lacks its prerouting/output chain.
  • The process-test fixture describes leftovers (state, ppid, pgid, cmdline) before killing them.

Verification

  • New root tests: three loads leave one rule per chain; a trace_output load followed by a plain one leaves only prerouting; after several loads each packet is traced by NSE once; a flush ruleset ruleset is not ready and says why. Against the old load(), two of them fail (3 NSE events per packet).
  • New unit test that holds creation open after the fork: fails every time on the old process.py, passes with the fix.
  • Local: lint, 839 unit tests (coverage 99%), mkdocs --strict; 89 integration tests in the privileged Debian container, no residual resources.

🤖 Generated with Claude Code

onyks-os and others added 2 commits November 27, 2026 13:26
RuleEngine.load() prepends NSE's trace table, but nft -f appends to a
chain that already exists: every load duplicated 'meta nftrace set 1',
and a load without trace_output kept an earlier output chain. The trace
block now starts with 'table inet nse_trace' + 'delete table inet
nse_trace' in the same transaction.

A readiness proof that fails now says whether nse_trace or one of its
chains is missing, e.g. after a ruleset starting with 'flush ruleset'.

The process-test fixture describes any leftover (state, parent, group,
command) before killing it, to diagnose the intermittent failure of
test_cancelling_the_start_leaves_nothing_running.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: onyks-os <129986281+onyks-os@users.noreply.github.com>
…E 2.5.2

The child exists before asyncio.create_subprocess_exec() returns. A
cancel in that window reached asyncio, which killed only the group
leader: what the launch chain had already forked survived, adopted by
init. On Ubuntu, where /bin/sh is dash, this made
test_cancelling_the_start_leaves_nothing_running fail about once in
200 runs (7 of 1200 on GitHub runners, each leftover a 'sleep 30' with
ppid=1 in the leader's group).

Creation now runs shielded; on a cancel it is allowed to finish, and the
whole process group is killed before the cancel is re-raised. A new test
holds creation open after the fork and reproduces the leak every time
without the fix.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: onyks-os <129986281+onyks-os@users.noreply.github.com>
@onyks-os
onyks-os merged commit 86d0ce4 into main Nov 27, 2026
18 checks passed
@onyks-os
onyks-os deleted the fix/2.5.2 branch November 27, 2026 12:49
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