-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In debug mode an assertion in class loader fails when destoying the class loader #39
Comments
I am unable to reproduce the bug. |
ok, now am able to reproduce it :) Mistake on my side |
This happens because
I don't think that the second reason is very likely. It seems like the mutex is accessed after it has been destroyed. I have no idea how/why though |
Ok, I poked at it some more: all boost::recursive_locks are destroyed by the libc exit_handler. After that happens the class_loader tries to lock them. I do not understand why libc calls the recursive_lock destructor, though. It shouldn't.... |
Found it: This is in class_loader_core.cpp
The mutex is static local while the class_loader is static. The class_loader is created before the mutex. Thus the mutex is destroyed before the class_loader. The class_loader tries to access the mutex during destruction and obviously fails. This is something that should be fixed upstream (might very well be, we are on a really old version of the class_loader). |
I don't think they changed this in their newer versions. See: Actually, there is some work going on trying to improve this but is an open issue: |
Ok this is more complex than I though. This is not an upstream bug. The upstream class_loader works fine as long as it is not statically allocated. What happens is: (1) the class_loader is statically allocated (because we use base::Singleton) My solution would be to manually delete the class_loader pointer at the end of main. I can do it in a hacky way for now but ultimately this needs an extension to base::Singleton |
The bug has been fixed in branch https://github.com/envire/envire-envire_core/tree/fix-classLoader I had to add a feature to base-logging thus for now this fork of base-logging is required: |
Thanks for investigating this issue! 👍 |
We should document somewhere that one needs to manually destroy the ClassLoader before the program ends, I guess? |
Discovered trying to fix this other issue
The same minimal example, but compiled in debug mode creates this behavior:
At https://github.com/ros/class_loader/blob/0.3.7/src/class_loader_core.cpp#L497
It triggers:
The text was updated successfully, but these errors were encountered: