Skip to content

Fix out-of-bounds read in GCP core_vertex_ids - #284

Merged
zfergus merged 4 commits into
mainfrom
fix/gcp-core-vertex-ids
Nov 2, 2026
Merged

zfergus merged 4 commits into
mainfrom
fix/gcp-core-vertex-ids

Conversation

@zfergus

@zfergus zfergus commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Description

Fixes an out-of-bounds read in GCPCollisionTemplate::core_vertex_ids().

  • The function indexed m_vertex_ids (one entry per vertex, 4 for Edge3-Edge3) with DOF indices that run up to 11.
  • The only caller, TangentialCollisions::build, reads entries 0-3, so the out-of-range values were never used.
  • Under -D_GLIBCXX_ASSERTIONS, std::vector::operator[] aborts on the read.
  • It now maps each core point to its vertex slot: the core points of primitive A, then those of primitive B.
  • finitediff_finitediff gets EIGEN_DONT_VECTORIZE=1 when SIMD is on, like MeshFEMSparse, so matrices our lambdas return and finite-diff reshapes or frees share one alignment.
  • Bumps the scalable-ccd pin.

API changes

  • core_vertex_ids() returns std::array<index_t, N_CORE_POINTS> instead of std::array<index_t, N_CORE_DOFS>.
  • TangentialCollisions::build is the only caller in the codebase and is unaffected.

Type of change

  • Bug fix (non-breaking change which fixes an issue)

How Has This Been Tested?

  • Full suite (429 tests) in Debug with -D_GLIBCXX_ASSERTIONS passes.
  • Smooth friction force no_mu and no_contact_force_multiplier, Smooth friction force jacobian 3D, and Smooth friction force jacobian of a single collision aborted at stl_vector.h:1282 in core_vertex_ids before this change and pass after it.
cmake -B build -DIPC_TOOLKIT_BUILD_TESTS=ON -DCMAKE_BUILD_TYPE=Debug \
    -DCMAKE_CXX_FLAGS=-D_GLIBCXX_ASSERTIONS -DSIMD_CXX_FLAGS=-march=x86-64-v3
cmake --build build -j && ctest --test-dir build -j

Test Configuration:

  • OS and Version: CachyOS Linux (kernel 7.2.3, glibc 2.44)
  • Compiler and Version: GCC 15.3.0

Checklist

  • I have followed the project style guide
  • My code follows the clang-format style guidelines of this project
  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • Any dependent changes have been merged and published in downstream modules

zfergus and others added 4 commits November 1, 2026 19:45
- Map each core point to its vertex slot instead of indexing the vertex ids with DOF indices
- Return one id per core point (N_CORE_POINTS) rather than per DOF

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
- Define EIGEN_DONT_VECTORIZE on finite-diff when SIMD is on, as for MeshFEMSparse
- Avoids alignment and allocator mismatches on matrices that cross the library boundary

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
lcov 2.4 on ubuntu-26.04 reports an unhit deleting destructor as an
inconsistency, which fails the --remove step.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@codecov

codecov Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 96.76%. Comparing base (b9d0325) to head (6c8f9da).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #284      +/-   ##
==========================================
- Coverage   96.97%   96.76%   -0.22%     
==========================================
  Files         221      221              
  Lines       22426    22502      +76     
  Branches     1540     1559      +19     
==========================================
+ Hits        21748    21774      +26     
- Misses        678      728      +50     
Flag Coverage Δ
unittests 96.76% <100.00%> (-0.22%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@zfergus
zfergus marked this pull request as ready for review November 2, 2026 03:02
@zfergus
zfergus merged commit 888e552 into main Nov 2, 2026
19 checks passed
@zfergus
zfergus deleted the fix/gcp-core-vertex-ids branch November 2, 2026 03:02
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