https://bugs.winehq.org/show_bug.cgi?id=43969
Bug ID: 43969 Summary: openGL SwapBuffers with NULL context Product: Wine Version: 2.19 Hardware: x86 OS: Linux Status: UNCONFIRMED Severity: normal Priority: P2 Component: winex11.drv Assignee: wine-bugs@winehq.org Reporter: jp-dev@inbox.ru Distribution: ---
A fragment of openGL code works under Windows and crashes under wine staging 2.19 at glxdrv_wglSwapBuffers. This code can be found under the VSTGUI project (see https://git.io/vFCwl).
The problem in wine is triggered because the library makes a null context current before the invocation of swapBuffers. As strange as it may be, Windows is able to render in this condition. wglMakeCurrent (deviceContext, 0); SwapBuffers (deviceContext); When I pass a context instead of 0, wine works as well.
This reveals a pair of problems. First, there is a null pointer dereference in wgl_SwapBuffers. ctx->hdc is an invalid access because of the null context (I have added the `&& ctx` check). if (escape.gl_drawable && ctx) ExtEscape( ctx->hdc, X11DRV_ESCAPE, sizeof(escape), (LPSTR)&escape, 0, NULL );
This change allows the program to run without crash, but the result is no rendering. My test configuration on Windows was 8.1 with the vmware GL passthrough driver.