Skip to content

fix(stack): initialize binary files on Linux - #140

Merged
ehennestad merged 2 commits into
devfrom
fix-binary-file-creation-on-linux
Sep 18, 2026
Merged

ehennestad merged 2 commits into
devfrom
fix-binary-file-creation-on-linux

Conversation

@ehennestad

Copy link
Copy Markdown
Collaborator

nansen.stack.virtual.Binary.initializeFile preallocates a new .raw file. It only assigned status inside an ispc/ismac branch, so on Linux neither branch ran, status was never defined, and the following if status threw Unrecognized function or variable 'status'. Every code path that creates a new binary file was broken on Linux.

This is pre-existing, but nansen.stack.crop (#139) is the first test to create a binary file on Linux, so it showed up as five nansen.unittest.stack.CropTest errors in CI with the identifier NANSEN:Stack:Crop:FileNotCreated and Caused by: Unrecognized function or variable 'status'. The suite passes on macOS because ismac sets status = 1 and the fwrite fallback runs.

status now defaults to 1 and is only overridden on Windows, where fsutil preallocates the file without writing its contents. Linux and macOS take the fwrite fallback, which is the path macOS already used.

The fopen handle is also checked before it is used. Previously a folder that does not exist or is not writable passed -1 to fwrite. The error now names the file and the reason fopen gave. The handle is closed through onCleanup, so the file is released if fwrite errors, and cleared explicitly before the file is memory mapped.

🤖 Generated with Claude Code

Binary.initializeFile only assigned status inside an ispc/ismac
branch, so on Linux the variable was never defined and `if status`
threw "Unrecognized function or variable 'status'". Every code path
that creates a new .raw file failed on Linux, which surfaced in CI as
five CropTest errors with the identifier
NANSEN:Stack:Crop:FileNotCreated.

Default status to the fallback path and only override it on Windows,
where fsutil preallocates the file. Also check the fopen handle before
writing, so a folder that does not exist or is not writable reports
the reason instead of failing on an invalid file id, and close the
file through onCleanup so it is released if fwrite errors.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@github-actions

Copy link
Copy Markdown
Contributor

Test Results

369 tests  ±0   369 ✅ +7   27s ⏱️ ±0s
 25 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 3d7bfe0. ± Comparison against base commit 6da5f8a.

@ehennestad
ehennestad merged commit edc4dea into dev Sep 18, 2026
@ehennestad
ehennestad deleted the fix-binary-file-creation-on-linux branch September 18, 2026 03:11
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