Hi,

we have an issue with log4cxx.dll, version 0.13.0; here is what we found out so 
far:

  *   We built log4cxx.dll on a Windows Server 2019 with cmake (from the 
downloaded apache-log4cxx-0.13.0.zip).
     *   In apache-log4cxx-0.13.0\src\main\include\CMakeLists.txt the four 
lines below activate the SetThreadDescription / GetThreadDescription calls 
(because in the Windows SDK on that machine processthreadapi.h contains 
Set/GetThreadDescription):
if(WIN32)
    CHECK_SYMBOL_EXISTS(SetThreadDescription "windows.h;processthreadsapi.h" 
HAS_SETTHREADDESCRIPTION)
    CHECK_SYMBOL_EXISTS(GetThreadDescription "windows.h;processthreadsapi.h" 
HAS_GETTHREADDESCRIPTION)
endif(WIN32)
     *   And here is the call in threadutility.cpp:
...
#elif LOG4CXX_HAS_SETTHREADDESCRIPTION
   HRESULT hr = SetThreadDescription(static_cast<HANDLE>(nativeHandle), 
threadName.c_str());
...
     *   That means now log4cxx.dll needs an entry point for 
SetThreadDescription as soon as a client program that linked log4cxx.lib is 
started
  *   I made a small console program (named logConsole) with only one call to 
log4cxx in main() (after the "Hello World!" std::cout  output):
log4cxx::helpers::LogLog::setQuietMode(true);
  *   On a Windows Server 2019 or on Windows 10, the program starts and I see 
'Hello World!'
  *   Now the issue: on a Windows Server 2016 (version 1607), the program does 
not start up at all.
     *   In the event viewer's system log, the following "Application popup" 
message appears:
Application popup: logConsole.exe - Entry Point Not Found : The procedure entry 
point SetThreadDescription could not be located in the dynamic link library 
C:\Users\xyz\Documents\log4cxx.dll.

That means any program that uses this log4cxx.dll compiled on Windows 10 won't 
even start up on Windows Server 2016.

Here is what Microsoft says in:
https://learn.microsoft.com/en-us/windows/win32/api/processthreadsapi/nf-processthreadsapi-setthreaddescription
Windows Server 2016, Windows 10 LTSB 2016 and Windows 10 version 1607: 
SetThreadDescription is only available by Run Time Dynamic 
Linking<https://learn.microsoft.com/en-us/windows/win32/dlls/using-run-time-dynamic-linking>
 in KernelBase.dll.

As far as I can see there is no Run Time Dynamic Linking (via LoadLibrary) in 
the source code around the SetThreadDescription and GetThreadDescription calls.

Has anyone an idea what to do to avoid the problem on old machines?

My first guess is to delete these lines (but then the new calls are never made):
if(WIN32)
    CHECK_SYMBOL_EXISTS(SetThreadDescription "windows.h;processthreadsapi.h" 
HAS_SETTHREADDESCRIPTION)
    CHECK_SYMBOL_EXISTS(GetThreadDescription "windows.h;processthreadsapi.h" 
HAS_GETTHREADDESCRIPTION)
endif(WIN32)

Thank you in advance for any responses!

Best Regards,
Michael


Reply via email to