The DrakeLcm object launches a thread, that by default is not stopped until the DrakeLcm destructor. Other classes might register "upon receipt of message" callbacks onto it, where DrakeLcm retains a pointer to user code that handles new messages. Depending on the DrakeLcm declaration order with respect to other objects on the local stack, the message recipient might be destroyed prior to the DrakeLcm being destroyed, which means the thread might call back into garbage.
Here, we explicitly stop the thread prior to destroying any objects, so that we can be sure they are always safe to delete.
Closes #9697. Closes #9809. Closes #6634.
Relates to #7524, though some bugs beyond this patch still remain according to CI.
该提问来源于开源项目:RobotLocomotion/drake