I am using the log4cplus library. When I create the application, it compiles and starts correctly (well, not quite right, since it does not write anything, but this is another problem), but when I close it, I get this error:
Run-Time Check Failure
Here is my code. I marked the relevant places with comments.
int APIENTRY _tWinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPTSTR lpCmdLine, _In_ int nCmdShow) { UNREFERENCED_PARAMETER(hPrevInstance); UNREFERENCED_PARAMETER(lpCmdLine); ////////////////// SET UP CHECKS FOR MEMORY LEAKS //////////////////// _CrtMemState s1; _CrtMemCheckpoint(&s1); _CrtSetDbgFlag(_CRTDBG_ALLOC_MEM_DF | _CRTDBG_LEAK_CHECK_DF); ////////////////////////////////////////////////////////////////////// log4cplus::PropertyConfigurator config(_T("log.properties")); // <-- this line seems to be responsible for the issue. When I remove it, everything is ok. _CrtMemDumpAllObjectsSince(&s1); // <-- here program breaks with mentioned error. return 1; }
So, as written in the comments, the PropertyConfigurator()
constructor seems to be responsible for the problem. No other code in this place causes such a problem.
Interestingly, it may be wrong if this library is used by many people and it works, while I am having problems with stack corruption.
Does anyone know what is going on here?
EDIT:
I deleted all the unnecessary code (the code edited above) and left only the relevant one. However, log4cplus::PropertyConfigurator config(_T("log.properties"));
causes a problem.
source share