Repository navigation
fix(stack): initialize binary files on Linux - #140
Merged
Merged
Conversation
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>
Contributor
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.
nansen.stack.virtual.Binary.initializeFilepreallocates a new.rawfile. It only assignedstatusinside anispc/ismacbranch, so on Linux neither branch ran,statuswas never defined, and the followingif statusthrewUnrecognized 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 fivenansen.unittest.stack.CropTesterrors in CI with the identifierNANSEN:Stack:Crop:FileNotCreatedandCaused by: Unrecognized function or variable 'status'. The suite passes on macOS becauseismacsetsstatus = 1and thefwritefallback runs.statusnow defaults to 1 and is only overridden on Windows, wherefsutilpreallocates the file without writing its contents. Linux and macOS take thefwritefallback, which is the path macOS already used.The
fopenhandle is also checked before it is used. Previously a folder that does not exist or is not writable passed-1tofwrite. The error now names the file and the reasonfopengave. The handle is closed throughonCleanup, so the file is released iffwriteerrors, and cleared explicitly before the file is memory mapped.🤖 Generated with Claude Code