Make msan treat mjData buffer as uninitialized in mj_resetData.
Indiscriminate memset into d->buffer and m->buffer previously caused msan to not detect uninitialized reads. Also fix tests with uninitialized read bugs that are detected by msan after this change. PiperOrigin-RevId: 451508224 Change-Id: I1f4b080a8ef765c34ba7a0adc2c686419f6e5516
This commit is contained in:
committed by
Copybara-Service
parent
ef9fa9dfe4
commit
185b79f664
@@ -909,6 +909,7 @@ Euler integrator, semi-implicit in velocity.
|
||||
def test_mj_ray(self):
|
||||
# mj_ray has tricky argument types
|
||||
geomid = np.zeros(1, np.int32)
|
||||
mujoco.mj_forward(self.model, self.data)
|
||||
mujoco.mj_ray(self.model, self.data, [0, 0, 0], [0, 0, 1], None, 0, 0,
|
||||
geomid)
|
||||
mujoco.mj_ray(self.model, self.data, [0, 0, 0], [0, 0, 1],
|
||||
|
||||
@@ -806,7 +806,13 @@ void MjDataWrapper::Serialize(std::ostream& output) const {
|
||||
#undef X
|
||||
|
||||
// Write buffer contents
|
||||
WriteBytes(output, ptr_->buffer, ptr_->nbuffer);
|
||||
{
|
||||
MJDATA_POINTERS_PREAMBLE((&this->metadata_))
|
||||
#define X(type, name, nr, nc) \
|
||||
WriteBytes(output, ptr_->name, sizeof(type)*(this->metadata_.nr)*(nc));
|
||||
MJDATA_POINTERS
|
||||
#undef X
|
||||
}
|
||||
}
|
||||
|
||||
MjDataWrapper MjDataWrapper::Deserialize(std::istream& input) {
|
||||
@@ -857,7 +863,13 @@ MjDataWrapper MjDataWrapper::Deserialize(std::istream& input) {
|
||||
#undef X
|
||||
|
||||
// Read buffer contents
|
||||
ReadBytes(input, d->buffer, d->nbuffer);
|
||||
{
|
||||
MJDATA_POINTERS_PREAMBLE((&m))
|
||||
#define X(type, name, nr, nc) \
|
||||
ReadBytes(input, d->name, sizeof(type)*(m.nr)*(nc));
|
||||
MJDATA_POINTERS
|
||||
#undef X
|
||||
}
|
||||
CheckInput(input, "mjData");
|
||||
|
||||
// All bytes should have been used.
|
||||
|
||||
Reference in New Issue
Block a user