On 8/20/19 3:28 PM, Paul Gofman wrote:
Latest commits brought some extra DECLSPEC_HOTPATCH attributes to a few kernelbase.dll (former kernel32.dll) functions, which have triggered gcc bug (see [1], [2]). The bug is not triggered when -fPIC is used, or if optimization is disabled. It looks like the bug is triggered mostly in the stub functions which have just WARN or FIXME, those functions which have some other code inside look ok (though I did not check them all). I know that tweaks which workaround compiler issues are not welcome in Wine. But in the present case it is likely going to be a massive regression, as the problem affects, e. g., native .Net (at least 4.0 for me) which is crashing after the second call to SetThreadStackGuarantee(), and likely much more. This is probably going to be long standing issue, as even after the bug is fixed upstream the fix is yet to come to mingw-w64 gcc versions used in Wine builds across distributions. In the view of that, maybe it worth considering some temporary solution? E. g., adding __attribute__((optimize(0))) to DECLSPEC_HOTPATCH can workaround the problem.
I'm personally not a fan of disabling optimizations on every single hot-patch function, since there should be a lot of functions using it. Maybe the stubs can be beefed up so they don't introduce the bug, or at the very least add the optimize(0) only on the stubs somehow?