Skip to content

BUG: Return child preflight errors from ReadH5Ebsd without a crash - #1968

Closed
imikejackson wants to merge 1 commit into
BlueQuartzSoftware:developfrom
imikejackson:fix/read_h5ebsd_preflight_errors
Closed

imikejackson wants to merge 1 commit into
BlueQuartzSoftware:developfrom
imikejackson:fix/read_h5ebsd_preflight_errors

Conversation

@imikejackson

Copy link
Copy Markdown
Contributor

Summary

Read H5EBSD File crashed when the file stores a sample or Euler transformation that the rotation filter it calls rejects. ReadH5Ebsd::operator() forwarded the preflight errors of Rotate Euler Reference Frame and Rotate Sample Reference Frame by calling errors() on a default Result<>. A default Result<> holds a success, so errors() on it is undefined behavior: a Debug build asserts in expected::error(), and a Release build writes through stack memory and the process stops with a bus error (SIGBUS) or a stack-protector abort. Both places now return the child errors as an error Result, as the same function already does for child execute errors. 2 files changed, +49 / −12 lines.

The crash occurs only when the child preflight fails. Example: a stored SampleTransformationAngle of 45 degrees, which Rotate Sample Reference Frame rejects because it is not a lossless grid rotation. A 90-degree rotation passes the child preflight and is not affected. Rotate Sample Reference Frame itself returns the correct error; only the forwarding in Read H5EBSD File was wrong.

Change

  • src/Plugins/OrientationAnalysis/src/OrientationAnalysis/Filters/Algorithms/ReadH5Ebsd.cpp — both child-preflight failure branches return {nonstd::make_unexpected(preflightResult.outputActions.errors())}.
  • src/Plugins/OrientationAnalysis/test/ReadH5EbsdTest.cpp — new test OrientationAnalysis::ReadH5Ebsd: Child preflight errors. It copies the 6_5_h5ebsd_exemplar test file to the test output directory and changes its stored transform: 45 degrees about (0, 0, 1) for the sample transform, and a zero Euler-transform axis. Execute must return exactly one error, -6850 from Rotate Sample Reference Frame or -96200 from Rotate Euler Reference Frame.

Test plan

  • Before the fix, the new test stops with a bus error.
  • macOS Release in-core (DREAM3D-NX build): OrientationAnalysis::ReadH5Ebsd tests pass (6/6).
  • macOS Release out-of-core (SIMPLNX_TEST_ALGORITHM_PATH=1): the same tests pass (6/6).
  • A Debug build of nxrunner with a 45-degree sample transform stopped at the expected::error() assertion in ReadH5Ebsd.cpp before the fix.
  • clang-format 19.1.1 is clean on both changed files.
  • CI passes on all platforms.

Related Issue

  • This PR has no related issue

ReadH5Ebsd forwarded the preflight errors of RotateEulerRefFrame and
RotateSampleRefFrame by calling errors() on a default (valid) Result<>.
That is undefined behavior: a Debug build asserts, and a Release build
writes through stack memory and crashes. A stored sample transform that
is not a lossless grid rotation, such as 45 degrees about Z, triggered
it. ReadH5Ebsd now returns the child errors as an error Result.

Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
@imikejackson imikejackson self-assigned this Nov 12, 2026
@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