[Bug 38402] New: glDebugMessageCallback is broken
https://bugs.winehq.org/show_bug.cgi?id=38402 Bug ID: 38402 Summary: glDebugMessageCallback is broken Product: Wine Version: unspecified Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: opengl Assignee: wine-bugs(a)winehq.org Reporter: chris.kcat(a)gmail.com Distribution: --- According to the KHR_debug extension spec, the function glDebugMessageCallback takes a function pointer callback with the type: typedef void (APIENTRY *GLDEBUGPROC)(GLenum source, GLenum type, GLuint id, GLenum severity, GLsizei length, const GLchar* message, const void* userParam); https://www.opengl.org/registry/specs/KHR/debug.txt In particular, it notes that the function callback uses the same calling convention as the other GL functions. The problem is that on Windows, GL uses the stdcall calling convention, while on Linux it uses cdecl. Wine's glDebugMessageCallback thunk passes the callback through as-is, so the system's libGL tries to call an stdcall function as though it was cdecl, causing it to crash upon returning. Another problem is that the spec says: "When DEBUG_OUTPUT_SYNCHRONOUS is disabled, the driver is optionally allowed to concurrently call the debug callback routine from potentially multiple threads, including threads that the context that generated the message is not currently bound to." meaning the callback can be called on threads other than the one OpenGL is being used on. This is a problem because it may be called on one or more internal driver threads that were not created using the Windows API, and if the callback function tries to do anything that relies on Windows-related thread information, it won't be there. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=38402 Sebastian Lackner <sebastian(a)fds-team.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |sebastian(a)fds-team.de -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=38402 Anastasius Focht <focht(a)gmx.net> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |focht(a)gmx.net --- Comment #1 from Anastasius Focht <focht(a)gmx.net> --- Hello Chris, do you have a real world application/game that breaks because of this or is this just an "offline" analysis/finding? Please provide download/link for the affected application if possible. Regards -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=38402 --- Comment #2 from Chris <chris.kcat(a)gmail.com> --- Not an app per-se, but I noticed it happen with my D3DGL project, which is a d3d9 dll designed to run with other apps: https://github.com/kcat/d3dgl It currently has a hack to work with Wine by making the callback cdecl: https://github.com/kcat/d3dgl/blob/42715c71b67a15e9e8dfbcd6a1c0d4093f38cb5d/... If the __cdecl is changed to the appropriate GLAPIENTRY, and the callback is invoked, it will crash. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=38402 Marcus Meissner <marcus(a)jet.franken.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|UNCONFIRMED |NEW CC| |marcus(a)jet.franken.de Ever confirmed|0 |1 --- Comment #3 from Marcus Meissner <marcus(a)jet.franken.de> --- yes, the calling convention is mismatched. we forward to the Linux opengl, which does a UNIX cdecl callback instead of a Win32/Win64 WINAPI callback. It needs to be moved out of the auto-generated functions into wgl.c and implemented seperately. (a bit tricky due to the autogeneration of the code) -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=38402 Marcus Meissner <marcus(a)jet.franken.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Summary|glDebugMessageCallback is |glDebugMessageCallback has |broken |mismatched calling | |convention -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=38402 Matteo Bruni <matteo.mystral(a)gmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |matteo.mystral(a)gmail.com --- Comment #4 from Matteo Bruni <matteo.mystral(a)gmail.com> --- We need to store the address of the user callback somewhere (in struct opengl_context maybe) and register our wrapper to OpenGL in glDebugMessageCallback*(). Our wrapper will in turn call the user callback taking care of the calling convention mismatch. I had a shot at writing a patch for this but I never completed it and I'm not sure when I'll get to it again. If someone else wants to try, be my guest. I don't think there is much we can do about the non-DEBUG_OUTPUT_SYNCHRONOUS case unfortunately. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=38402 --- Comment #5 from Marcus Meissner <marcus(a)jet.franken.de> --- Created attachment 52429 --> https://bugs.winehq.org/attachment.cgi?id=52429 projects/wine/0002-opengl32-for-glDebugMessageCallback-use-thunks-for-W.patch can you try this patch? also the opengl32 test I had to regenerate the autogenerated files, so its a bit larger. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=38402 Marcus Meissner <marcus(a)jet.franken.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Assignee|wine-bugs(a)winehq.org |marcus(a)jet.franken.de -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=38402 --- Comment #6 from Chris <chris.kcat(a)gmail.com> --- That patch seems to work with my dll (it doesn't crash when calling the callback with the fixed calling convention). But I notice the opengl32 tests don't seem to actually call it since the traces don't appear, though it does get called in my dll. Maybe the message queue isn't getting flushed, or maybe it requires a 3.0+ context? -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=38402 --- Comment #7 from Marcus Meissner <marcus(a)jet.franken.de> --- I had the same experience with the tests. The doc seems to mention it only calls in debug builds perhaps. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=38402 Marcus Meissner <marcus(a)jet.franken.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Attachment #52429|0 |1 is obsolete| | --- Comment #8 from Marcus Meissner <marcus(a)jet.franken.de> --- Created attachment 52440 --> https://bugs.winehq.org/attachment.cgi?id=52440 0029-opengl32-for-glDebugMessageCallback-use-thunks-for-W.patch submitted this patch it has a testcase, but it does not seem to trigger. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=38402 --- Comment #9 from Chris <chris.kcat(a)gmail.com> --- What if you try adding a glFinish() call after inserting the messages? That may force it to process pending messages. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=38402 --- Comment #10 from Marcus Meissner <marcus(a)jet.franken.de> --- tried, does not change behaviour :( -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=38402 Sebastian Lackner <sebastian(a)fds-team.de> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |STAGED CC| |dmitry(a)baikal.ru, | |erich.e.hoover(a)wine-staging | |.com, michael(a)fds-team.de Staged patchset| |https://github.com/wine-com | |pholio/wine-staging/tree/ma | |ster/patches/opengl32-glDeb | |ugMessageCallback -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=38402 André H. <nerv(a)dawncrow.de> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |nerv(a)dawncrow.de Staged patchset|https://github.com/wine-com |https://github.com/wine-sta |pholio/wine-staging/tree/ma |ging/wine-staging/tree/mast |ster/patches/opengl32-glDeb |er/patches/opengl32-glDebug |ugMessageCallback |MessageCallback -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=38402 Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|STAGED |RESOLVED CC| |leslie_alistair(a)hotmail.com Resolution|--- |FIXED Fixed by SHA1| |e07230ed4e8302efce99ce19243 | |89c229d90adfd --- Comment #11 from Alistair Leslie-Hughes <leslie_alistair(a)hotmail.com> --- Fixed by https://source.winehq.org/git/wine.git/?a=commit;h=e07230ed4e8302efce99ce192... -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=38402 Anastasius Focht <focht(a)gmx.net> changed: What |Removed |Added ---------------------------------------------------------------------------- Keywords| |download, source Version|unspecified |1.7.40 URL| |https://github.com/kcat/d3d | |gl -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=38402 Alexandre Julliard <julliard(a)winehq.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|RESOLVED |CLOSED --- Comment #12 from Alexandre Julliard <julliard(a)winehq.org> --- Closing bugs fixed in 3.18. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=38402 Michael Stefaniuc <mstefani(a)winehq.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|--- |3.0.x -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
https://bugs.winehq.org/show_bug.cgi?id=38402 Michael Stefaniuc <mstefani(a)winehq.org> changed: What |Removed |Added ---------------------------------------------------------------------------- Target Milestone|3.0.x |--- --- Comment #13 from Michael Stefaniuc <mstefani(a)winehq.org> --- Removing the 3.0.x milestone from bug fixes included in 3.0.5. -- Do not reply to this email, post in Bugzilla using the above URL to reply. You are receiving this mail because: You are watching all bug changes.
participants (1)
-
wine-bugs@winehq.org