Repository navigation
BUG: Use one column count for a square-grid ANG file - #73
Closed
imikejackson wants to merge 1 commit into
Closed
imikejackson wants to merge 1 commit into
imikejackson wants to merge 1 commit into
Conversation
AngReader::readFile() sized the data arrays from NCOLS_ODD (or NCOLS_EVEN when NCOLS_ODD was not positive), reordered the data with NCOLS_ODD, and reported NCOLS_EVEN as the X dimension. A square-grid file without a NCOLS_ODD line crashed in the raster reorder, and a file with different NCOLS_ODD and NCOLS_EVEN values returned success with an X dimension that did not match the data. For a square grid, readFile() now resolves one column count before it reads the data and stores it in both values. Different positive values give error -120, and no positive value gives error -130. Signed-off-by: Michael Jackson <mike.jackson@bluequartz.net>
This was referenced Nov 13, 2026
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 |
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
AngReader::readFile()uses one column count for a square-grid.angfile. Before, the reader used three different values: it sized the data arrays fromNCOLS_ODD(or fromNCOLS_EVENwhenNCOLS_ODDwas not positive), it reordered the data to raster order withNCOLS_ODD, andgetXDimension()returnedNCOLS_EVEN. 2 files changed, +99 / −0 lines.# NCOLS_ODD:line kept the default value -1. The raster reorder converted it to a very large column count and read past the end of the arrays (crash).NCOLS_ODDandNCOLS_EVENboth positive but different returned success, andgetXDimension()did not match the number of points that were read. A caller that sizes its output fromgetXDimension()gets wrong data or reads past the arrays.For a square grid,
readFile()now resolves the column count before it reads the data:NCOLS_ODDandNCOLS_EVENare both positive and different, the read fails with error -120.NCOLS_ODDif it is positive, andNCOLS_EVENif not. If neither is positive, the read fails with error -130.NCOLS_ODDandNCOLS_EVEN, so the allocation, the raster reorder andgetXDimension()agree.Each error message names the file and both values. Hex-grid files,
readHeaderOnly()and the HDF5 readers do not change.This defect was found while reviewing BlueQuartzSoftware/simplnx#1967, which validates the ANG grid dimensions that simplnx uses.
Test plan
Source/Test/AngImportTest.cpp(SquareGridColumnsEvenOnly,SquareGridColumnsOddOnly,SquareGridColumnsMismatch,SquareGridColumnsNonpositive,SquareGridColumnsEqual) write small.angfiles and check the number of points, the X dimension, both column counts, the Phi1 values in written order, and the error codes and messages.EvenOnlycrashes (SIGSEGV),OddOnlygives X dimension -1,Mismatchreturns 0, andNonpositivereturns the raster error -101105. The equal-columns control passes.EbsdLib-Releasepreset): full test suite passes, 434/434.Related Issue