Skip to content
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

Invalid use of globals in openpsi #2991

Open
linas opened this issue Jan 27, 2018 · 0 comments
Open

Invalid use of globals in openpsi #2991

linas opened this issue Jan 27, 2018 · 0 comments
Assignees
Labels

Comments

@linas
Copy link
Member

linas commented Jan 27, 2018

The file OpenPsiRules.h decalres multiple arrays storing handles as globals. This will often lead to crashes in cxa_finalize when the shared library is unloaded. This is the current reason for why OpenPsiRulesUTest and the other OpenPsi tests crash.

Basically, when those tests finish, the C libarary unloads all shared libraries that were used, which causes all finalizers in those shared libraries to run. Whenever a shared library contains global C++ objects, the finalizer calls the destructors on those objects. a global Handle _psi_category would be an example of a global C++ class.

The problem here is that the finalizers are run in arbitrary order, and there is no way in which to control that order. In this case, the finalizer that unloaded libatombase.so which contains the definition for Handle has already run, so the code that defines the Handle destructor is now gone. At some later time, the finalizers for libopenpsi are run, which try to call the destructor for Handle which does not exist. Then boom!! an awful bunch of corruption messages spill out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants