https://bugs.winehq.org/show_bug.cgi?id=45199
--- Comment #12 from Lukáš Krejčí lskrejci@gmail.com --- The crashes seem to be related to hot patching certain library functions. I was able to test the program from https://bugs.winehq.org/show_bug.cgi?id=45230 and found out that libtcmalloc.dll.so is patching RtlAllocateHeap (and others, list attached). The problem is that it is overwriting the position-independent code thunk call, which represents the first instruction of that function. The issues started with Wine 3.8, which was that first one compiled by GCC 8.1.0. Wine 3.7 was compiled by GCC 7.3.1.
When I recompiled RtlAllocateHeap with DECLSPEC_HOTPATCH modifier, the program (TIM.exe) started working. It also worked with WINEDEBUG=relay, this can be explained by the fact that entry points to ntdll are patched to relay thunks. It should also be noted the compiling with -O0 or -O1 did not work for me - I guess GCC did not insert the call to get_pc_thunk as the first instruction.
While I did not test recompiling SysAllocStringByteLen from this bug report, it too has a call to a thunk as its first instruction.