From 2b38148d2459eb6058686bfdb5828bea0683a551 Mon Sep 17 00:00:00 2001 From: Saran Tunyasuvunakool Date: Tue, 4 Jul 2023 08:25:10 -0700 Subject: [PATCH] Explicitly zero out `cinert` of the world body. Values of `cinert` are only set by `mj_comPos` for body 1 and above, which leaves the values for body 0 uninitialized. This triggers a `use-of-uninitialized-value` error under msan when the entire `cinert` array is read. PiperOrigin-RevId: 545453619 Change-Id: I7bfdb4e4e33677903fc90c6ad070490aa65bf464 --- src/engine/engine_core_smooth.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/engine/engine_core_smooth.c b/src/engine/engine_core_smooth.c index 6572f4f2..ea50fe0d 100644 --- a/src/engine/engine_core_smooth.c +++ b/src/engine/engine_core_smooth.c @@ -207,6 +207,9 @@ void mj_comPos(const mjModel* m, mjData* d) { } } + // zero out CoM frame inertia for the world body + mju_zero(d->cinert, 10); + // map inertias to frame centered at subtree_com for (int i=1; i < m->nbody; i++) { mju_sub3(offset, d->xipos+3*i, d->subtree_com+3*m->body_rootid[i]);