log4cplus:
client:
We use log4cplus in an custom C++ dll which itself gets dynamically loaded in java program.
during the runtime everything works ok.
At application exit we see an java hotspot error (see logs).
This happens with and without calling log4cplus::Logger::shutdown();
The problem also occurs if nothing but log4cplus::initialize();
and log4cplus::Logger::shutdown();
are called.
From the hotspot error it looks like an cleanup issue:
Stack: [0x46760000,0x467b0000], sp=0x467aee5c, free space=315k Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code) C [ntdll.dll+0xecc94] C [ntdll.dll+0x9683a] C [KERNEL32.DLL+0x1dbb9] C [MSVCR110.dll+0x9fa77] C [MSVCR110.dll+0x4defc] C [MSVCR110.dll+0x4f4cf] C [MSVCR110.dll+0x2431b] C [MSVCR110.dll+0x243dc] C [MSVCR110.dll+0x16629] C [MSVCR110.dll+0x6a312] C [MSVCP110.dll+0x2e2d8] C [MSVCP110.dll+0x2e47e] C [log4cplus.dll+0x229b] log4cplus::thread::SyncGuard<log4cplus::thread::Mutex>::SyncGuard<log4cplus::thread::Mutex>+0x2b C [log4cplus.dll+0x3f1dd] log4cplus::spi::ObjectRegistryBase::clear+0x2d C [log4cplus.dll+0x14225] log4cplus::`anonymous namespace'::DefaultContext::~DefaultContext+0x45 C [log4cplus.dll+0x143a5] log4cplus::`anonymous namespace'::destroy_default_context::~destroy_default_context+0x25 C [log4cplus.dll+0x559cd] log4cplus::`anonymous namespace'::`dynamic atexit destructor for 'destroy_default_context_''+0xd C [log4cplus.dll+0x4e002] _CRT_INIT+0xc1 C [log4cplus.dll+0x4e228] __DllMainCRTStartup+0xcf C [log4cplus.dll+0x4e152] _DllMainCRTStartup+0x1c
I am not sure what to think about this. Could you please try HEAD of 1.2.x branch or 2.0.x branch? There have been some initialization and shutdown related changes since the 1.2.0 release. If just using newer log4cplus does not help, could you please try and run your app/java under a debugger with Microsoft symbols path set up so that we can see more of the contex, if at all possible?
Tried it with log4cplus-1.2.1-rc1
Same result. But small difference in the call stack.
I've also attached the MSVC Debugger with log4cplus symbols and got:
Thank you for the additional information, I think I now understand the situation. We have seen this before. The issue is with how are C++11 synchornization primitives implemented in Visual Studio.
As a stop gap measure, you can modify the log4cplus source like the following diff, for 1.2.x branch:
This will however not apply on 2.0.x branch because I have removed the non-C++11 implementations of synchornization primitives. I will either have to re-introduce them or...I do not know what else yet.
I am keeping this open to remind me about this issue.
Diff:
This is basically the issue: https://stackoverflow.com/questions/22402791/visual-studio-2013-stdmutex-and-the-dreaded-windows-loader-lock
I wonder, could you try it with Visual Studio 2015 or 2017?
I have pushed bd27044f35 to 1.2.x branch to work around this for 1.2.x. It should actually be OK on 2.0.x branch as only Visual Studio 2015 and later is supported there.
Hi Václav,
I've tried your patch with log4cplus-1.2.1-rc2 and it seems this did the trick!
Thank you very much for the quick fix!