Gpu Ray Plugin crashes when deleted

asked 2019-10-17 08:38:40 -0500

rafiki gravatar image

Problem

I have a simple empty world containing just a model with a GpuRayPlugin. When trying to delete the GpuRayPlugin from my model, gazebo crashes and returns a segfault. Here is the error message, with some prints I use for debugging (the code and instructions on how to reproduce are given below):

[Wrn] [Event.cc:60] Start destructor  
ID value is 0
Event bool value is 1
PN6gazebo5event5EventE

Thread 1 "gzserver" received signal SIGSEGV, Segmentation fault.
0x000055555719fd20 in ?? ()

I have already tried the following:

  • Checked that id and event member variables still exist by printing their values and the event type before the function call (see error message above). They clearly still exist, but SEGFAULT is thrown before entering Disconnect(), because the first debug statement inside Disconnect() ("Start disconnect") never prints.
  • The problem is specific to the GpuLaserPlugin, so I looked into how this object is destroyed, but the issue subsists even when commenting out the only line that destructor contains!

The full backtrace can be found here. The error seems to occur in de destructor of a Connection object, more specifically when Disconnect() is called.

I do not really know what to try anymore... does anyone have an idea/suggestion as to what may be causing this?

Code

I reproduce here some of the code I think is relevant, with some added debug print statements.

The Connection class:

class GZ_COMMON_VISIBLE Connection
{
  public: Connection(Event *_e, const int _i);
  public: ~Connection();
  public: int Id() const;
  private: Event *event = nullptr;
  private: int id = -1;
  private: common::Time creationTime;
  public: template<typename T> friend class EventT;
};

The Connection destructor:

Connection::~Connection()
{
  gzwarn << "Start destructor \n";                                  //for debug

  if (this->event && this->id >= 0)
  {
    this->event->SetSignaled(true);
    bool eventBool = this->event->Signaled();                       //for debug
    std::cout << "ID value is " << this->id << std::endl;           //for debug
    std::cout << "Event bool value is " << eventBool << std::endl;  //for debug
    std::cout << typeid(this->event).name() << std::endl;           //for debug
    this->event->Disconnect(this->id);
    this->id = -1;
    this->event = nullptr;
  }
  gzwarn << "End destructor \n";                                    //for debug
}

The Event and EventT class:

class GZ_COMMON_VISIBLE Event
{
  public: Event();
  public: virtual ~Event();
  public: virtual void Disconnect(int _id) = 0;
  public: bool Signaled() const;
  public: void SetSignaled(const bool _sig);
  private: bool signaled;
};

...

template<typename T>
class EventT : public Event
{
  public: EventT();
  public: virtual ~EventT();
  public: ConnectionPtr Connect(const std::function<T> &_subscriber);
  public: virtual void Disconnect(int _id);

...

}

...

void EventT<T>::Disconnect(int _id)
{
  printf("Start disconnect \n");                                //for debug

  // Find the connection
  auto const &it = this->connections.find(_id);

  if (it != this->connections.end())
  {
    it->second->on = false;
    this->connectionsToRemove.push_back(it);
  }
  printf("End disconnect \n");                                  //for debug
}

To reproduce

  • Optional: Install gazebo from source in debug mode.
  • Launch the sdf file here in gazebo and delete the model from gazebo (e.g. by calling the /gazebo/delete_model service).

Edit

I noticed this is actually an issue: issue #2574, but there are no comments or proposed fixes so this does not help much :-(

edit retag flag offensive close merge delete