Robot3d crashes on adding robot over YARP
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
Robot3D |
Fix Committed
|
High
|
Anne van Rossum |
Bug Description
Gdb does not report so much about the crash, valgrind gives this additional information:
Info: 23:19:24:
==3546== Invalid read of size 4
==3546== at 0x42EB6B9: dtGame:
==3546== by 0x42ECE9B: dtGame:
...
==3546== Address 0xb6bad40 is 8 bytes inside a block of size 32 free'd
==3546== at 0x4024851: operator delete(void*) (vg_replace_
==3546== by 0x42F37AC: std::vector<
_M_insert_
dtCore:
==3546== by 0x42E5BD6: dtGame:
==3546== by 0xBA6C01D: srInterface:
==3546== by 0xBA6B3F6: srInterface:
==3546== by 0xBA6A85E: srInterface:
==3546== by 0x42EB6DA: dtGame:
...
==3546== Invalid read of size 4
==3546== at 0x42EB6CF: dtGame:
==3546== by 0x42ECE9B: dtGame:
...
==3546== Address 0x0 is not stack'd, malloc'd or (recently) free'd
==3546== Process terminating with default action of signal 11 (SIGSEGV)
==3546== Access not within mapped region at address 0x0
==3546== at 0x42EB6CF: dtGame:
==3546== by 0x42ECE9B: dtGame:
The problem stems from the way Delta3D is set up. It might perhaps be called an actual bug... The actors in Delta3D can be created and removed on the fly. The components in Delta3D cannot. At least, if you add a component this should happen OUTSIDE of the ProcessMessage loop of another component.
It is namely the case that AddComponent invalidates the iterators in DoSendMessageTo Components calling either ProcessMessage multiple times on the same component, or worse, finding no component anymore at that location because the iterators have become invalid because of memory reallocation. This bug could only be reproduced by me in a 32-bit VM, and not on the 64-bit host, which might relate to either the different system libraries or more limited system resources.
The bug has been circumvented by using a separate thread to handle YARP messages like "ADD_ROBOT", sending a "pause simulator" game message, waiting till the component gets this message, sleeping a bit additionally (assuming that this would be enough to get this message to all components) and finally adding the component to the Robot3D simulator.
This bug might resurface when many robots are used (each with their own component).
More information: http:// www.delta3d. org/forum/ viewtopic. php?forum= 14&showtopic= 19848