pantor / ruckig

Motion Generation for Robots and Machines. Real-time. Jerk-constrained. Time-optimal.
https://ruckig.com
MIT License
635 stars 155 forks source link

Fix out of bound iterator in tests #189

Open sciprosk opened 2 months ago

sciprosk commented 2 months ago

Hi everyone,

I was trying to build Ruckig w/ tests in Debug and got out-of-bound iterator access errors from some of the tests in inline void add_profile(ProfileIter& profile) in a couple of places that was captured by asserts in STL.

It looks like the issue is with reserving std::array<Profile, 3> being the size of 3, while the profile iterator can advance by three from valid_profiles.begin() and point to valid_profiles.end() when being dereferenced eventually.

I summarize these behavior in a couple of commits. It would be also nice to add an input validation into add_profile to fail early in Debug (should be stripped out in Release anyway).

Environment: Visual Studio Community 2022 Release - x86_amd64; MSVC 17.9.34728.123; Debug build.