QuickLogger
QuickLogger copied to clipboard
Issue within a library
Hi! Before anything, congrats on such a versatile logging library!
I have been struggling to encapsulate logging habilities for our win32 apps, but only when they are executed on Windows 7 or Windows server 2008 r2. If I run the code on Windows 10 or Windows Server 2016 or 2019, it works like a charm.
The problem seems to be related to thread handling inside a DLL.
I isolated the problem to the bare minimum, i'll attach the code and be grateful if anyone can give me a hand.
Hello, I was hoping to get some feedback about this issue. Is there anything else I could send you? Thanks!
Windows 7 32 or 64bits? Could you explain a little more?
Problem seems to be happening on both 32 and 64bits version (tested on Win7 32 and Win2008 64), although behaviour is slightly different. On both OS the executable is prevented from terminating because of an unfinished thread inside the DLL.
If I open procexp.exe, on Windows 7 32 bits the program immediately finishes when I try to inspect the console process. On Windows 2008 program does not finish and shows a remaining thread still running on the library.
I've attached the code, I'll paste it here anyway.
If I write a simple console project to a call DLL that is supposed to use QuickLogger it fails on the mentioned platforms.
CONSOLE PROJECT program consoleProject;
{$APPTYPE CONSOLE}
{$R *.res}
uses //ShareMem, System.SysUtils, Quick.Logger, Quick.Logger.Provider.Console;
function AddIntegers(_a, _b: integer): integer; stdcall; external 'libProject.dll';
begin Logger.Providers.Add(GlobalLogConsoleProvider);
try WriteLn(AddIntegers(1, 2)); WriteLn('Press Enter'); ReadLn; except on E: Exception do WriteLn(E.ClassName, ': ', E.Message); end;
end.
LIBRARY library libProject;
uses //ShareMem, System.SysUtils, System.Classes, Quick.Logger, Quick.Logger.Provider.Console;
{$R *.res}
function AddIntegers(const _a, _b: integer): integer; stdcall; begin Result := _a + _b; Logger.Debug('info para debug'); end;
exports AddIntegers;
begin Logger.Providers.Add(GlobalLogConsoleProvider); with GlobalLogConsoleProvider do begin LogLevel := LOG_VERBOSE; ShowEventColors := True; Enabled := True; end;
end.
Thank you!
Seems some kind of behavior with delphi over windows 7/2008 versions. If you comment line FQueueCondVar.ReleaseAll at Quick.Threads line 968, shutdown problem disappears. I'm trying to solve or report to Embarcadero.
Thanks!!!