I made new tests and the good news is, that the hang is fixed, but the bad news is, that the sleep does not help.
Lazarus = main_3_99-1463-g5fa267ce0a
FPC = 3.2.2-r0d122c49 (release)
OS = Linux Ubuntu 22.04 64-bit with GTK2
First I tested with the original sleep of 50:
- with loop value = 500 everything is perfect
- with loop value = 1000 I got always 688 lines
- with loop value = 2000 I got always 1782 or 1998 lines
- with loop value = 10000 I got always 9757 or 9972 lines
Then I changed the sleep to 150, 250, 650, 1550 and 3000 and repeated above loop values. I got the same results with 2 exceptions:
- with sleep=1550 and loop value=10000 I got 1 time all 10000 lines (in 10 tests)
- with sleep=3000 and loop value=2000 I got 1 time all 2000 lines (in 10 tests)
So these 2 exceptions look like random results and were only 1 time in 10 tests.
Here is my <install_path>/lazarus/components/lazdebuggers/lazdebuggerfp/fpdebugdebugger.pas from line 3474 on where I patched the sleep:
procedure TFpDebugDebugger.FDbgControllerProcessExitEvent(AExitCode: DWord);
var
AThread: TFpWaitForConsoleOutputThread;
begin
if assigned(FConsoleOutputThread) then
begin
AThread := TFpWaitForConsoleOutputThread(FConsoleOutputThread);
FConsoleOutputThread := nil;
AThread.Terminate;
AThread.DoHasConsoleOutput(0);
AThread.WaitFor;
sleep(3000); /// HG changed 15.2.24
AThread.DoHasConsoleOutput(0);
AThread.Free;
end;
SetExitCode(Integer(AExitCode));
{$PUSH}{$R-}
DoDbgEvent(ecProcess, etProcessExit, Format('Process exited with exit-code %u',[AExitCode]));
{$POP}
LockRelease;
try
SetState(dsStop);
StopAllWorkers;
FreeDebugThread;
finally
UnlockRelease;
end;
end;
I saw, that 1 inserted line of your patch =
https://gitlab.com/freepascal.org/lazarus/lazarus/-/commit/b1a91a2333b2d1a6fbdcf90c9eff7b128725a25a (from reply #62) is missing there:
Application.RemoveAsyncCalls(AThread);
Hope that is correct.