GUI multithreaded Win32 program sometimes freeze when quitting

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

GUI multithreaded Win32 program sometimes freeze when quitting

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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: GUI multithreaded Win32 program sometimes freeze when quitting

Mark Morgan Lloyd-5
On 18/04/17 12:00, 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]
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
Reply | Threaded
Open this post in threaded view
|

Re: GUI multithreaded Win32 program sometimes freeze when quitting

Henry Vermaak
In reply to this post by Dennis
On Tue, Apr 18, 2017 at 07:32:21PM +0800, 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
_______________________________________________
fpc-pascal maillist  -  [hidden email]
http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal