Fix volatile correctness in lazy load and add roundtrip test#1747
Open
ken-swyfft wants to merge 2 commits intonissl-lab:masterfrom
Open
Fix volatile correctness in lazy load and add roundtrip test#1747ken-swyfft wants to merge 2 commits intonissl-lab:masterfrom
ken-swyfft wants to merge 2 commits intonissl-lab:masterfrom
Conversation
- Add volatile to _worksheetLoaded for correct double-checked locking on ARM/.NET platforms where memory ordering is weaker than x86 - Add SaveWithoutAccessPreservesUntouchedSheets test verifying that opening a workbook, modifying one sheet, and saving preserves untouched sheets' data through the lazy load Commit() early-return Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
…s/20260321_lazy-load-volatile-and-roundtrip-test
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
Follow-up to #1741 (Sheet Lazy Loading):
Add
volatileto_worksheetLoaded— The double-checked locking pattern inEnsureWorksheetLoaded()reads_worksheetLoadedoutside the lock. Withoutvolatile, on ARM platforms (.NET on Apple Silicon, Graviton, etc.) the CPU's weaker memory ordering could allow a thread to see_worksheetLoaded = truebefore theworksheetfields are fully initialized. On x86/x64 this is a no-op due to strong ordering, so no perf impact.Add
SaveWithoutAccessPreservesUntouchedSheetstest — Creates a 3-sheet workbook, re-opens it, modifies only sheet 1, saves, and verifies sheets 0 and 2 survived the roundtrip with original data intact. This exercises thePrepareForCommit()andCommit()early-return paths that skip re-serialization of unaccessed sheets — the core value proposition of lazy loading.Test plan
TestXSSFSheetLazyLoadtests pass on both net8.0 and net472🤖 Generated with Claude Code