I'm trying to instrument a multithreaded program using the /Gh compiler option, but I ran into this interesting error. I wrote a simple DLL based on the Interceptor library from PrakaramJoshi, but when atexit() is called Access Violation Exception is thrown in _peneter.
I made a small code to reproduce the problem, here are my remarks:
- The problem occurs when the instrumented program uses static global variables.
- When compiling for debug the problem does not occur.
- When choosing /EHs exception handling model the problem does not occur with global mutex.
- But with /EHs and a global std::vector it is.
This is my project:
I think this has something to do with static initialization. So my question is how should I solve this problem? Is there any other approach to dodge this?