From 8a7c5eeb672e9b0d334e996ec90f408ce9b21780 Mon Sep 17 00:00:00 2001 From: Justin Carpentier Date: Fri, 22 Dec 2023 09:57:05 +0100 Subject: [PATCH 1/3] algo/crba: add missing noalias() --- include/pinocchio/algorithm/crba.hxx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/include/pinocchio/algorithm/crba.hxx b/include/pinocchio/algorithm/crba.hxx index 6b788ac380..c3d8fb9b0b 100644 --- a/include/pinocchio/algorithm/crba.hxx +++ b/include/pinocchio/algorithm/crba.hxx @@ -77,7 +77,7 @@ namespace pinocchio jmodel.jointCols(data.Fcrb[i]) = data.Ycrb[i] * jdata.S(); /* M[i,SUBTREE] = S'*F[1:6,SUBTREE] */ - data.M.block(jmodel.idx_v(),jmodel.idx_v(),jmodel.nv(),data.nvSubtree[i]) + data.M.block(jmodel.idx_v(),jmodel.idx_v(),jmodel.nv(),data.nvSubtree[i]).noalias() = jdata.S().transpose()*data.Fcrb[i].middleCols(jmodel.idx_v(),data.nvSubtree[i]); const JointIndex & parent = model.parents[i]; From 13d0129c278bfebcdd38b188a08f821798641dd7 Mon Sep 17 00:00:00 2001 From: Justin Carpentier Date: Fri, 22 Dec 2023 10:21:46 +0100 Subject: [PATCH 2/3] test/crba: add malloc test for debug mode --- unittest/crba.cpp | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/unittest/crba.cpp b/unittest/crba.cpp index 8073ef4780..e05dc26f81 100644 --- a/unittest/crba.cpp +++ b/unittest/crba.cpp @@ -10,6 +10,10 @@ * */ +#ifndef EIGEN_RUNTIME_NO_MALLOC + #define EIGEN_RUNTIME_NO_MALLOC +#endif + #include "pinocchio/multibody/model.hpp" #include "pinocchio/multibody/data.hpp" #include "pinocchio/algorithm/crba.hpp" @@ -158,5 +162,24 @@ BOOST_AUTO_TEST_CASE(test_minimal_crba) } +#ifndef NDEBUG + +BOOST_AUTO_TEST_CASE(test_crba_malloc) +{ + using namespace pinocchio; + pinocchio::Model model; + pinocchio::buildModels::humanoidRandom(model); + + model.addJoint(size_t(model.njoints-1), pinocchio::JointModelRevoluteUnaligned(SE3::Vector3::UnitX()), SE3::Random(), "revolute_unaligned"); + pinocchio::Data data(model); + + const Eigen::VectorXd q = pinocchio::neutral(model); + Eigen::internal::set_is_malloc_allowed(false); + crba(model, data, q); + Eigen::internal::set_is_malloc_allowed(true); +} + +#endif + BOOST_AUTO_TEST_SUITE_END () From 27b0db5763662e96690cb93a87f9d838fbf404b0 Mon Sep 17 00:00:00 2001 From: Justin Carpentier Date: Fri, 22 Dec 2023 10:25:12 +0100 Subject: [PATCH 3/3] changelog: update --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 97debeb318..072d9c119f 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/). - Fix missing include for Boost >= 1.83 ([#2103](https://github.com/stack-of-tasks/pinocchio/pull/2103)) - Remove f-strings to fix install with python 2 ([#2110](https://github.com/stack-of-tasks/pinocchio/pull/2110)) - CMake: stop exporting CppAd/cppadcodegen & fetch submodule if not available ([#2112](https://github.com/stack-of-tasks/pinocchio/pull/2112)) +- Fix malloc issue in CRBA algo ([#2126](https://github.com/stack-of-tasks/pinocchio/pull/2126)) ## [2.6.21] - 2023-11-27