Repository navigation
Close file in read_bjg_header after reading the header - #141
Open
stevevanhooser wants to merge 1 commit into
Open
stevevanhooser wants to merge 1 commit into
stevevanhooser wants to merge 1 commit into
Conversation
read_bjg_header opened the .bin file to read the 4096-byte header but never closed it, leaking one file descriptor per call. ndr.reader.bjg calls it from t0_t1, getchannelsepoch, samplerate and readchannels_epochsamples, so segmented reads of long recordings (such as NDI ingestion) could exhaust the per-process open-file limit. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01PuiCWsNMWhTwwN3PrnGTw8
Contributor
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #141 +/- ##
==========================================
- Coverage 53.26% 53.25% -0.01%
==========================================
Files 160 160
Lines 9190 9191 +1
==========================================
Hits 4895 4895
- Misses 4295 4296 +1 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This branch has not been deployed
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.
Summary
ndr.format.bjg.read_bjg_headeropened the BJG.binfile to read its 4096-byte header but never calledfclose, leaking one file descriptor per call.ndr.reader.bjgcalls this function fromt0_t1,getchannelsepoch,samplerateandreadchannels_epochsamples(andndr.format.bjg.readcalls it too). Reading a long recording in segments (for example NDI'singest, which reads 1e6-sample segments) therefore leaks a handle per segment and can exhaust the per-process open-file limit (256 by default on macOS). After that, later file opens fail.Change
Adds
fclose(fid)right after the headerfread. Nothing after that line usesfid, so closing early also covers the latererror(...)paths in the parser.Testing
Not run: no MATLAB environment was available. Suggested check: call
ndr.format.bjg.read_bjg_headeron a BJG file in a loop and confirmnumel(fopen('all'))stays at 0.🤖 Generated with Claude Code
https://claude.ai/code/session_01PuiCWsNMWhTwwN3PrnGTw8
Generated by Claude Code