FastMM4 icon indicating copy to clipboard operation
FastMM4 copied to clipboard

Problem with shared MM between exe and dll

Open jaclas opened this issue 7 years ago • 1 comments

I compile dll and exe with ShareMM option, but when I unload dll (FreeLibrary) from exe then FastMM hangs on FinalizeMemoryManager->DestroyCleanupThread called from DLL finalization.

procedure DestroyCleanupThread;
begin
  if ReleaseStackCleanupThread <> 0 then
  begin
    SetEvent(ReleaseStackCleanupThreadTerminate);
    WaitForSingleObject(ReleaseStackCleanupThread, INFINITE);  <--- hangs on waiting
    CloseHandle(ReleaseStackCleanupThread);
    ReleaseStackCleanupThread := 0;
    CloseHandle(ReleaseStackCleanupThreadTerminate);
    ReleaseStackCleanupThreadTerminate := 0;
  end;
end;

jaclas avatar Nov 22 '17 08:11 jaclas

Without ShareMM options unloading DLL hangs too (when DLL is compiled with FastMM).

jaclas avatar Nov 23 '17 09:11 jaclas