Skip to content

BUG: Check the Phase of Interest and its crystal structure in Write GBCD GMT - #1970

Closed
imikejackson wants to merge 1 commit into
BlueQuartzSoftware:developfrom
imikejackson:fix/writegbcdgmt-crystal-structure-check
Closed

imikejackson wants to merge 1 commit into
BlueQuartzSoftware:developfrom
imikejackson:fix/writegbcdgmt-crystal-structure-check

Conversation

@imikejackson

@imikejackson imikejackson commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Write GBCD Pole Figure (GMT 5) indexed ebsdlib::LaueOps::GetAllOrientationOps() with CrystalStructures[PhaseOfInterest] without a check (WriteGBCDGMTFile.cpp, operator()()). Phase 0 always holds 999 (UnknownCrystalStructure), so Phase of Interest = 0, or any phase with an unknown crystal structure, read past the end of the vector and dereferenced garbage. On develop the new test crashes with a segmentation fault. The phase was also used to index the cached Crystal Structures without a check against that array's tuple count.

Changes:

  • New WriteGBCDGMTFile::ValidatePhaseOfInterest(), which preflightImpl() and the algorithm's operator()() both call. Preflight can see the parameter and the tuple counts, but not the array values, so it rejects phase 0 (the Unknown phase) and phases that either array does not hold.
  • The algorithm checks the Crystal Structures value of the phase against GetAllOrientationOps().size() before it indexes the operations. Preflight cannot read array values, so this check runs in execute.
Code Where Failure
-96715 (new) preflight and algorithm Phase of Interest is 0 or negative
-96712 (existing, unchanged condition) preflight and algorithm Phase of Interest not in the GBCD array; the message now names the array
-96716 (new) preflight and algorithm Phase of Interest not in the Crystal Structures array
-96717 (new) algorithm Crystal structure of the Phase of Interest has no Laue operations (for example 999)

The -96715 and -96716 checks also fix the phase-range part of #1873 WriteGBCDGMTFileFilter#4 (negative phase, and a phase past the shorter ensemble array), because the crash and those checks are on the same line.

Other unchecked GetAllOrientationOps() indexes in OrientationAnalysis

I audited every OrientationAnalysis algorithm that indexes the orientation-ops vector. Each one checks its index before use except these sites. All of them are in the EBSD readers' preflight phase summary and are a different defect (a file value, not a Crystal Structures array value), so they are not in this PR:

Overlap with open pull requests

Existing branches

I checked every branch on origin and fork for commits not in develop that touch the changed files. None fixes this item. The only other branch that touches them is fix/orientation-axis-direction-validation (#1969, misorientation axis validation, different hunks).

Test Plan

  • New test OrientationAnalysis::WriteGBCDGMTFileFilter: Phase and Laue Index Bounds fails on develop (0cd2009): preflight accepts phase 0 and a phase missing from Crystal Structures, and the Unknown crystal structure case ends with SegFault. It passes with this change.
  • Full Write GBCD GMT test set passes, 5/5: ctest -R "OrientationAnalysis::WriteGBCDGMTFileFilter".
  • Linux x64, Release, Ninja, in-core build. Synthetic data written by the test; no new data archives.
  • Out-of-core validation NOT run (no out-of-core build on this machine). A maintainer needs to run the dual-build protocol.
  • Skills that could not be loaded (not available in this environment): bluequartz-skills:cpp-best-practices, bluequartz-skills:simplnx-best-practices, filter-implementation, implement-filter-tests, error-messages, dual-build-protocol, clang-format, github-workflow. docs/Coding_Knowledge_Base.md was followed instead.

Related Issue

Related to #1879 (item WriteGBCDGMTFileFilter#5) and #1873 (item WriteGBCDGMTFileFilter#4, phase range).

🤖 Generated with Claude Code

…BCD GMT

- WriteGBCDGMTFile indexed GetAllOrientationOps() with the Crystal Structures
  value of the Phase of Interest without a check. Phase 0, whose value is 999
  (Unknown), or any phase with an unknown crystal structure read past the end
  of the vector and crashed.
- The Phase of Interest was also used to index Crystal Structures without a
  check against its tuple count.
- New ValidatePhaseOfInterest(), called by preflight and the algorithm, rejects
  a phase below 1 (-96715), a phase missing from the GBCD array (-96712,
  unchanged) and a phase missing from Crystal Structures (-96716).
- The algorithm returns -96717 when the crystal structure of the phase has no
  Laue operations, before it indexes them.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

@imikejackson

Copy link
Copy Markdown
Contributor Author

Closed in favor of #1973, which merges this branch (with its history) together with the other EBSD fixes that need the next EbsdLib release (BlueQuartzSoftware/EbsdLib#86). The branch is kept.

🤖 Generated with Claude Code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant