gazebosim / gazebo-classic

Gazebo classic. For the latest version, see https://github.com/gazebosim/gz-sim
http://classic.gazebosim.org/
Other
1.16k stars 476 forks source link

Crash after deleting simple gripper in paused state #1448

Open osrf-migration opened 9 years ago

osrf-migration commented 9 years ago

Original report (archived issue) by Ian Chen (Bitbucket: Ian Chen, GitHub: iche033).


Only happens when you try to run simulation again after deleting the model in paused state

Steps to reproduce

  1. Insert simple gripper

  2. pause simulation

  3. delete the simple gripper (select it and press del key)

  4. play simulation -> crash

osrf-migration commented 9 years ago

Original comment by Ian Chen (Bitbucket: Ian Chen, GitHub: iche033).


backtrace

(gdb) r --verbose
Starting program: /home/ian/local/bin/gzserver --verbose
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
[New Thread 0x7fffdc3fa700 (LWP 31326)]
Gazebo multi-robot simulator, version 5.0.0
Copyright (C) 2012-2014 Open Source Robotics Foundation.
Released under the Apache 2 License.
http://gazebosim.org

[New Thread 0x7fffdb930700 (LWP 31327)]
[New Thread 0x7fffdb12f700 (LWP 31328)]
[Msg] Waiting for master.
[Msg] Connected to gazebo master @ http://127.0.0.1:11345
[Msg] Publicized address: 172.23.1.93
[New Thread 0x7fffda722700 (LWP 31329)]
[New Thread 0x7fffd3598700 (LWP 31330)]
[New Thread 0x7fffd2d97700 (LWP 31331)]
[New Thread 0x7fffd2596700 (LWP 31332)]
[New Thread 0x7fffd1d95700 (LWP 31333)]
[New Thread 0x7fffd1594700 (LWP 31334)]
[New Thread 0x7fffd0d93700 (LWP 31335)]
[New Thread 0x7fffb7fff700 (LWP 31336)]
[New Thread 0x7fffb77fe700 (LWP 31337)]
[New Thread 0x7fffb6dfd700 (LWP 31342)]
[New Thread 0x7fffb65fb700 (LWP 31344)]
[New Thread 0x7fffb69fc700 (LWP 31343)]
[New Thread 0x7fffb61fa700 (LWP 31345)]
[New Thread 0x7fffb59f8700 (LWP 31347)]
[New Thread 0x7fffb5df9700 (LWP 31346)]
[New Thread 0x7fffb55f7700 (LWP 31348)]
[New Thread 0x7fffb51f6700 (LWP 31356)]
[New Thread 0x7fffb49f5700 (LWP 31357)]
[New Thread 0x7fff7ffff700 (LWP 31358)]
[New Thread 0x7fff7f7fe700 (LWP 31359)]
gzserver: /usr/include/boost/smart_ptr/shared_ptr.hpp:653: typename boost::detail::sp_member_access<T>::type boost::shared_ptr<T>::operator->() const [with T = gazebo::physics::SurfaceParams; typename boost::detail::sp_member_access<T>::type = gazebo::physics::SurfaceParams*]: Assertion `px != 0' failed.

Program received signal SIGABRT, Aborted.
[Switching to Thread 0x7fff7ffff700 (LWP 31358)]
0x00007ffff49e2bb9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56  ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0  0x00007ffff49e2bb9 in __GI_raise (sig=sig@entry=6) at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007ffff49e5fc8 in __GI_abort () at abort.c:89
#2  0x00007ffff49dba76 in __assert_fail_base (fmt=0x7ffff4b2d2b0 "%s%s%s:%u: %s%sAssertion `%s' failed.\n%n", 
    assertion=assertion@entry=0x7ffff1feb0c0 "px != 0", 
    file=file@entry=0x7ffff1feb250 "/usr/include/boost/smart_ptr/shared_ptr.hpp", line=line@entry=653, 
    function=function@entry=0x7ffff1ff5540 <boost::shared_ptr<gazebo::physics::SurfaceParams>::operator->() const::__PRETTY_FUNCTION__> "typename boost::detail::sp_member_access<T>::type boost::shared_ptr<T>::operator->() const [with T = gazebo::physics::SurfaceParams; typename boost::detail::sp_member_access<T>::type = gazebo::physics"...) at assert.c:92
#3  0x00007ffff49dbb22 in __GI___assert_fail (assertion=0x7ffff1feb0c0 "px != 0", 
    file=0x7ffff1feb250 "/usr/include/boost/smart_ptr/shared_ptr.hpp", line=653, 
    function=0x7ffff1ff5540 <boost::shared_ptr<gazebo::physics::SurfaceParams>::operator->() const::__PRETTY_FUNCTION__> "typename boost::detail::sp_member_access<T>::type boost::shared_ptr<T>::operator->() const [with T = gazebo::physics::SurfaceParams; typename boost::detail::sp_member_access<T>::type = gazebo::physics"...) at assert.c:101
#4  0x00007ffff1fd4183 in boost::shared_ptr<gazebo::physics::SurfaceParams>::operator-> (this=<optimized out>)
    at /usr/include/boost/smart_ptr/shared_ptr.hpp:653
#5  0x00007ffff1fdf3a9 in operator-> (this=<optimized out>)
    at /home/ian/depot/clones/gazebo4/gazebo/physics/ode/ODEPhysics.cc:930
#6  gazebo::physics::ODEPhysics::Collide (this=this@entry=0xf3e280, _collision1=0x7fff7801a6a0, _collision2=0xfd59c0, 
    _contactCollisions=0x1027350) at /home/ian/depot/clones/gazebo4/gazebo/physics/ode/ODEPhysics.cc:829
#7  0x00007ffff1fdf510 in gazebo::physics::ODEPhysics::UpdateCollision (this=0xf3e280)
    at /home/ian/depot/clones/gazebo4/gazebo/physics/ode/ODEPhysics.cc:382
#8  0x00007ffff73dbc51 in gazebo::physics::World::Update (this=this@entry=0xf30290)
    at /home/ian/depot/clones/gazebo4/gazebo/physics/World.cc:686
#9  0x00007ffff73e566b in gazebo::physics::World::Step (this=this@entry=0xf30290)
    at /home/ian/depot/clones/gazebo4/gazebo/physics/World.cc:608
#10 0x00007ffff73e5b2d in gazebo::physics::World::RunLoop (this=0xf30290)
    at /home/ian/depot/clones/gazebo4/gazebo/physics/World.cc:452
#11 0x00007ffff5c2ea4a in ?? () from /usr/lib/x86_64-linux-gnu/libboost_thread.so.1.54.0
#12 0x00007ffff6a6f182 in start_thread (arg=0x7fff7ffff700) at pthread_create.c:312
#13 0x00007ffff4aa6efd in clone () at ../sysdeps/unix/sysv/linux/x86_64/clone.S:111
osrf-migration commented 9 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


I think the following will fix it:

diff -r c0c02ff2f40f49b90e2b7192f8f9876a1b29a4eb gazebo/physics/ode/ODEPhysics.cc
--- a/gazebo/physics/ode/ODEPhysics.cc  Mon Feb 09 21:41:10 2015 -0800
+++ b/gazebo/physics/ode/ODEPhysics.cc  Tue Feb 10 17:28:50 2015 -0800
@@ -810,15 +810,30 @@
 void ODEPhysics::Collide(ODECollision *_collision1, ODECollision *_collision2,
                          dContactGeom *_contactCollisions)
 {
+  if (!_collision1 || !_collision2)
+  {
+    // Invalid Collision pointers.
+    return;
+  }
+
+  ODESurfaceParamsPtr surf1 = _collision1->GetODESurface();
+  ODESurfaceParamsPtr surf2 = _collision2->GetODESurface();
+
+  if (!surf1 || !surf2)
+  {
+    // Invalid SurfaceParams pointers.
+    return;
+  }
+
   // Filter collisions based on contact bitmask if collide_without_contact is
   // on.The bitmask is set mainly for speed improvements otherwise a collision
   // with collide_without_contact may potentially generate a large number of
   // contacts.
-  if (_collision1->GetSurface()->collideWithoutContact ||
-      _collision2->GetSurface()->collideWithoutContact)
+  if (surf1->collideWithoutContact ||
+      surf2->collideWithoutContact)
   {
-    if ((_collision1->GetSurface()->collideWithoutContactBitmask &
-         _collision2->GetSurface()->collideWithoutContactBitmask) == 0)
+    if ((surf1->collideWithoutContactBitmask &
+         surf2->collideWithoutContactBitmask) == 0)
     {
       return;
     }
@@ -888,9 +903,6 @@
                          dContactSlip1 |
                          dContactSlip2;

-  ODESurfaceParamsPtr surf1 = _collision1->GetODESurface();
-  ODESurfaceParamsPtr surf2 = _collision2->GetODESurface();
-
   // Compute the CFM and ERP by assuming the two bodies form a
   // spring-damper system.
   double kp = 1.0 / (1.0 / surf1->kp + 1.0 / surf2->kp);
osrf-migration commented 9 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


We should write a test that fails without the fix, then apply the fix.

osrf-migration commented 9 years ago

Original comment by Steve Peters (Bitbucket: Steven Peters, GitHub: scpeters).


osrf-migration commented 7 years ago

Original comment by Nate Koenig (Bitbucket: Nathan Koenig).


AstroStucky commented 4 months ago

I can confirm this is still an issue in version 11.14.0. In my testing the crash occurs sporadically, so you have to reattempt the procedure until it happens.