Francois Jacques wrote:
Group, This patch comes from investigation of a bug that was observed in RedHat 7.0 and not observed in RedHat 6.1. After a debugging session that involved Stephane and I, we found out that it was a compiler issue (which I feared from the start, but wasn't considering it seriously... arghhh). The RedHat 6.1 installation has gcc version 2.91.66 and the RedHat 7.0 installation has gcc version 2.96-20000731 (RedHat Linux 7.0) with latest updates from RedHat. What's happening : 1) HOOK_CallHook is being called (notice wParam and lParam arguments)2) Local variables wParamOrig and lParamOrig are set to wParam and lParam values3) Mapping function is called (MapFunc) with the *addresses* of wParam and lParam so those get changed before we call the hook4) After MapFunc is called, wParamOrig and lParamOrig values also changed to the new values of wParam and lParam (!) Explanation : Down to the assembly level code, the compiler doesn't create wParamOrig and lParamOrig on the stack. Instead, it directly use wParam and lParam. Fix : add volatile to wParamOrig and lParamOrig to prevent optimizations on those variables (aka. force their presence on the stack)
This kind of begs the question: how many more places in Wine should the volatile keyword be used? I find it hard to believe that this is the only spot in a large very low-level project like Wine.
-Dave