Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2017-04

GUI multithreaded Win32 program sometimes freeze when quitting

3 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Dennis

I have an win32 multithreaded program written in lazarus 1.7, FPC 3.1.1

From time to time, when it quits, it will freezes and from the task manager, the program will occupies the entire CPU core.

I noticed that it will happen more often if:
1)
constructor TMyComponent.Create(TheOwner : TComponent);
begin
    self.some_component := TSomeComponent.Create(TheOwner);
end;

instead of

constructor TMyComponent.Create(TheOwner : TComponent);
begin
    self.some_component := TSomeComponent.Create(self);
end;

2) if the program executes some methods of a nil object

3) if I don't do a build all when some common units are changed by another project.

Since this freezing behavour does not happen during debugging, I have spent months trying to fix it but failed.

Any suggestions are welcome.

Dennis

Reply by email

Mark Morgan Lloyd
to Dennis
Dennis wrote
I have an win32 multithreaded program written in lazarus 1.7, FPC 3.1.1 From time to time, when it quits, it will freezes and from the task manager, the program will occupies the entire CPU core. I noticed that it will happen more often if:

This might be better on the Lazarus ML since it's likely to be a subtlety of the LCL.

My experience is that it pays to be absolutely paranoid during termination regarding the continued availability of anything associated with a form, and also about termination flags themselves particularly the application terminate flag.

Granted that most of my unhappy experience in this area was in Delphi, but like yourself I found the culprit elusive.

Mark Morgan Lloyd markMLl .AT. telemetry.co .DOT. uk [Opinions above are the author's, not those of his employers or colleagues]

Reply by email

Henry Vermaak
to Dennis: I have an win32 multithreaded program written in lazarus 1.7, FPC 3.1.1 From time to…
Dennis wrote
Since this freezing behavour does not happen during debugging, I have spent months trying to fix it but failed. Any suggestions are welcome.

Try using a data race detector to see if it's a deadlock. I don't know about Windows, but I've used the helgrind tool in valgrind to successfully fix thread errors in a lazarus program. If you're lucky, the problem will manifest itself on a platform that valgrind is available on.

Henry

Reply by email