So I was always annoyed by the way dlcompat
used to just leak. Then one day a couple of months ago, I said to myself “Hey, just add a call to atexit(3) and put in some cleanup code”.
I figured that it would be safe to deallocate everything then, after all we are in exit(), nothing could possibly call dlopen/dlclose/dlerror/dlsym from there right?
WRONG!
I discovered today that it is indeed possible to call dl functions after exit() has been called.
C++ static destructors can be called after I do my cleaning in dlcompat_cleanup. So, exit calls dlcompat_cleanup which deallocates all it’s malloc’d blocks and the pthread locks etc. exit then proceeds to call
the c++ static destructors which call dlclose, at which point dlcompat barfs all kinds of ugly stuff before it dies rather vocally.
So now I guss I have to go patch dlcompat to leak again. Sometimes it is better to leak
than have something squat on your head and do a big poop.
