CDBEnv::Shutdown calls OutputDebugStringF if there is an error closing the database.
The database environment is a global variable.
OutputDebugStringF contains a static boost::mutex.
C++ does not guarantee an order for the destruction of static/global objects, and I am getting a crash I assume because at shutdown (I’m testing handling of corrupt wallet files):
the static mutexDebugLog is destroyed THEN the bitdb CDBEnv is destroyed, calling printf (OutputDebugStringF), which then crashes calling scoped_lock(mutexDebugLog)