envire / envire-envire_core

Core part for the Environment Representation library
BSD 2-Clause "Simplified" License
7 stars 13 forks source link

ClassLoader throws exception on destruction #37

Closed arneboe closed 5 years ago

arneboe commented 5 years ago

The destructor of ClassLoader crashes throwing class_loader::LibraryUnloadException.

console output:

terminate called after throwing an instance of 'class_loader::LibraryUnloadException'
  what():  Attempt to unload library that class_loader is unaware of.
Aborted (core dumped)

Minimal example to reproduce.

#include <envire_core/plugin/ClassLoader.hpp>
#include <envire_core/items/Item.hpp>
#include <octomap/AbstractOcTree.h>
using namespace envire::core;

int main(int argc, char **argv)
{

  Item<boost::shared_ptr<octomap::AbstractOcTree>>::Ptr octree;

  ClassLoader* loader = ClassLoader::getInstance();
  if(!loader->createEnvireItem("envire::core::Item<boost::shared_ptr<octomap::AbstractOcTree>>",octree))
  {
    std::cerr << "Unabled to load envire::octomap::OcTree" << std::endl;
    return -1;
  }
  return 0;
}
arneboe commented 5 years ago

@saarnold

Rauldg commented 5 years ago

Maybe is related to this one, which also occurs on destruction.

Rauldg commented 5 years ago

I tried to debug this: So far after setting the debug mode in compilation, the destructor fails with a different error:

At https://github.com/ros/class_loader/blob/0.3.7/src/class_loader_core.cpp#L497

It triggers:

install/include/boost/thread/pthread/recursive_mutex.hpp:113: void boost::recursive_mutex::lock(): Assertion `!pthread_mutex_lock(&m)' failed.

I think that when running in release mode the name of the loaded library in the class loader gets corrupted. That's why it can not find it, but couldn't find out when that happens.

arneboe commented 5 years ago

Assertions are disabled in release mode. The assert you found might be a completely different bug. Maybe it is best to open a new bug report for the assert?

Rauldg commented 5 years ago

Created the separated issue

arneboe commented 5 years ago

After fixing #39 I can no longer reproduce this bug.