Validate optical-property vector sizes once, after parsing, not per token#158
Merged
maureeungaro merged 1 commit intoJun 13, 2026
Merged
Conversation
…oken getMaterialPropertyFromString appends one value per token in a while(!eof()) loop, and the cross-vector size validation block sat inside that loop, guarded by `if (propertyName == "rayleigh")`. On the first rayleigh token only one value has been pushed, so rayleigh.size()==1; for any real multi-point optical material (photonEnergy size > 1) the very first check fired ERR_GMATERIALOPTICALPROPERTYMISMATCH and aborted loading of valid, consistent data. Move the validation block out of the token loop so it runs once, after the full property vector has been parsed. propertyName is constant for the call and rayleigh is parsed last, so all other optical vectors are fully populated when the check runs. The check bodies are unchanged. Verified: the cherenkov optical example (photonEnergy/indexOfRefraction/ absorptionLength) still parses its material and runs to completion (Geant4 11.4.1 dev container). Fixes gemc#112 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
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.
getMaterialPropertyFromStringappends one value per token in awhile(!eof())loop, and the cross-vector size-validation block sat inside that loop, guarded byif (propertyName == "rayleigh"). On the first rayleigh token only one value has been pushed, sorayleigh.size() == 1; for any real multi-point optical material (photonEnergy size > 1) the very first check firedERR_GMATERIALOPTICALPROPERTYMISMATCHand aborted loading of valid, consistent data.Move the validation block out of the token loop so it runs once, after the full property vector has been parsed.
propertyNameis constant for the call and rayleigh is parsed last, so all other optical vectors are fully populated when the check runs. The check bodies are unchanged (a pure code-motion; the diff is large only because the block de-indents one level).Validation: the cherenkov optical example (which exercises the same
getMaterialPropertyFromStringparser for photonEnergy/indexOfRefraction/absorptionLength) still parses its material and runs to completion in the Geant4 11.4.1 dev container. Note: no in-tree example usesrayleigh, so the specific abort path can't be reproduced without authoring new material data.Fixes #112