Closed naoki-mizuno closed 1 week ago
@naoki-mizuno 報告ありがとうございます.複数の環境で試していますが私の方では再現していません.私の方で再現するか,新しい情報の報告があれば解決に取り組みたいと思います.
I had the same issue. I tried to build in debug to get a stack trace, however, that already fixed it. So for me, a clean build was the solution.
I tried building the latest master
s (https://github.com/yoshito-n-students/gazebo_continuous_track/commit/6b8023e10173dd929d83008abd32d5aa910162f4, https://github.com/yoshito-n-students/gazebo_continuous_track_example/commit/9dc578dea640d3147278bfff0a5754aed0ea4145), and found that if I build with build type Release I get a segfault, but if I build with Debug I don't.
@yoshito-okada Could you try building with -DCMAKE_BUILD_TYPE=Release
and see if it crashes in your environment as well?
FYI my environment is:
I can confirm this behavior, in Debug
in runs fine, in Release
it crashes. I am on the same environment as @naoki-mizuno.
Thank you for interesting reports! Confirmed too on Ubuntu 18.04 + Gazebo 9.
Also, I found that the returned value of sdf::initFile() became invalid when Release
. I will look further this problem and get back here when I find something new.
https://github.com/yoshito-n-students/gazebo_continuous_track/blob/6b8023e10173dd929d83008abd32d5aa910162f4/include/gazebo_continuous_track/gazebo_continuous_track_simple.hpp#L166
I do not have a setup of this plugin but based on the information @yoshito-okada and @Martin-Oehler gathered I assume that the problem is that GZ_ASSERT evaluates to BOOST_ASSERT_MSG(expr, msg)
(see here) which evaluates by default (can be changed with defines) to assert((expr) && (msg))
(see here).
And that evaluates to ((void)0)
if NDEBUG
is defined as documented here.
Hence, all these statements in the asserts are not executed if NDEBUG
is defined which is the case for Release
or RelWithDebInfo
builds.
You should use a temp variable:
bool init_sdf_successful = sdf::initFile(ros::package::getPath("gazebo_continuous_track") +
"/sdf/continuous_track_simple_plugin.sdf", fmt);
GZ_ASSERT(init_sdf_succesful, "Cannot initialize sdf by continuous_track_simple_plugin.sdf");
This way the statement will be executed in any case.
I would suggest running grep -r GZ_ASSERT
and/or grep -ir assert
in the repo to find other potential erroneous assert statements.
Thank you, @StefanFabian ! I wrongly expected GZ_ASSERT
to trap an unrecoverable error regardless of Release
or Debug
.
@Martin-Oehler @naoki-mizuno
To evaluate a condition and report an fatal error on loading a plugin to gzserver
, I would change GZ_ASSERT(condition, msg)
to if(condition) gzthrow(msg);
. How do you like this change? I already confirmed this change worked for the ContinuousTrackSimple
plugin in Release
. Also, I guess gzserver
will properly handle an exception from a plugin because a test case exists in the official repo.
@yoshito-okada If you can push those changes to gazebo_continuous_track
I can check if the problem is fixed in my environments.
以前ROSConJP会場で相談していたプラグインロード時にgzserverが落ちる問題ですが,Melodic + Gazebo 9.11.0でも発生しました.Kinetic + Gazebo 7.16.0でも同じ問題が発生しています.
と言っても「落ちる」以外のデバッグに使えそうな情報が今のところないので,とりあえずIssueだけ立てておきます...
環境