AGB  ·  Datenschutz  ·  Impressum  







Anmelden
Nützliche Links
Registrieren
Zurück Delphi-PRAXiS Sprachen und Entwicklungsumgebungen Sonstige Fragen zu Delphi Delphi Delphi 12: Fehler mit Action := caFree
Thema durchsuchen
Ansicht
Themen-Optionen

Delphi 12: Fehler mit Action := caFree

Ein Thema von WiWo · begonnen am 1. Dez 2023 · letzter Beitrag vom 5. Dez 2023
Antwort Antwort
Seite 2 von 3     12 3      
peterbelow

Registriert seit: 12. Jan 2019
Ort: Hessen
700 Beiträge
 
Delphi 12 Athens
 
#11

AW: Delphi 12: Fehler mit Action := caFree

  Alt 2. Dez 2023, 13:20
ich hab jetzt das Projekt sowie als Screenshot den Zustand nach der Exception rangehängt.
Bemerkt hab ich den Fehler zuerst in einem wirklich riesigen Projekt und ziemlich lange gebraucht, bis ich die Ursache gefunden hatte. Aber auch schon mit dem angehängten Winzigst-Projekt krieg ich den Fehler.
Mein Delphi-Build ist übrigens 29.0.50491.5718; ich weiß nicht, ob da grad noch kleine Updates gemacht werden.
Ich kann das Problem in D12 reproduzieren, nur die Fehleradressen sind nicht immer gleich. Das ist ein echter Bug, der beim Implementieren des verbesserten MDI-Supports in TCustomForm.WndProc eingebaut wurde, siehe Post #9 in diesem Thread.

Bitte sei so nett und lege einen Bugreport mit deinem Beispielprogramm auf quality.embarcadero.com an.
Peter Below
  Mit Zitat antworten Zitat
Kas Ob.

Registriert seit: 3. Sep 2023
346 Beiträge
 
#12

AW: Delphi 12: Fehler mit Action := caFree

  Alt 2. Dez 2023, 13:37
I am out of words and at loss of straight thinking !
WTF is that stack ?
Did Embarcadero completely redesigned the TApplication in VCL ? and butchered it in the process ?
In D12 they completely reworked the support for MDI UIs to allow all the modern features users expect on Win 10 and 11. There probably are a lot of legacy MDI programs around that are in dire need of updating and from Embarcadero customers with some clout ...

This Visual manager thing was appearendly introduced to implement this support, but they introduced a bug in the process as well.
At the very end of TCustomForm.WndProc there are these lines:

Delphi-Quellcode:
  inherited WndProc(Message);

  if VisualManager_AcceptMessage(Message) then
    VisualManager_WndProc(Message);
end;
Closing a secondary form with an OnClose handler that sets caFree as close action eventually calls TCustomform.Release, which posts a CM_RELEASE message to the form. The inherited WndProc call above passes that to the CMRelease message handler, which Frees the form instance. So the form self reference is invalid when VisualManager_AcceptMessage is called, and since that method tries to read a field of the form it blows up.
Thank you for the details, i really appreciate it, still one thing you did not confirm yet, and will be really insightful.
On you Delphi is the stack cut at TApllicatiom.ProcessMessage too ? like WiWo screenshot, that is a problem not smaller the broken design !
Kas
  Mit Zitat antworten Zitat
peterbelow

Registriert seit: 12. Jan 2019
Ort: Hessen
700 Beiträge
 
Delphi 12 Athens
 
#13

AW: Delphi 12: Fehler mit Action := caFree

  Alt 2. Dez 2023, 14:29
Thank you for the details, i really appreciate it, still one thing you did not confirm yet, and will be really insightful.
On you Delphi is the stack cut at TApllicatiom.ProcessMessage too ? like WiWo screenshot, that is a problem not smaller the broken design !
If I run to a breakpoint in the OnClose handler the full call stack looks like this

Unit2.TForm2.FormClose($7F650010,caHide)
Vcl.Forms.TCustomForm.DoClose(???)
Vcl.Forms.TCustomForm.Close
Unit2.TForm2.Button1Click($3157C10)
Vcl.Controls.TControl.Click
Vcl.StdCtrls.TCustomButton.Click
Vcl.StdCtrls.TCustomButton.CNCommand(???)
Vcl.Controls.TControl.WndProc((48401, 1634, 591458, 0, 1634, 0, (), 1634, 9, (), 0, 0, ()))
Vcl.Controls.TWinControl.WndProc((48401, 1634, 591458, 0, 1634, 0, (), 1634, 9, (), 0, 0, ()))
Vcl.StdCtrls.TButtonControl.WndProc((48401, 1634, 591458, 0, 1634, 0, (), 1634, 9, (), 0, 0, ()))
Vcl.Controls.TControl.Perform(???,???,591458)
Vcl.Controls.DoControlMsg(???,(no value))
Vcl.Controls.TWinControl.WMCommand((273, (), 1634, 0, (), 591458, 0))
Vcl.Forms.TCustomForm.WMCommand((273, (), 1634, 0, (), 591458, 0))
Vcl.Controls.TControl.WndProc((273, 1634, 591458, 0, 1634, 0, (), 1634, 9, (), 0, 0, ()))
Vcl.Controls.TWinControl.WndProc((273, 1634, 591458, 0, 1634, 0, (), 1634, 9, (), 0, 0, ()))
Vcl.Forms.TCustomForm.WndProc((273, 1634, 591458, 0, 1634, 0, (), 1634, 9, (), 0, 0, ()))
Vcl.Controls.TWinControl.MainWndProc(???)
System.Classes.StdWndProc(657428,273,1634,591458)
:75d40eab USER32.AddClipboardFormatListener + 0x4b
:75d37e5a ; C:\WINDOWS\SysWOW64\USER32.dll
:75d37239 ; C:\WINDOWS\SysWOW64\USER32.dll
:75d3587f USER32.SendMessageW + 0x6f
:6e0c6618 ; C:\WINDOWS\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.3636_none_a863 d714867441db\comctl32.dll
:6e105f33 ; C:\WINDOWS\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_6.0.19041.3636_none_a863 d714867441db\comctl32.dll
:75d40eab USER32.AddClipboardFormatListener + 0x4b
:75d37e5a ; C:\WINDOWS\SysWOW64\USER32.dll
:75d37537 ; C:\WINDOWS\SysWOW64\USER32.dll
:75d356db USER32.CallWindowProcW + 0x1b
Vcl.Controls.TWinControl.DefaultHandler(???)
:005ff9e2 TWinControl.DefaultHandler + $136
:005ff88c TWinControl.WndProc + $6AC
:00614f89 TButtonControl.WndProc + $71
:00588db2 StdWndProc + $16
:75d40eab USER32.AddClipboardFormatListener + 0x4b
:75d37e5a ; C:\WINDOWS\SysWOW64\USER32.dll
:75d35bca ; C:\WINDOWS\SysWOW64\USER32.dll
:75d35990 USER32.DispatchMessageW + 0x10
Peter Below
  Mit Zitat antworten Zitat
Kas Ob.

Registriert seit: 3. Sep 2023
346 Beiträge
 
#14

AW: Delphi 12: Fehler mit Action := caFree

  Alt 2. Dez 2023, 14:52
If I run to a breakpoint in the OnClose handler the full call stack looks like this

Unit2.TForm2.FormClose($7F650010,caHide)
Vcl.Forms.TCustomForm.DoClose(???)
Well, that is normal, and there is no ProcessMessage there, the stack when the exception raised is the most critical to find/capture, hence my question about why it is cut in the screenshot, or just the debugger is failing to walk the stack which indicate bigger/deeper issue in RTL/VCL flow like stack overflow (overwrite, wrong declaration..) or just a reproducible debugger failure.
Kas
  Mit Zitat antworten Zitat
peterbelow

Registriert seit: 12. Jan 2019
Ort: Hessen
700 Beiträge
 
Delphi 12 Athens
 
#15

AW: Delphi 12: Fehler mit Action := caFree

  Alt 3. Dez 2023, 13:20

Well, that is normal, and there is no ProcessMessage there, the stack when the exception raised is the most critical to find/capture, hence my question about why it is cut in the screenshot, or just the debugger is failing to walk the stack which indicate bigger/deeper issue in RTL/VCL flow like stack overflow (overwrite, wrong declaration..) or just a reproducible debugger failure.
If I let the IDE break on the exception the call stack does look like in original post:

Vcl.Forms.TCustomForm.VisualManager_AcceptMessage( (45089, 0, 0, 0, 0, 0, (), 0, 0, (), 0, 0, ()))
Vcl.Forms.TCustomForm.WndProc((9960336, 9960352, 9960168, 9960168, 64416, 151, (), 64232, 151, (), 64232, 151, ()))
Vcl.Controls.TWinControl.MainWndProc(???)
System.Classes.StdWndProc(721212,45089,0,0)
:75d40eab USER32.AddClipboardFormatListener + 0x4b
:75d37e5a ; C:\WINDOWS\SysWOW64\USER32.dll
:75d35bca ; C:\WINDOWS\SysWOW64\USER32.dll
:75d35990 USER32.DispatchMessageW + 0x10
Vcl.Forms.TApplication.ProcessMessage(???)

That is what I would expect in this situation since the code flow after the PostMessage for the cm_release message returns to the main message loop in TApplication.Run, and thus the call stack unwinds to that location. There is no way to determine where in the code the message was posted, so the debugger cannot show that. Of course that is unfortunate in this case since the stack does not reveal the actual cause of the problem, but we have to live with it since that's how Windows apps work. The debugger can do nothing for us here, the info it would need is simply not there.
Peter Below
  Mit Zitat antworten Zitat
Kas Ob.

Registriert seit: 3. Sep 2023
346 Beiträge
 
#16

AW: Delphi 12: Fehler mit Action := caFree

  Alt 3. Dez 2023, 13:48
That is what I would expect in this situation since the code flow after the PostMessage for the cm_release message returns to the main message loop in TApplication.Run, and thus the call stack unwinds to that location. There is no way to determine where in the code the message was posted, so the debugger cannot show that. Of course that is unfortunate in this case since the stack does not reveal the actual cause of the problem, but we have to live with it since that's how Windows apps work. The debugger can do nothing for us here, the info it would need is simply not there.
Well, i disagree on expecting that behavior, my thoughts on this can be reduced to this:
1) The stack is corrupted and that is that, meaning unwind will fail to find the last SEH handler (or SEH chain) and the app will crash, in case OS catch an unhandled exception (through its own SEH) that return to specific positions, it will terminate the process, return position they are .. like if a background thread raised an exception without SEH trap, the OS will unwind and find it pointing to its origin in the kernel that called from CreateThread then the app is doomed and will be terminated then and there, also if the main thread raised an exception, and in unwinding the OS found it pointing to the code responsible for CreateProcess then also the app is done and gone, now if this is the case and it is confirmed by two users you and OP then this is reproducible RTL/VCL bug.
2) The stack is fine and the debugger is failing to walk it, then this is a debugger bug, also confirmed by 2 users.
3) Irrelevant to the stack and what the debugger is able show/walk/report, this exception confirmed by 2 users, and this is reproducible RTL/VCL bug.

So in all case this is a bug and need to be reported/fixed.

as for Vcl.Forms.TApplication.ProcessMessage being the first/oldest reported by the debugger, these is no more clearer report that there is a bug and it concern the stack itself or the debugger, like above either the debugger had failed or the stack already damaged/corrupted byt the RTL/VCL itself.
Also Vcl.Forms.TApplication.ProcessMessage is Delphi code and it is not an OS callback function, hence should and must have another code calling it from within Delphi code and that code (procedure/function) should be on the stack too, as simple as that.
Kas
  Mit Zitat antworten Zitat
TurboMagic

Registriert seit: 28. Feb 2016
Ort: Nordost Baden-Württemberg
2.936 Beiträge
 
Delphi 12 Athens
 
#17

AW: Delphi 12: Fehler mit Action := caFree

  Alt 3. Dez 2023, 15:23
This Visual manager thing was appearendly introduced to implement this support, but they introduced a bug in the process as well.
At the very end of TCustomForm.WndProc there are these lines:

Delphi-Quellcode:
  inherited WndProc(Message);

  if VisualManager_AcceptMessage(Message) then
    VisualManager_WndProc(Message);
end;
Closing a secondary form with an OnClose handler that sets caFree as close action eventually calls TCustomform.Release, which posts a CM_RELEASE message to the form. The inherited WndProc call above passes that to the CMRelease message handler, which Frees the form instance. So the form self reference is invalid when VisualManager_AcceptMessage is called, and since that method tries to read a field of the form it blows up.
Thanks for this thorough analysis!
Did you already check if that bug is already known? Means a QP report for it exists?
If none exists yet, would you be so kind to file one?

Ok, I just saw your last post in german on tis matter where you ask the OP to create a QP report if none exists yet.
So please disregard this one. The OP should use your material though, as this looks like a quite good starting point
for fixing it.

Geändert von TurboMagic ( 3. Dez 2023 um 15:26 Uhr)
  Mit Zitat antworten Zitat
peterbelow

Registriert seit: 12. Jan 2019
Ort: Hessen
700 Beiträge
 
Delphi 12 Athens
 
#18

AW: Delphi 12: Fehler mit Action := caFree

  Alt 3. Dez 2023, 15:29

So in all case this is a bug and need to be reported/fixed.

as for Vcl.Forms.TApplication.ProcessMessage being the first/oldest reported by the debugger, these is no more clearer report that there is a bug and it concern the stack itself or the debugger, like above either the debugger had failed or the stack already damaged/corrupted byt the RTL/VCL itself.
Also Vcl.Forms.TApplication.ProcessMessage is Delphi code and it is not an OS callback function, hence should and must have another code calling it from within Delphi code and that code (procedure/function) should be on the stack too, as simple as that.
The problem itself is a bug, no argument. But the debugger is not faulty, the stack is not corrupted. It correctly reports the location at which the exception was raised. That is just not the location that is at the root of the problem, but that is fairly often the case.
Peter Below
  Mit Zitat antworten Zitat
Kas Ob.

Registriert seit: 3. Sep 2023
346 Beiträge
 
#19

AW: Delphi 12: Fehler mit Action := caFree

  Alt 3. Dez 2023, 17:08
The problem itself is a bug, no argument. But the debugger is not faulty, the stack is not corrupted. It correctly reports the location at which the exception was raised. That is just not the location that is at the root of the problem, but that is fairly often the case.
I am sorry, may be didn't explain this clearly.

The debugger is reporting only 9 calls and stopped at TApplication.ProcessMesage , this call explicitly means there is more to it and it could be helpful or it could be not, but that is not up to the debugger to decide, it should go deeper, you already pasted two stacks report, so why one is over 50 walked and the real needed one with an exception is stopped/cut at 9 ?

That is my point about failing or buggy debugger.

Also see your first stack there is no ProcessMessages or ProcessMessage, so why that specific call in the stack (on exception) to begin with ?
If you noticed in the first stack (long) the whole process is logical and right, on other hand with the one with the exception also looks logical and fine but where and who (or whom ? bad English) did call it ?

All stacks should be resolved/walked to the origin, in the first one +50 was enough but if you want to go deeper, you should pass TApplication.Run and continue into address inside the kernel, same with threads but-there will be any TApplication.xxxx ,because they are what are they, threads.

Now back to the case at hand, Who did call ProcessMessage(MSG), and why the debugger stopped or failed to continue walking the stack from there to something declaring it is in fact the main thread form UI main message handling.

Did Application.ProcessMessages called form he main thread by design from the VCL ???? that ducked up to say the least, and that from an event triggered by the UI, well i am out of words here.
Yet again will repeat it, even if that is the case then ProcessMessage that reported in the stack should have a caller reported and resolved by the debugger.

Sorry again if that is still not clear, but i hope it might be.
Kas
  Mit Zitat antworten Zitat
TurboMagic

Registriert seit: 28. Feb 2016
Ort: Nordost Baden-Württemberg
2.936 Beiträge
 
Delphi 12 Athens
 
#20

AW: Delphi 12: Fehler mit Action := caFree

  Alt 3. Dez 2023, 21:23

So in all case this is a bug and need to be reported/fixed.
Meanwhile somebody else has reported the original issue:
https://quality.embarcadero.com/browse/RSP-43547

You might want to vote for it.
  Mit Zitat antworten Zitat
Antwort Antwort
Seite 2 von 3     12 3      

 

Forumregeln

Es ist dir nicht erlaubt, neue Themen zu verfassen.
Es ist dir nicht erlaubt, auf Beiträge zu antworten.
Es ist dir nicht erlaubt, Anhänge hochzuladen.
Es ist dir nicht erlaubt, deine Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.
Trackbacks are an
Pingbacks are an
Refbacks are aus

Gehe zu:

Impressum · AGB · Datenschutz · Nach oben
Alle Zeitangaben in WEZ +1. Es ist jetzt 11:49 Uhr.
Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz