Serious bug in Forms.pas – Delphi 2009

By | November 6, 2008

There is a serious bug in the Forms.pas of Delphi 2009. A “stdcall” directive got lost in the transition from Delphi 2007 to Delphi 2009. This missing directive is visible via QC #66892 (Closing forms deactivates the application) and what is worse it trashes the stack and the application can vanish or raise an access violation if a form is closed or hidden. It is a ticking time bomb if you want.

But no worry, I have written a little bugfix unit that patches the defect Forms.pas function at runtime (no file on disk is modified). Adding this unit to a project is all you have to do. The initialization section of the HideStackTrashingFix.pas will automatically install the runtime patch. This unit can also be used by C++Builder users.

I hope that Update 2 will fix this and make this unit obsolete.

Download from CodeCentral:

7 thoughts on “Serious bug in Forms.pas – Delphi 2009

  1. Roddy

    Thanks, Andy.

    However, it doesn’t seem to work right for me. I added it a to an existing C++ Builder application, and the app will now not ‘restore’ after being minimized to the taskbar. It just sits there and has to be killed. Removing the fix restores ‘normal’ behaviour.

    Anything you can think of that might affect that?

  2. Richard King

    Thanks for the fix – a project we have just released and compiled up in D2009 does not appear to suffer from this problem — but I am not feeling very confident.

    I am extremely surprised that this basic functionality failure was not caught in CG/Emb’o’s testing.

    And more surprised this was not fixed in Update 1 (since this bug was lodged in mid September). Not a good start on Emb’o’s front…

Comments are closed.