Repository navigation
BUG: Report an error when a .cpr file defines no phases - #75
Closed
imikejackson wants to merge 1 commit into
Closed
imikejackson wants to merge 1 commit into
imikejackson wants to merge 1 commit into
Conversation
- Before: CprReader::readHeaderOnly() did not check the [Phases] Count value. When the key was missing, not an integer, or <= 0, the phase loop ran zero times and readHeaderOnly()/readFile() returned 0 with an empty phase vector. - After: a missing, unreadable or non-positive phase count returns -102300 with a message that names the .cpr file and the value. Files that define at least one phase are read as before. - Add CprReaderTest, which writes small .cpr/.crc pairs with and without phases. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
7 tasks done
Collaborator
Author
|
Closed in favor of #86, which merges this branch (with its history) together with the other open EbsdLib fixes for the next release, so simplnx can build against one EbsdLib branch. The branch is kept. 🤖 Generated with Claude Code |
Open
22 tasks
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
Callers take a crystal-structure value from a file (where
UnknownCrystalStructureis 999) or from a phase'sdetermineOrientationOpsIndex()and indexLaueOps::GetAllOrientationOps()with it. A value outside the vector reads out of bounds. EbsdLib had no range-checked accessor: the only static lookups wereGetAllOrientationOps()(unchecked vector) andGetLaueOpsFromSpaceGroupNumber()(takes a space-group number, not a crystal structure).GetLaueOpsFromSpaceGroupNumber()from BUG: Map space groups 1-230 to the correct Laue class #67:static LaueOps::Pointer LaueOps::GetOrientationOpsFromCrystalStructure(uint32_t crystalStructure)LaueOpssubclass asGetAllOrientationOps()[crystalStructure]for eachebsdlib::CrystalStructureconstant 0-10, andNullPointer()forLaueGroupEnd(11),UnknownCrystalStructure(999) and every other value.LaueGroupEnd(11) is rejected on purpose.GetAllOrientationOps()has a 12th entry (anOrthoRhombicOpslabelled "Axis OrthorhombicOps"), but 11 is the end marker of the Laue groups, not a crystal structure. Callers that want the legacy entry can still index the vector.GetAllOrientationOps()builds a new vector of 12 newly allocatedLaueOpsobjects on every call. The new accessor creates only the requested object.GetAllOrientationOps()with an unchecked value from a file: the readers'printSelf()already useGetLaueOpsFromSpaceGroupNumber()with a null check, andPoleFigureCompositor/DiscretePoleFigureCompositoralready comparelaueOpsIndexwith the vector size. The apps index it with literals. So no call sites change.Test Plan
EbsdLib::ebsdlib::LaueOpsTest::GetOrientationOpsFromCrystalStructure(inLaueOpsTest.cpp). Ondevelopit does not compile ('GetOrientationOpsFromCrystalStructure' is not a member of 'ebsdlib::LaueOps'): there is no checked accessor. With this change it passes. It checks every valid constant against an independent table of class names and againstGetAllOrientationOps(), and that 11, 12, 999 andUINT32_MAXreturn null. (LaueOpshas nogetCrystalStructure()method, so the test compares class names.)ctestsuite passes, FULL_COUNT.Related Issue
Related to BlueQuartzSoftware/simplnx#1867 (class C07e), BlueQuartzSoftware/simplnx#1879, and the unchecked index in simplnx
WriteGBCDGMTFile.cpp. simplnx can switch those call sites to this accessor once this is merged.Overlaps: open PRs #60, #61, #64 and #74 also change
LaueOps.cpp(and #60/#61LaueOps.handLaueOpsTest.cpp). This change only adds a function and a test case, so any conflict is textual; merge order does not matter.The
bluequartz-skillsskills (cpp-best-practices,simplnx-best-practices) could not be loaded in this environment; the repository's CLAUDE.md coding standards were followed.🤖 Generated with Claude Code