Jens Froslev-Nielsen
Jens Froslev-Nielsen

Reputation: 31

Migration of old project from C++Builder 10.2 to 10.2.3 crashes at runtime

I have a very hard time upgrading our old C++Builder 10.2 project to 10.2.3 (we are using the Clang compiler, 32bit application on a 64bit PC).

The 10.2.3 installation went OK (on a clean Windows 10 PC), - the project compiles and links - everyone is happy so far.

But, when running the application in the debugger, I can see that the this pointer for the MainForm (a rather large object, for historic reasons) suddenly changes to garbage across a single method invocation call (when calling one of its own methods - just after the constructor is finished) which leads to a crucial failure.

I have tried to comment out the __fastcall calling convention for the particular method, and then the debugger goes a bit further, but then crashes in the next method invocation using __fastcall due to this pointer corruption (we have 1000+ methods with __fastcall, so commenting them all out is not an option).

Does anyone have a clue what is happening?

A new Clang compiler switch, maybe?

Issue with large objects?

I also tried to build a brand new project from scratch in 10.2.3 - but with no luck - the same weird thing happens.

Upvotes: 2

Views: 293

Answers (1)

Remy Lebeau
Remy Lebeau

Reputation: 597916

This is a known bug in the Clang compilers, which has already been reported to Embarcadero:

RSP-12769: bcc32c have problems with __fastcall calling convention

RSP-20171: Tokyo 10.2.3 clang destroys this pointer if stack is large

RSP-20173: BCC32C parameter corruption with more than 4KB of data on a stack frame

A patch for the Clang compilers in 10.2.3 Tokyo is available on Embarcadero's CodeCentral:

ID: 30834, C++Builder 10.2.3 C++ Compiler 4k Stack Allocation Patch

Upvotes: 3

Related Questions