Troubleshoot thread access violation in Boost Log on shutdown

I have an application that uses towing. During shutdown, it receives an access violation when accessing a null pointer. When I go through the code to the point of failure, it seems that the boost :: log dll file is de-allocated, and then boost :: thread code tries to access the memory that was once occupied by the log dll.

I do not use any boost threads in my own code, and so suppose the boost-thread dll is used by boost log.

So that all drains are destroyed before shutdown, I call: core-> flush () and core-> remove_all_sinks ()

I am using boost 1.60 and also tried this with a boost of 1.63. The same result.

Is there a way to ensure that the buffer towing core is completely closed before the dll exits / unloads?

+4
source share
1 answer

This problem may be related to the local object installed by the promotion system. Similarly, in your case, this locale can be destroyed before Boost.Log is de-initialized, resulting in a crash.

In accordance with additional documents, in particular, the rotation module of the log file. They provided a workaround for a similar case. Promote known issues.

The solution is to initialize the locale in the main loop so that boost has enough loops to clear at the end.

int main(int argc, char* argv[])
{
    boost::filesystem::path::imbue(std::locale("C"));
    initialize_log();

    // ...
}
+1
source

Source: https://habr.com/ru/post/1670121/


All Articles