Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue within a library #46

Open
ptavasci opened this issue Dec 11, 2020 · 5 comments
Open

Issue within a library #46

ptavasci opened this issue Dec 11, 2020 · 5 comments

Comments

@ptavasci
Copy link

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.

dll.zip

@ptavasci-provart
Copy link

Hello, I was hoping to get some feedback about this issue. Is there anything else I could send you?
Thanks!

@exilon
Copy link
Owner

exilon commented Jan 28, 2021

Windows 7 32 or 64bits? Could you explain a little more?

@ptavasci-provart
Copy link

ptavasci-provart commented Jan 29, 2021

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!

@exilon
Copy link
Owner

exilon commented Feb 7, 2021

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.

@ptavasci-provart
Copy link

Thanks!!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants