View Issue Details

IDProjectCategoryView StatusLast Update
0021451LazarusLCLpublic2021-01-29 20:00
ReporterMartin Friebe Assigned ToMartin Friebe  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionfixed 
Product Version0.9.31 (SVN) 
Fixed in Version2.2 
Summary0021451: running at full CPU when it should be Idle (modal form + ReleaseComponents)
DescriptionCan be observed with the new Src-Win-Mgr. (but IMHO is not a fault of it)

- open it via keyboard ctrl-shift-W
- tick the checkbox of the SynEdit, that was active (and therefore
handles the KeyDown)
- Close it (from within the mgr)

Now we have full CPU (1 core at 100%)

The reason is in
    procedure TApplication.ReleaseComponents;

which runs at Idle, as well as at a queued async call

It checks if the componont is still ref counted:

         if (Component is TLCLComponent)
         and (TLCLComponent(Component).LCLRefCount>0) then begin
           // add again to FComponentsToRelease
           ReleaseComponent(Component);
         end else begin
           // this might free some more components from FComponentsReleasing
           Component.Free;


In the given case, the "ShowModal" is called in the KeyDown handler.
Therefore as long as the Form is shown, the Componont can not be
destroyed and will be rescheduled.
Unfortunately the re-schedule runs immediately. Creating an endless loop.
TagsNo tags attached.
Fixed in Revision64435
LazTarget2.2
Widgetset
Attached Files

Activities

Cyrax

2012-03-09 22:10

reporter   ~0057453

I can confirm this bug. System: win32, Free Pascal trunk 2.7.1-r20476, Lazarus trunk 0.9.31-r35808.

Zeljan Rikalo

2012-03-10 08:54

developer   ~0057456

@Martin, can you create example of problem. Maybe it's related to my changes of ShowModal (modal form does not destroy it's handle anymore when modal finished).

Martin Friebe

2012-03-10 11:58

manager   ~0057457

Last edited: 2012-03-10 11:59

I don't think it has anything to do with the destruction of the modal form. (I do not think that the issue is new ,either)

The problem should be easy to make out, simply by looking at
  procedure TApplication.ReleaseComponents;

- knowing that both async and idle will run in ShowModal
- knowing what LclRefCount is for

ReleaseComponents will be executed in Idle/Async as soon as there are components waiting to be released.

Normally idle/async only happens after the end of any message to any component (KeyDown).

But with a ModalForm being called from inside a KeyHandler this leads to an endless loop (as modal form runs it's own message loop)

-------
Please look at the example in the IDE.

Zeljan Rikalo

2012-03-10 12:26

developer   ~0057460

Yes, you're right.

Vincent Snijders

2014-10-02 10:46

manager   ~0077879

I cannot reproduce this issue, probably because the Source Window Manager isn't a modal dialog anymore.

Martin, if you can create an example application to reproduce the issue, you can create a new issue so we can look into the problem.

Martin Friebe

2021-01-28 22:47

manager   ~0128647

Just happened again. Opening a project that is set to a target (OS/cpu) not supported by the installed fpc.

SourceNotebook is in an event / has refcount.

Modal dlg is called to inform about "target not supported" => endless attempts to free sourcenotebook in the modals event loop.

Issue History

Date Modified Username Field Change
2012-03-09 20:57 Martin Friebe New Issue
2012-03-09 20:57 Martin Friebe LazTarget => -
2012-03-09 22:10 Cyrax Note Added: 0057453
2012-03-10 08:54 Zeljan Rikalo Note Added: 0057456
2012-03-10 08:54 Zeljan Rikalo Status new => feedback
2012-03-10 11:58 Martin Friebe Note Added: 0057457
2012-03-10 11:59 Martin Friebe Note Edited: 0057457
2012-03-10 12:26 Zeljan Rikalo Note Added: 0057460
2014-10-02 10:46 Vincent Snijders Note Added: 0077879
2014-10-02 10:46 Vincent Snijders Status feedback => resolved
2014-10-02 10:46 Vincent Snijders Resolution open => unable to reproduce
2014-10-02 10:46 Vincent Snijders Assigned To => Vincent Snijders
2019-04-22 19:33 Martin Friebe Status resolved => closed
2021-01-28 22:45 Martin Friebe Assigned To Vincent Snijders => Martin Friebe
2021-01-28 22:47 Martin Friebe Status closed => assigned
2021-01-28 22:47 Martin Friebe Resolution unable to reproduce => open
2021-01-28 22:47 Martin Friebe Note Added: 0128647
2021-01-29 20:00 Martin Friebe Status assigned => resolved
2021-01-29 20:00 Martin Friebe Resolution open => fixed
2021-01-29 20:00 Martin Friebe Fixed in Version => 2.2
2021-01-29 20:00 Martin Friebe Fixed in Revision => 64435
2021-01-29 20:00 Martin Friebe LazTarget - => 2.2