0

We have a 32-bit Visual C++/MFC based (Multi-Document Interface-MDI) application which is compiled using Visual Studio 2005.

We are running the application on Windows Server 2008 R2 (64-bit) having ATI Graphics card (ATIES1000 version 8.240.50.5000 to be exact).

We are using OpenGL in certain parts of our software.

The problem is that the software is randomly crashing after executing the code related to initialization of an OpenGL based window. After including heavy tracing in the code, we found out that the program execution becomes abnormal after executing wglCreateContext() function; it skips the rest of the code for the current function for initializing of OpenGL based Window and instead starts executing the default View (drawing) function of the application (eg. ApplicationView::OnDraw).

After executing a few lines of code for the default view, the program generates an exception when trying to access a main document member variable. Our unhandled exception filter is able to catch the exception and generate an execution dump, but the execution dump does not provide much useful information either, other than specifying that the exception code is c0000090.

The problem is quite random and is only reported to appear on this Windows server environment only.

Any help or hints in solving this situation?

EDIT : in other words, the program structure looks like this, with the execution randomly skipping the lines after wglCreateContext() function, executing a few lines of ApplicationView::onDraw and then causing an exception:

void 3DView::InitializeOpenGL()
{
    ....
    Init3DWindow( m_b3DEnabled, m_pDC->GetSafeHdc());
    m_Font->init();
    ....
}


bool 3DView::Init3DWindow( bool b3DEnabled, HDC pHDC)
{
    ...
    static PIXELFORMATDESCRIPTOR pd = {
        sizeof (PIXELFORMATDESCRIPTOR), // Specifies the size
        1,               // Specifies the version of this data structure
            ...
    };
    int iPixelFormat = ChoosePixelFormat(pHDC, &pd);
    if(iPixelFormat == 0) 
    {
        ...
    }
    bSuccess = SetPixelFormat(pHDC, iPixelFormat, &pd);
    m_hRC = wglCreateContext(pHDC);
    //Execution becomes abnormal afterwards and control exits from 3DView::Init3DWindow
    if(m_hRC==NULL)
    {
        ...
    }
    bSuccess = wglMakeCurrent(pHDC, m_hRC);
        ....
    return true;
}

void ApplicationView::OnDraw(CDC* pDC)
{
    ...
    CApplicationDoc* pDoc = GetDocument();
    ASSERT_VALID(pDoc);
    ...
    double currentValue = pDoc->m_CurrentValue;
    //EXCEPTION raised at the above line
    double nextValue = pDoc->nextValue;
}
  • Sounds like an exception may be being thrown by the OGL code, causing it to exit the calling function. – user1793036 Jan 31 '14 at 01:33
  • @user1793036 thanks for your comment. Going to wrap wglCreateContext() function call in a __try __except block. – user3253944 Jan 31 '14 at 09:07
  • Yes, after wrapping the problematic code in `try` `catch(...)` blocks, we are able to confirm that `wglCreateContext()` is generating an exception. `GetLastError()` within the `catch(...)` block is still returning `0` (or success). Is there any way that we can find out the type or the reason for the exception being thrown? – user3253944 Jan 31 '14 at 17:25
  • What is m_pDC? Is it the device context for the view? – rrirower Jan 31 '14 at 18:22
  • @rrirower yes, this is the device context (`CDC`) for the `3DView` class. – user3253944 Jan 31 '14 at 19:20
  • sorry I didn't notice earlier, but, that error code 0xC0000090 is C0000090 STATUS_FLOAT_INVALID_OPERATION. Have you checked to ensure the pixel format descriptor data is correct? – rrirower Jan 31 '14 at 19:39
  • @rrirower yes, i have just checked that `PIXELFORMATDESCRIPTOR` is correct and none of its parameters is a variable. `ChoosePixelFormat` always returns non-zero (success) value and similarly `SetPixelFormat` always returns true. – user3253944 Feb 03 '14 at 08:27

0 Answers0