gz-sim icon indicating copy to clipboard operation
gz-sim copied to clipboard

INTEGRATION_thruster has undefined behavior potentially causing test flakiness

Open azeey opened this issue 1 year ago • 4 comments

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();

azeey avatar Jan 17 '24 15:01 azeey

can I work on this issue ?

GauravKumar9920 avatar Feb 14 '24 19:02 GauravKumar9920

Yes, please!

azeey avatar Feb 14 '24 21:02 azeey

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) ?

GauravKumar9920 avatar Feb 15 '24 09:02 GauravKumar9920

Hi @GauravKumar9920, this issue is not about code style, but that accessing std::vector::back on an empty vector could cause a crash.

azeey avatar Feb 15 '24 16:02 azeey