Skip to content

BUG: Report an error for an empty or malformed EBSD phase table - #1971

Closed
imikejackson wants to merge 1 commit into
BlueQuartzSoftware:developfrom
imikejackson:fix/ebsd-reader-phase-table-checks
Closed

imikejackson wants to merge 1 commit into
BlueQuartzSoftware:developfrom
imikejackson:fix/ebsd-reader-phase-table-checks

Conversation

@imikejackson

@imikejackson imikejackson commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Two EBSD readers accepted a phase table that they could not use.

  • Read Oxford Instr. Channel 5 Data (.cpr/.crc): ReadChannel5Data::loadMaterialInfo() returned the reader's error code when the .cpr file listed no phases. That code is 0, so the filter continued with an uninitialized ensemble row 0 (Crystal Structures 0, which is Hexagonal_High, instead of 999 Unknown) and an empty Material Name. On develop the new test then fails with an exception: DataStructure::getDataRef(): Input Path 'DataContainer' does not exist. Preflight also accepted the file.
  • Read H5EBSD File: the ensemble loader (LoadInfo() in ReadH5Ebsd.cpp) read six values from getLatticeConstants() without checking the vector size, so a phase with fewer than six lattice constants was read out of bounds. The loop also wrote each phase at its phase index without a bound check, so a phase table with indices 1 and 3 wrote past the ensemble arrays. On develop the new test returns success for the short lattice-constant case and ends with SegFault for the phase-index case.

Changes:

Code Filter Where Failure
-66502 Read Oxford Instr. Channel 5 Data preflight and algorithm The .cpr [Phases] section lists no phases
-50028 Read H5EBSD File execute A phase has fewer than 6 lattice constants
-50029 Read H5EBSD File execute A phase index is outside 1 to the number of phases
  • Read H5EBSD File checks every phase before it writes any ensemble value. The check runs in execute because the preflight phase summary (GeneratePreflightPhaseInformation) is rewritten by BUG: Validate EBSD reader headers, scans and slice ranges #1967. After both merge, the check can move to preflight.
  • Valid input is unchanged: every existing test of both readers passes.

Overlap with open pull requests

  • BUG: Validate EBSD reader headers, scans and slice ranges #1967 (fix/ebsd-vv-filter-items) changes ReadChannel5Data.cpp (operator()()), ReadChannel5DataFilter.cpp (preflightImpl(), other hunks), ReadChannel5DataTest.cpp and ReadH5EbsdTest.cpp. I checked its diff: it does not fix either item. Its lattice-constant check is only for H5OIM and H5Esprit (IEbsdOemReader.hpp), and it does not touch loadMaterialInfo() or ReadH5Ebsd.cpp. This change is kept small; whichever of the two merges second rebases (the test files will conflict at the end).
  • BUG: Return child preflight errors from ReadH5Ebsd without a crash #1968 changes ReadH5Ebsd.cpp::operator()() (child preflight errors). No hunk overlaps.

Existing branches

I checked every branch on origin and fork for commits not in develop that touch the changed files. None fixes these items. Branches that touch the same files: fix/ebsd-vv-filter-items (#1967; ReadChannel5Data.cpp, ReadChannel5DataFilter.cpp and both test files), fix/read_h5ebsd_preflight_errors (#1968; ReadH5Ebsd.cpp operator()() and ReadH5EbsdTest.cpp), and topic/correct_feature_am_updates (#1913; one argument added in ReadH5Ebsd.cpp operator()() and ReadH5EbsdTest.cpp). None of them changes loadMaterialInfo() or the phase loop in LoadInfo().

Test Plan

  • New tests fail on develop (0cd2009) and pass with this change:
    • OrientationAnalysis::ReadChannel5Data: Empty phase list (filter preflight and execute, and the algorithm without the filter)
    • OrientationAnalysis::ReadH5Ebsd: Phase table validation (a phase with 3 lattice constants, and phase indices 1 and 3)
  • Full test sets pass, 12/12: ctest -R "OrientationAnalysis::(ReadChannel5Data|ReadH5Ebsd)".
  • Linux x64, Release, Ninja, in-core build. The tests write synthetic .cpr/.crc and .h5ebsd files with the existing fixture writers; 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 #1868 (item ReadChannel5DataFilter#3) and #1866 (item ReadH5EbsdFilter#4, both the lattice-constant and the phase-index parts).

🤖 Generated with Claude Code

- ReadChannel5Data::loadMaterialInfo() returned the reader's error code, 0,
  when the .cpr file listed no phases. The filter continued with an
  uninitialized ensemble row (Crystal Structures 0, Hexagonal_High, instead of
  999) and then failed with an exception. Preflight and execute now return
  -66502.
- ReadH5Ebsd read six lattice constants from each phase without checking the
  size of getLatticeConstants(), and wrote each phase at its phase index
  without checking it against the ensemble size. A phase with fewer than six
  lattice constants now returns -50028, and a phase index outside 1..N
  returns -50029, before any ensemble value is written.

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