cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

stefan0073
Journeyman III

Exception in ChoosePixelFormat

Serious problems with latest drivers

All this on Win7 x64, Catalyst Version 10.11, ATI Radeon HD 4600 Series.

There's a serious problem in the latest drivers. The very first call to ChoosePixelFormat() always throws an exception. Subsequent calls succeed without problems.

 

While the thrown exception is caught (by the driver itself, I assume), on Win7 x64 this breaks applications. See here for why this is very, very bad:

http://support.microsoft.com/kb/976038

 

Because of the exception getting caught by Windows, my window creation function never finishes because all code after ChoosePixelFormat() isn't run, so SetPixelFormat() isn't called either.

 

To reproduce the exception:

  • start Visual Studio (I'm using VS2010), Menu Debug->Exceptions, check all exceptions there
  • create a new win32 project with the default options
  • add a new menu entry to the main menu resources named "ChoosePixelFormat"

Then change the WndProc function to:

LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
    int wmId, wmEvent;
    PAINTSTRUCT ps;
    HDC hdc;

    switch (message)
    {
    case WM_COMMAND:
        wmId    = LOWORD(wParam);
        wmEvent = HIWORD(wParam);
        // Parse the menu selections:
        switch (wmId)
        {
        case IDM_ABOUT:
            DialogBox(hInst, MAKEINTRESOURCE(IDD_ABOUTBOX), hWnd, About);
            break;
        case IDM_EXIT:
            DestroyWindow(hWnd);
            break;
        case ID_FILE_CHOOSEPIXELFORMAT:
            {
                INITCOMMONCONTROLSEX InitCtrls;
                InitCtrls.dwSize = sizeof(InitCtrls);
                // Set this to include all the common control classes you want to use
                // in your application.
                InitCtrls.dwICC = ICC_WIN95_CLASSES;
                InitCommonControlsEx(&InitCtrls);

                HDC hDC = ::GetDC(hWnd);
                PIXELFORMATDESCRIPTOR pfd;
                ZeroMemory( &pfd, sizeof( pfd ) );
                pfd.nSize = sizeof( pfd );
                pfd.nVersion = 1;
                pfd.dwFlags = PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL |
                    PFD_DOUBLEBUFFER;
                pfd.iPixelType = PFD_TYPE_RGBA;
                pfd.cColorBits = 24;
                pfd.cDepthBits = 16;
                pfd.iLayerType = PFD_MAIN_PLANE;
                int iFormat = ChoosePixelFormat( hDC, &pfd );
                SetPixelFormat( hDC, iFormat, &pfd );
                ReleaseDC(hWnd, hDC);
                //DestroyWindow(hWndDummy);
            }
            break;
        default:
            return DefWindowProc(hWnd, message, wParam, lParam);
        }
        break;
    case WM_PAINT:
        hdc = BeginPaint(hWnd, &ps);
        // TODO: Add any drawing code here...
        EndPaint(hWnd, &ps);
        break;
    case WM_DESTROY:
        PostQuitMessage(0);
        break;
    default:
        return DefWindowProc(hWnd, message, wParam, lParam);
    }
    return 0;
}

 

 

Now simply execute the ChoosePixelFormat menu command and Visual Studio will get triggered because of an exception thrown by the ATI driver.

 

Of course, this is just a minor problem which I can work around (as I said: only the first call throws the exception) by calling this function before anything else gets initialized.

 

The real big problem comes if you have two monitors with two completely different graphic cards. If the window for which ChoosePixelFormat is called is not on the default monitor (the default monitor being assigned to the ATI graphics card), then ChoosePixelFormat() crashes hard every time.

 

I could attach the VS2010 test project, but the forum doesn't seem to allow attachments.

4 Replies
pboudier
Staff

we have not seen this issue on any of the apps in our QA for win7, so there is something special here.

the kb article that you refer to is mentionning an issue with exceptions in ring0 (kernel mode), but the OGL driver is almost entirely in ring3 (user mode), so I am not sure if that is related.

can you send your test case to devrel@amd.com ?

thanks,

Pierre B.

0 Likes

I've sent an email with all the data and example code to the email address you mentioned (devrel at amd.com) on december 20, 2010.

But no reply yet.

0 Likes

Hello,

I'm experiencing this very same crash in Windows 7 in an MFC application that uses OpenGL. The crash always happens in ChoosePixelFormat or SetPixelFormat if I don't use ChoosePixelFormat.

If I use Application Verifier the logs show the error in wglGetPixelFormat.

I'm pasting down here one the logs, the shorter one, and I'll try to attach a zip with the other log files.

Thanks,
Diego


First chance access violation for current stack trace.
312afd8 - Invalid address causing the exception.
6e645a20 - Code address executing the invalid access.
31d8f4 - Exception record.
31d910 - Context record.

vrfcore!VfCoreRedirectedStopMessage+81 (d:\avrf\source\base\avrf\avrf30\vrfcore\stopredirect.cpp @ 103)
vfbasics!VerifierStopMessage+292 (d:\avrf\source\base\avrf\avrf30\providers\basics\basics.c @ 1214)
vfbasics!AVrfpCheckFirstChanceException+c8 (d:\avrf\source\base\avrf\vrfcommon\support.c @ 1108)
vfbasics!AVrfpVectoredExceptionHandler+16 (d:\avrf\source\base\avrf\vrfcommon\support.c @ 323)
ntdll!RtlCompactHeap+58a ( @ 0)
ntdll!TpSetTimer+3e9 ( @ 0)
ntdll!TpSetTimer+1bd ( @ 0)
ntdll!KiUserExceptionDispatcher+f ( @ 0)
atigktxx!GetD3DKMTProcAddress+1299 ( @ 0)
atioglxx!DrvPresentBuffers+e47f ( @ 0)
atioglxx!DrvSwapBuffers+dc88 ( @ 0)
OPENGL32!wglSwapMultipleBuffers+e46 ( @ 0)
OPENGL32!wglSwapMultipleBuffers+efc ( @ 0)
OPENGL32!wglGetProcAddress+45f ( @ 0)
OPENGL32!wglGetPixelFormat+70 ( @ 0)
OPENGL32!wglDescribePixelFormat+a2 ( @ 0)
GDI32!DescribePixelFormat+2e ( @ 0)


 

0 Likes

Did this issue ever get fixed ?

I am seeing what looks like the same problem.  I am writing a Qt image viewer program and when I create the image window it crashes in the call to SetPixelFormat (attempts to dereference a NULL pointer and trashes the call stack).  My computer has 3 monitors, two of which are driven by an ATI Radeon HD4600 PCI Express graphics card.  The third monitor is being driven by the Intel graphics adaptor built in to the motherboard.

I only get the crash if the window is created on the third monitor. If I create the window on either of the other two monitors then I get no crash and my program works fine.  I'm running Windows 7 64-bit and the ATI driver is version 8.970.100.7000 (dated 16 Nov 2012).

--

Glenn

0 Likes