Articles C++Builder 10.3.3 Threading and TLS Patch by David Millington

emailx45

Social Engineer
Joined
May 5, 2008
Messages
2,387
Reaction score
2,149
C++Builder 10.3.3 Threading and TLS Patch
[SHOWTOGROUPS=4,20]
David Millington
29/1/2020

An issue with thread-local storage that could cause AVs on some Win64 machines has been resolved
We've just released a patch for C++Builder 10.3.3 that resolves:
  • RSP-27180 64-bit builds crash with threads
    Creating and using a thread (eg std::thread) could result in an access violation on some machines.
This was caused by an error setting up the Win64 32-byte shadow space inside the assembly code to clean up TLS (thread-local storage) data, combined with the compiler applying a tail-call optimization to a method call (HeapFree) called within that, which meant that with the compiler optimization applied the effective caller of HeapFree was the code that incorrectly set up the shadow space. On some machines, possibly dependent on different Windows builds, HeapFree uses that shadow space, and so the TLS cleanup crashed. The patch correctly sets up the shadow space, and the crash no longer occurs.

The patch is available here: 30909 C++Builder 10.3.3 Threading and TLS Patch Full installation instructions are included in the readme.



RAD Studio 10.3.3 Indy Server SSL Certificate Patch


C++Builder 10.3.3 Threading and TLS Patch


C++Builder 10.3.3 Threading and TLS Patch
IDERA CommunitySearchUser
David Millington
David Millington
29/1/2020
An issue with thread-local storage that could cause AVs on some Win64 machines has been resolved

We've just released a patch for C++Builder 10.3.3 that resolves:

RSP-27180 64-bit builds crash with threads
Creating and using a thread (eg std::thread) could result in an access violation on some machines.
This was caused by an error setting up the Win64 32-byte shadow space inside the assembly code to clean up TLS (thread-local storage) data, combined with the compiler applying a tail-call optimization to a method call (HeapFree) called within that, which meant that with the compiler optimization applied the effective caller of HeapFree was the code that incorrectly set up the shadow space. On some machines, possibly dependent on different Windows builds, HeapFree uses that shadow space, and so the TLS cleanup crashed. The patch correctly sets up the shadow space, and the crash no longer occurs.

The patch is available here: 30909 C++Builder 10.3.3 Threading and TLS Patch Full installation instructions are included in the readme.

links more info
Stack Allocation

Using Thread-local Variables - RAD Studio

What Is Tail Call Optimization?

30909 C++Builder 10.3.3 Threading and TLS Patch

[/SHOWTOGROUPS]
 
Last edited:

lezar

New member
Joined
Oct 4, 2005
Messages
3
Reaction score
0
"Hey guys, has anyone managed to apply this patch successfully to CB10.3.3? I've been trying for hours but keep getting errors when compiling the sample project."
 

kadr-30

New member
Joined
Jun 2, 2008
Messages
3
Reaction score
0
Yooo, what's up guys? Just wanted to give a big shoutout to David Millington for dropping this patch. I've been trying to get threading working smoothly in C++Builder for months and this should finally help me out.
 
Top