Skip to content

[LinearSystem] MatrixProjectionMethod: Fix out-of-bounds matrix writes - #6256

Open
fredroy wants to merge 1 commit into
sofa-framework:masterfrom
fredroy:fix_matrixprojectionmethod
Open

[LinearSystem] MatrixProjectionMethod: Fix out-of-bounds matrix writes#6256
fredroy wants to merge 1 commit into
sofa-framework:masterfrom
fredroy:fix_matrixprojectionmethod

Conversation

@fredroy

@fredroy fredroy commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

MatrixProjectionMethod::addMappedMatrixToGlobalMatrixEigen iterated over the cartesian product of the union of both mechanical states' top-most ancestors, instead of inputs1 x inputs2.
For the resulting spurious pairs no Jacobian exists, and computeProjection silently falls back to an unprojected block whose dimensions belong to the mapped state, written at the global offsets of an unrelated state.

[with-all-tests]

[ci-depends-on https://github.com/sofa-framework/Regression/pull/126]


By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).


Reviewers will merge this pull-request only if

  • it builds with SUCCESS for all platforms on the CI.
  • it does not generate new warnings.
  • it does not generate new unit test failures.
  • it does not generate new scene test failures.
  • it does not break API compatibility.
  • it is more than 1 week old (or has fast-merge label).

@fredroy fredroy added pr: fix Fix a bug pr: fast merge Minor change that can be merged without waiting for the 7 review days pr: status to review To notify reviewers to review this pull-request pr: AI-aided Label notifying the reviewers that part or all of the PR has been generated with the help of an AI labels Aug 24, 2026
@fredroy
fredroy requested a review from alxbilger August 25, 2026 00:14
@fredroy
fredroy force-pushed the fix_matrixprojectionmethod branch from e482fad to 2b0c0df Compare August 25, 2026 01:36
@fredroy

fredroy commented Aug 25, 2026

Copy link
Copy Markdown
Contributor Author

for windows....
[ci-build][with-all-tests]

@sofabot

sofabot commented Aug 25, 2026

Copy link
Copy Markdown
Collaborator

[ci-depends-on] detected during build #4.

To unlock the merge button, you must

@alxbilger

Copy link
Copy Markdown
Contributor

Strongly related to #6222

@alxbilger alxbilger 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.

I am afraid Claude is wrong!

Consider a spring that has 2 input mapped states resulting into 2 mapping jacobian matrices: $J_1$ and $J_2$. The cartesian product suggested by Claude would lead to the pairs $(J_1, J_2)$, while the previous code would lead to $(J_1,J_1)$, $(J_1,J_2)$, $(J_2,J_1)$, $(J_2,J_2)$. The latter is the correct solution. It would lead to $J_1^T K J_1$, $J_1^T K J_2$, $J_2^T K J_1$, $J_2^T K J_2$, i.e. the totality of the coupling terms.

I suggest to close this PR.

@alxbilger alxbilger removed the pr: fast merge Minor change that can be merged without waiting for the 7 review days label Aug 25, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr: AI-aided Label notifying the reviewers that part or all of the PR has been generated with the help of an AI pr: fix Fix a bug pr: status to review To notify reviewers to review this pull-request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants