I have a simple program that creates an OmniThread workerpool in the 'initialization' of a unit and destroys the same pool in the 'finalization' of that unit. This works fine as long as we do not use EurekaLog. If we include EurekaLog an access violation is raised during finalization of the application (after closing the app). This happens only once every 3 to 10 times the program ends; so it seems some sort of timing issue.
It seems that it all works fine, if we create the workerpool in the "normal" application flow (not in the initialization and finalization of a seperate unit).
The code of this unit is as follows:
unit Unit1;
interface
uses
OtlParallel;
var
_Worker: IOmniBackgroundWorker;
implementation
initialization
_Worker := Parallel.BackgroundWorker.NumTasks(10)
.Execute(
procedure(const AWorkItem: IOmniWorkItem)
begin
//
end
);
finalization
_Worker.Terminate(INFINITE);
_Worker := nil;
end.
The main application is also simple:
uses
{$IFDEF EurekaLog}
EMemLeaks,
EResLeaks,
EDebugExports,
EDebugJCL,
EFixSafeCallException,
EMapWin32,
EAppVCL,
EDialogWinAPIMSClassic,
EDialogWinAPIEurekaLogDetailed,
EDialogWinAPIStepsToReproduce,
ExceptionLog7,
{$ENDIF EurekaLog}
Vcl.Forms,
Unit1 in 'Unit1.pas';
{$R *.res}
begin
Application.Initialize;
Application.MainFormOnTaskbar := True;
Application.Run;
end.
The callstack on the access violation is:
:5653e4c4
OtlTaskControl.TOmniTask.Execute
OtlThreadPool.TOTPWorkerThread.ExecuteWorkItem($393A160)
OtlThreadPool.TOTPWorkerThread.Execute
System.Classes.ThreadProc($3976800)
EThreadsManager.NakedBeginThreadWrapper(???)
:76ee6359 KERNEL32.BaseThreadInitThunk + 0x19
:77628944 ntdll.RtlGetAppContainerNamedObjectPath + 0xe4
:77628914 ntdll.RtlGetAppContainerNamedObjectPath + 0xb4
I use the latest master checkout of OTL and EurekaLog version 7.9.1.4 update 1 hot-fix 4.
Is the way we create and destroy the workerpool correct? And, if so, is anybody familiar with issues in OTL/EurekaLog if they are used together?