c++c++builder-10.2-tokyo

Abnormal program termination on shutdown with TRESTClient


When a program that has a TRESTClient components is shutdown, it will show an "Abnormal Program Termination" error.

Recently, we've upgraded a project from C++Builder 2009 to C++Builder 10.2 Tokyo. Afterwards, we added the new TRESTClient to our project. Now, every time we try to close the application, it shows this error. This means that an abort() call is probably made.

We've run the debugger until the end of the tWinMain() function, which shows that it happens after the return. This shows that the exception is thrown during application cleanup. In the included call stack, it shows Data::Bind::Objectscope::Finalization, and UnregisterScope() being called from there. This is most likely where the exception is thrown.

This problem seems very similar to the issue in this forum post. Remy Lebeau describes this as a bug where, if an item is not found while unregistering, an exception is thrown.


Solution

  • This is fixed as of 10.3.2: https://stackoverflow.com/a/56195297/6852057

    To fix it in an older version:

    The issue has to do with the link order of two libraries, namely "bindengine.lib" and "bindcomp.lib".

    When "bindcomp.lib" is linked in BEFORE "bindengine.lib" you will see this problem, and for some frustrating reason the IDE insists in placing the them in wrong order. So to resolve the issue.

    1. close your project that shows the problem in the IDE.
    2. load the project's .cbproj into a text editor (HINT: NOT the IDE)
    3. search for the "" tag.
    4. switch the position of the two libs "...;bindengine.lib;bindcomp.lib;... " so as to have the "bindengine" BEFORE "bindcomp".
    5. repeat the process for any other "" (as you might have more than one configuration)
    6. repeat 3. to 5. for the tag ""
    7. save the project file.
    8. open it in the IDE and Build OR Clean and Make the project again. So that the EXE gets re-linked.