Repository navigation
volume: close the file after a successful rawiv write - #663
Merged
Merged
Conversation
rawiv_io::writeVolumeFile's only fclose on the success path sat inside an #if 0 block, so every successful .rawiv write leaked its FILE*. The last scanline stayed in the stdio buffer (the per-scanline fseek flushes the others), so a read in the same process saw zeros there, and on Windows the file stayed locked until the process exited. pycvc's test_volume_rawiv_roundtrip failed on Windows for this reason (PermissionError deleting its temp directory). Close the file after the (still disabled) min/max block, checking the result since a late flush error surfaces at fclose, and drop the dead close inside #if 0 so re-enabling it can't double-close. volume_io_test gains RawivWriteFlushesEveryVoxelAndClosesTheFile: it compares every voxel, the far corner included, and removes the file straight after the read. Before the fix it failed on the five voxels of the last scanline and on the remove. expect_volume_equal skips the far corner, citing "boundary-plane quantization"; this missing close may be what that comment saw.
This was referenced Oct 18, 2026
transfix
added a commit
that referenced
this pull request
Oct 18, 2026
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.
rawiv_io::writeVolumeFilenever closed its file after a successful write. Its onlyfclose(output)on the success path sat inside an#if 0block, so every.rawivwrite leaked theFILE*.Effects
fseeks before each scanline, which flushes the stdio buffer, so only the last scanline stayed unflushed. A read in the same process (or any reader before exit) saw zeros there.test_volume_rawiv_roundtripfailed on Windows, with aPermissionErrorwhileTemporaryDirectorycleaned up.RawivRoundTrippassed becauseexpect_volume_equalskips the far corner, citing "boundary-plane quantization on a full vertex-vs-cell round-trip". The missing close may be what that comment was seeing.Fix
fclose's result, since a late flush error only surfaces there.fcloseinside#if 0, so re-enabling that block can't double-close.The other volume writers (
.rawv,.mrc, spider, cvcraw) close properly. Their#if 0blocks contain no closes.Test
volume_io_testgainsRawivWriteFlushesEveryVoxelAndClosesTheFile. It reads back every voxel, the far corner included, then removes the file straight away.volume_io_test(26/26 on a quiet machine) andvolume_io_extra_test(54/54).test_pycvc.pypasses 15/15,test_volume_rawiv_roundtripincluded. A probe shows the file unlocked right aftersave().Unrelated, pre-existing
Run as one process on a loaded machine,
volume_io_testsometimes segfaults in the test afterCvcRawRoundTrip, whose backgroundbuild_hierarchythreads appear to outlive the test's app. It crashed 5/5 on this branch and 5/5 on an unmodified build of the main checkout under the same load, and it passes when run quietly. CI runs each gtest case in its own process (cvc_discover_tests), so it doesn't show up there. Tracked separately.