gz-sim
gz-sim copied to clipboard
INTEGRATION_thruster has undefined behavior potentially causing test flakiness
Environment
- OS Version: Ubuntu 22.04
- Source or binary build? gz-sim7, 926923f6644ce1d2ef68316bb20432c88cd3b75e
Description
- Expected behavior: Code has no undefined behaviors
- Actual behavior:
std::vector::back
is potentially called on an empty vector in multiple places. This is regarded as undefined behavior. For example: https://github.com/gazebosim/gz-sim/blob/926923f6644ce1d2ef68316bb20432c88cd3b75e/test/integration/thruster.cc#L335-L340
The vector modelPoses
is cleared followed by auto latest_pose = modelPoses.back();
can I work on this issue ?
Yes, please!
hii, upon running the code check I found that this issue is persistent among many other similar files, like detachable_joint.cc, WindEffects.cc and many others, shall I fix most of them or just this one(thruster.cc) ?
Hi @GauravKumar9920, this issue is not about code style, but that accessing std::vector::back
on an empty vector could cause a crash.