Skip to content

Fixes for issues pointed out by automated fuzzing - #620

Draft
stefanatwork wants to merge 31 commits into
masterfrom
sw/fuzzing_fixes
Draft

Fixes for issues pointed out by automated fuzzing#620
stefanatwork wants to merge 31 commits into
masterfrom
sw/fuzzing_fixes

Conversation

@stefanatwork

Copy link
Copy Markdown
Collaborator

Draft PR for easier review.

stefanatwork and others added 30 commits July 6, 2026 16:16
Clamp BVHBuilderMorton settings to MAX_BRANCHING_FACTOR when an oversized maxBranchingFactor is provided via RTCBuildArguments.\n\nAdd an integration test that exercises rtcBuildBVH with RTC_BUILD_QUALITY_LOW and maxBranchingFactor=64 to verify the Morton build path returns a valid root.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
* User facing API will return an error
* Internal API will thrown an exception
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR hardens Embree against a set of fuzzing-discovered edge cases (bounds/time-range handling, builder argument validation, and defensive guards in geometry traversal), and introduces a dedicated regression-test tutorial executable to prevent regressions.

Changes:

  • Add embree_regression_tests tutorial executable with targeted API/geometry regression cases.
  • Add multiple defensive checks across motion-blur bounds, grid leaf decoding, subdivision topology validation, curve index validation, and builder argument validation.
  • Minor formatting/whitespace cleanups in a few CMake/test files and headers.

Reviewed changes

Copilot reviewed 23 out of 24 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
tutorials/embree_regression_tests/embree_regression_tests.cpp New regression-test binary covering fuzzing-found edge cases.
tutorials/embree_regression_tests/CMakeLists.txt Builds/installs the new regression-test executable and registers it as a test.
tutorials/CMakeLists.txt Wires the new embree_regression_tests subdirectory into the tutorials build.
tests/integration/test_embree_release/test.cpp Removes trailing whitespace line.
tests/CMakeLists.txt Removes trailing whitespace line.
kernels/geometry/grid_soa.h Adds validation to guard against invalid leaf decoding.
kernels/geometry/grid_soa_intersector1.h Skips intersection/occlusion for invalid encoded grid leaves.
kernels/geometry/grid_soa_intersector_packet.h Same invalid-leaf guards for packet intersectors.
kernels/common/scene_subdiv_mesh.cpp Validates subdiv topology before half-edge initialization to prevent OOB.
kernels/common/scene_line_segments.h Fixes ddPdudu output writing to the wrong pointer.
kernels/common/scene_instance.cpp Adds guards for invalid time ranges/segments in bounds computations.
kernels/common/scene_instance_array.h Replaces asserts with defensive checks for object-id lookup.
kernels/common/scene_instance_array.cpp Adds bounds/object-id validation and range guards in instance-array code paths.
kernels/common/scene_curves.h Hardens curve index validation against overflow/underflow.
kernels/common/rtcore_builder.cpp Validates builder args (leaf size and branching factor per quality).
kernels/common/motion_derivative.h Adds recursion depth and max-root guards to avoid runaway recursion.
kernels/common/default.h Clamps/validates time segment range computation for invalid inputs.
kernels/common/accelset.h Validates time segment ranges before checking per-segment bounds.
kernels/builders/bvh_builder_msmblur.h Validates motion-blur primitive range before using it.
kernels/builders/bvh_builder_msmblur_hair.h Adds branching-factor upper-bound guard.
kernels/builders/bvh_builder_morton.h Adds branching-factor upper-bound guards in settings/builders.
kernels/builders/bvh_builder_hair.h Adds branching-factor upper-bound guard.
include/embree4/rtcore_common.h Whitespace/formatting-only adjustments.
common/math/lbbox.h Adds NaN/range validation and clamping to avoid invalid time-range bounds computation.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +203 to +206
if (this->numPrimitives == 1) {
object = objects[0];
if (object) { object->refInc(); }
}
Comment on lines +241 to +243
RTCScene child = createTriangleScene(device);
RTCScene top = rtcNewScene(device);
RTCGeometry inst = rtcNewGeometry(device, RTC_GEOMETRY_TYPE_INSTANCE);
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.

2 participants