Repository navigation
anari: fix crash on curves without primitive.index or vertex.radius - #87
Merged
iwald-nvidia merged 1 commit intoOct 26, 2026
Merged
Conversation
Both parameters are optional on 'curve' geometry (KHR_GEOMETRY_CURVE), but Curve::setBarneyParameters() dereferenced m_index unconditionally and Curve::bounds() dereferenced m_vertexRadius. A curve without an index crashed on the first render, and one without per-vertex radii crashed when the world bounds were queried. The ANARI SDK's test/random_curves scene, which has an unindexed curve with a global radius, segfaulted in both places. Without an index, every vertex except the last one now starts a segment, as in helide. Without per-vertex radii, the bounds use the global radius, as setBarneyParameters() already did. Add a pynari unit test that renders such a curve and checks the world bounds. Signed-off-by: Max Freedom Pollard <[email protected]> Co-Authored-By: Claude Opus 5.5 <[email protected]>
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.
primitive.indexandvertex.radiusare optional oncurvegeometry (onlyvertex.positionis required inKHR_GEOMETRY_CURVE, which barney advertises), butbarney/anari/Geometry.cppdereferences both without a null check:Curve::setBarneyParameters()readsm_index->totalSize()(line 636). A curve without an index segfaults on the first render, or on the first worldboundsquery, since that builds the model too.Curve::bounds()readsm_vertexRadius->beginAs<float>()(line 669). A curve that relies on the globalradiussegfaults when the worldboundsare queried.The ANARI SDK's
test/random_curvesscene, which has an unindexed curve with a global radius, crashes on both lines. So does this minimal pynari case:Fix
primitive.index, every vertex except the last one starts a segment, as in helide. Indexed curves are unchanged.Curve::bounds()uses the globalradius, under the same conditionsetBarneyParameters()already uses.unitTests/curve-optional-params.pyrenders such a curve and checks the world bounds and the covered pixels. It callsWorld.getBounds(), which is in pynarimasterbut not in the 1.4.0 release.Testing
I built
barney_cpu(Embree backend) on macOS arm64 with Apple clang 21, against ANARI-SDKmain(0.17.0). I built pynarimasteragainst the same SDK and loadedbarney_cputhroughANARI_LIBRARY. I ran each case onmain, with only one of the two hunks, and with the full fix:mainboundstest/random_curves: bounds, default camera, renderunitTests/curve-optional-params.pyThe existing
tests/*.shstill pass. I did not build or run the CUDA, OptiX or HIP backends because this machine has no GPU. The change is in the backend-independent ANARI layer.🤖 Generated with Claude Code