Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[sap] Avoid factoring ununitialized memory #21430

Merged
merged 1 commit into from
May 14, 2024

Conversation

jwnimmer-tri
Copy link
Collaborator

@jwnimmer-tri jwnimmer-tri commented May 14, 2024

Hotfix for #21421:

[ RUN      ] DenseSuperNodalSolver.InterfaceTest
==20== Conditional jump or move depends on uninitialised value(s)
==20==    at 0x14A588: Eigen::LDLT<Eigen::Ref<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 0, Eigen::OuterStride<-1> >, 1>& Eigen::LDLT<Eigen::Ref<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 0, Eigen::OuterStride<-1> >, 1>::compute<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::EigenBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> > const&) (LDLT.h:517)
==20==    by 0x14A1A7: Eigen::LDLT<Eigen::Ref<Eigen::Matrix<double, -1, -1, 0, -1, -1>, 0, Eigen::OuterStride<-1> >, 1>::LDLT<Eigen::Matrix<double, -1, -1, 0, -1, -1> >(Eigen::EigenBase<Eigen::Matrix<double, -1, -1, 0, -1, -1> >&) (LDLT.h:137)
==20==    by 0x149A53: drake::multibody::contact_solvers::internal::DenseSuperNodalSolver::DenseSuperNodalSolver(std::vector<Eigen::Matrix<double, -1, -1, 0, -1, -1>, std::allocator<Eigen::Matrix<double, -1, -1, 0, -1, -1> > > const*, drake::multibody::contact_solvers::internal::BlockSparseMatrix<double> const*) (dense_supernodal_solver.cc:29)
==20==    by 0x11D5B2: drake::multibody::contact_solvers::internal::DenseSuperNodalSolver_InterfaceTest_Test::TestBody() (dense_supernodal_solver_test.cc:129)
...

This change is Reviewable

Thanks, valgrind!

Also respell the initializer list helpers for clarity.
@jwnimmer-tri jwnimmer-tri added priority: high status: single reviewer ok https://drake.mit.edu/reviewable.html labels May 14, 2024
@jwnimmer-tri
Copy link
Collaborator Author

@drake-jenkins-bot linux-jammy-clang-bazel-experimental-valgrind-memcheck please

@jwnimmer-tri jwnimmer-tri added the release notes: none This pull request should not be mentioned in the release notes label May 14, 2024
@jwnimmer-tri
Copy link
Collaborator Author

+@sherm1 for both reviews, please (follow-up from #21421).

\CC @amcastro-tri FYI

Copy link
Collaborator Author

@jwnimmer-tri jwnimmer-tri left a comment

Choose a reason for hiding this comment

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

Reviewable status: LGTM missing from assignee sherm1(platform)


multibody/contact_solvers/sap/dense_supernodal_solver.cc line 10 at r1 (raw file):

namespace internal {

int SafeGetCols(const BlockSparseMatrix<double>* J) {

FYI This dance was not necessary. The line J_(SafeDeference("J", J)), already proved that J was non-null; we don't need to re-check before calling J->cols().

@jwnimmer-tri
Copy link
Collaborator Author

@drake-jenkins-bot linux-jammy-clang-bazel-experimental-release please (flake)

Copy link
Member

@sherm1 sherm1 left a comment

Choose a reason for hiding this comment

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

:lgtm: x 2
Thanks, Jeremy!

Reviewed 1 of 1 files at r1, all commit messages.
Reviewable status: :shipit: complete! all discussions resolved, LGTM from assignee sherm1(platform)


multibody/contact_solvers/sap/dense_supernodal_solver.cc line 23 at r1 (raw file):

    : A_(SafeDeference("A", A)),
      J_(SafeDeference("J", J)),
      H_(Eigen::MatrixXd::Zero(J->cols(), J->cols())),

FYI attn @amcastro-tri
Is there any reason you want to leave H_ uninitialized? If so you'll need to rework this so it doesn't look at any of that uninitialized memory. For now we're going to set it to zero to fix CI but you can revisit later if it's important.

Copy link
Member

@sherm1 sherm1 left a comment

Choose a reason for hiding this comment

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

CI failure looks like an unrelated flake?

Reviewable status: :shipit: complete! all discussions resolved, LGTM from assignee sherm1(platform)

@jwnimmer-tri
Copy link
Collaborator Author

@drake-jenkins-bot linux-jammy-clang-bazel-experimental-everything-release please (flake)

@jwnimmer-tri jwnimmer-tri merged commit 216ac4c into RobotLocomotion:master May 14, 2024
11 checks passed
@jwnimmer-tri jwnimmer-tri deleted the supernodal-hotfix branch May 14, 2024 17:27
RussTedrake pushed a commit to RussTedrake/drake that referenced this pull request Dec 15, 2024
Thanks, valgrind!

Also respell the initializer list helpers for clarity.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
priority: high release notes: none This pull request should not be mentioned in the release notes status: single reviewer ok https://drake.mit.edu/reviewable.html
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants