Skip to content

Fix OOP pcap capture race with archive packaging#626

Merged
haga-rak merged 1 commit into
mainfrom
fix/oop-capture-pack-race
Apr 15, 2026
Merged

Fix OOP pcap capture race with archive packaging#626
haga-rak merged 1 commit into
mainfrom
fix/oop-capture-pack-race

Conversation

@haga-rak
Copy link
Copy Markdown
Owner

Summary

The out-of-proc capture subprocess held pcapng FileStreams with buffered data while PackDirectoryToFile zipped the capture directory. Small captures could sit in the 4KB FileStream buffer and get skipped by ZipHelper's Length == 0 check, leaving captures/*.pcapng missing from the fxzy archive. This caused intermittent NREs in CliWithCapOutOfProc.Run when the test drained the (null) raw capture stream.

Changes

  • StartCommandBuilder: wrap scope in an await using block so the capture subprocess exits (closing and flushing all pcapng FileStreams) before packaging runs.
  • OutOfProcessCaptureContext.Flush: actually flush the BinaryWriter so the flush message reaches the subprocess.
  • CliTestBase: assert NotNull on the raw capture stream before draining so future regressions surface with a clear message instead of an NRE through an extension method.

Dispose the capture scope before PackDirectoryToFile so the subprocess
closes its pcapng FileStreams and flushes buffered data to disk.
Previously the scope was method-scoped and disposed after packaging,
so small captures could sit in the 4KB FileStream buffer and get
skipped by ZipHelper's Length==0 check, leaving captures/*.pcapng
missing from the fxzy archive.

Also flush the BinaryWriter in OutOfProcessCaptureContext.Flush so the
flush message actually reaches the subprocess, and tighten the CLI
test assertion to Assert.NotNull before draining the capture stream.
@haga-rak haga-rak added the bug Something isn't working label Apr 15, 2026
@haga-rak haga-rak merged commit a84cedf into main Apr 15, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant