public inbox for cygwin@cygwin.com
 help / color / mirror / Atom feed
From: Jon Turney <jon.turney@dronecode.org.uk>
To: cygwin@cygwin.com
Cc: Thomas Schweikle <tschweikle@gmail.com>
Subject: Re: XWin Server starts but terminates shortly after
Date: Thu, 19 Nov 2015 20:21:00 -0000	[thread overview]
Message-ID: <564E2F54.1000803@dronecode.org.uk> (raw)
In-Reply-To: <564B442E.6060009@dronecode.org.uk>

[-- Attachment #1: Type: text/plain, Size: 1637 bytes --]

On 17/11/2015 15:13, Jon Turney wrote:
> On 13/11/2015 15:13, Thomas Schweikle wrote:
>> Adding "-nowgl" does the trick. XWin is running again.
>
> It seems that this problem manifests itself when running on a Windows
> guest under VMWare, with their SVGA driver.
>
> This seems to be caused by a c0000374 (STATUS_HEAP_CORRUPTION) exception
> raised whilst loading the VMWare OpenGL driver.

This is easy to reduce to just the code that XWin uses to probe the 
capabilities of the native OpenGL renderer (attached).

$ gcc -Wall xwin-gl-probe.c -lgdi32 -lopengl32 -o xwin-gl-probe.exe

$ strace ./xwin-gl-probe.exe
[...]
--- Process 2356, exception c0000374 at 0000000077B64102
[...]

If I add a checking with HeapValidate() before the crashing call to 
ChoosePixelFormat(), that doesn't report any problems, so that seems to 
rule out the heap corruption being introduced by this code.

Compiling the same code with VS 2013 works without problems on my test 
VM (VMWare Player 12.0.1 + W7 x64 + VMWare SVGA driver)

This doesn't really get me any further forward though.  Does this crash 
loading vm3dgl64 because of a bug in vm3dgl64 which is only exposed in 
Cygwin? or because the Cygwin environment doesn't satisfy some 
requirement of vm3dgl64 that it should?

This isn't the first report of a crash in this probe with various 
graphics drivers (although typically the exception is c0000005, which we 
can catch and fallback to software rendering), so while it's tempting to 
assume this is a problem in the graphics driver, it's possible that 
something systematic is wrong.

-- 
Jon TURNEY
Volunteer Cygwin/X X Server maintainer

[-- Attachment #2: xwin-gl-probe.c --]
[-- Type: text/plain, Size: 2710 bytes --]

//
// gcc xwin-gl-probe.c -lgdi32 -lopengl32 -o xwin-gl-probe.exe -Wall
//

#include <stdio.h>
#include <windows.h>

int
main(void)
{
    HWND hwnd;
    HDC hdc;
    HGLRC hglrc;

    // create window class
#define WIN_GL_TEST_WINDOW_CLASS L"XWinGLTest"
    {
        static ATOM glTestWndClass = 0;

        if (glTestWndClass == 0) {
            WNDCLASSEXW wc;

            wc.cbSize = sizeof(WNDCLASSEX);
            wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
            wc.lpfnWndProc = DefWindowProc;
            wc.cbClsExtra = 0;
            wc.cbWndExtra = 0;
            wc.hInstance = GetModuleHandle(NULL);
            wc.hIcon = 0;
            wc.hCursor = 0;
            wc.hbrBackground = (HBRUSH) GetStockObject(WHITE_BRUSH);
            wc.lpszMenuName = NULL;
            wc.lpszClassName = WIN_GL_TEST_WINDOW_CLASS;
            wc.hIconSm = 0;
            RegisterClassExW(&wc);
        }
    }

   // create an invisible window for a scratch DC
   hwnd = CreateWindowExW(0,
                           WIN_GL_TEST_WINDOW_CLASS,
                           L"XWin GL Renderer Capabilities Test Window",
                           WS_OVERLAPPEDWINDOW|WS_VISIBLE, 0, 0, 0, 0, NULL, NULL, GetModuleHandle(NULL),
                           NULL);
    if (hwnd == NULL) {
        printf("Couldn't create a window for render capabilities testing\n");
        goto error;
    }

    hdc = GetDC(hwnd);
    if (!hdc) {
        printf("Couldn't create a DC for render capabilities testing\n");
        goto error;
    }

    // we must set a pixel format before we can create a context
    {
        PIXELFORMATDESCRIPTOR pfd = {
            sizeof(PIXELFORMATDESCRIPTOR),
            1,
            PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DEPTH_DONTCARE | PFD_DOUBLEBUFFER_DONTCARE | PFD_STEREO_DONTCARE,
            PFD_TYPE_RGBA,
            24,
            0, 0, 0, 0, 0, 0,
            0,
            0,
            0,
            0, 0, 0, 0,
            0,
            0,
            0,
            PFD_MAIN_PLANE,
            0,
            0, 0, 0
        };

        int iPixelFormat = ChoosePixelFormat(hdc, &pfd);
        if (iPixelFormat == 0) {
            printf("ChoosePixelFormat failed\n");
            goto error;
        }

        if (!SetPixelFormat(hdc, iPixelFormat, NULL)) {
            printf("SetPixelFormat %d failed\n", iPixelFormat);
            goto error;
        }
        printf("Testing pixelFormatIndex %d\n",iPixelFormat);
    }

    hglrc = wglCreateContext(hdc);
    if (!wglMakeCurrent(hdc, hglrc)) {
        printf("wglMakeCurrent error: %08x dc %p ctx %p\n", (unsigned)GetLastError(), hdc, hglrc);
    }

    printf("Done\n");
error:
    return 0;
}

[-- Attachment #3: Type: text/plain, Size: 218 bytes --]

--
Problem reports:       http://cygwin.com/problems.html
FAQ:                   http://cygwin.com/faq/
Documentation:         http://cygwin.com/docs.html
Unsubscribe info:      http://cygwin.com/ml/#unsubscribe-simple

      reply	other threads:[~2015-11-19 20:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-11-12 10:11 Thomas Schweikle
2015-11-12 14:42 ` Jon Turney
2015-11-17 15:13   ` Jon Turney
2015-11-19 20:21     ` Jon Turney [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=564E2F54.1000803@dronecode.org.uk \
    --to=jon.turney@dronecode.org.uk \
    --cc=cygwin@cygwin.com \
    --cc=tschweikle@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).