Have an amazing solution built in RAD Studio? Let us know. Looking for discounts? Visit our Special Offers page!
News

10.2.3 C++ Hotfix for an issue with a 4KB or larger stack allocation

In 10.2.3, there is an issue affecting methods using the fastcall calling convention that allocate 4KB or more on the stack inside the method. The stack allocation could result in the ‘this’ pointer containing an incorrect value.  This was reported as:

  • RSP-20171
  • RSP-20297 and RSP-20173 (duplicate reports)

You can download the hotfix from CodeCentral.

Technical info

For those interested in the technical details, when the stack grows, it might need to grow into a new page, and 4KB is the size of a page on Windows and so by definition will cause this to occur. When the compiler sees a 4KB or larger stack allocation it calls a method to ensure the next page(s) are committed. 

We have always had one RTL method to handle this, _chkstk, and in 10.2.3, we introduced a new version, _chkstk_noalloc. This new method ensures that the esp register is left unchanged; if not, while your app would be fine, the debugger could get confused and think it was in a recursive method. We fixed this issue in 10.2.3. This hotfix addresses a related issue where the eax register was not being restored correctly, which for a fastcall method manifests as the ‘this’ pointer.

Make sure you rebuild and relink your projects against the 10.2.3 RTL, since if you mix old and new RTLs you will get an unresolved external against this new method. Upgrading to 10.2.3 and this hotfix solves some debugging scenarios that were problematic in earlier releases, and enables debugging of method parameters and other items in a method with a very large allocation.

 

See What's New in 12.2 Athens See What's New in 12.2 Athens Dev Days of Summer 2-24

Reduce development time and get to market faster with RAD Studio, Delphi, or C++Builder.
Design. Code. Compile. Deploy.
Start Free Trial   Upgrade Today

   Free Delphi Community Edition   Free C++Builder Community Edition

About author

David is an Australian developer, currently living in far-north Europe. He is the senior product manager for C++ at Idera, looking after C++Builder and Visual Assist.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

IN THE ARTICLES