gzserver crashed randomly when using delete and spawn model. ROS core dumped

asked 2020-08-01 11:24:06 -0500

kolohe113 gravatar image

I am doing deep Q learning and trying to delete and spawn models for every episode. And I am getting the following crash:

gzserver: ../nptl/pthread_mutex_lock.c:79: __pthread_mutex_lock: Assertion `mutex->__data.__owner == 0' failed.
Aborted (core dumped)

This happens randomly; it can crash on the 50 episode or 400 episodes. Here are the portion of my code that I think is responsible for the crash:

    rospy.wait_for_service("gazebo/spawn_sdf_model" )
    delete_model = rospy.ServiceProxy("gazebo/delete_model", DeleteModel)
    spawn_model = rospy.ServiceProxy("gazebo/spawn_sdf_model", SpawnModel)

    #----------Surrounding Generation-----------#
    prev_surr_name = "surr"+str(self.prev_surrounding)
    # print("prev i i", self.prev_surrounding)
    if self.prev_surrounding is not None:
            resp = delete_model(prev_surr_name) #delete
        except rospy.ServiceException, e:
            print "Service call failed for delete model: %s" % e
    surr_i = random.randint(0,2)
    curr_surr_name = "surr"+str(surr_i)
    self.prev_surrounding = surr_i
    # print("current i", self.prev_surrounding)
    f = open('/home/user/model_editor_models/surr'+str(surr_i)+'/model.sdf','r')
    surr_xml = f.read()
    surr_x = 6.08
    surr_y = -2.2
    surr_quat = Quaternion(*quaternion_from_euler(0.0, 0.0, 0))
    surr_pose = Pose(Point(x=surr_x, y=-2.2,  z=0), surr_quat)
        resp = spawn_model(curr_surr_name, surr_xml, "", surr_pose, "world") #spawn
    except rospy.ServiceException, e:
        print "Service call failed for spawn_model: %s" % e

I am also getting these errors on my other terminal:

Service call failed for delete model: transport error completing service call: unable to receive data from sender, check sender's logs for details

Service call failed for spawn_model: unable to connect to service: [Errno 104] Connection reset by peer

I am using python and don't remember messing around with pthread, I did use gazebo.pauseSim() here and there but I don't think that cause this issue. Does anyone have an idea of what might cause these?

edit retag flag offensive close merge delete