CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums
Results 1 to 2 of 2

Thread: OpenGL - Debug to Release program crash

  1. #1
    Join Date
    Jun 2009

    Question OpenGL - Debug to Release program crash

    Hi all,

    Am making a game in C++ with OpenGL (and OpenAL for sound & DevIL for image handling) for a Uni. assignment.

    Everything had been fine so far, until I just tried to run my game in 'Release' mode as opposed to the usual 'Debug'. And *bham!*...the program crashed with an error before I even get to the main menu.

    The error I receive is :
    "Unhandled exception at 0x0377a110 in lesson1.exe: 0xC0000005: Access violation writing location 0x00000120."

    If I choose to 'Continue', I keep getting the same error message.

    By choosing 'Break', the program points me to the following line in a file called "msize.c" :

    #endif  /* _WIN64 */
     -->          retval = (size_t)HeapSize(_crtheap, 0, pblock);
    Here's part of the disassembly it points to :

        #endif  /* CRTDLL */
                else    /* __active_heap == __SYSTEM_HEAP */
        #endif  /* _WIN64 */
                    retval = (size_t)HeapSize(_crtheap, 0, pblock);
        00413759  push        ebx  
        0041375A  push        edi  
        0041375B  push        dword ptr [__crtheap (45748Ch)] 
        00413761  call        dword ptr [__imp__HeapSize@12 (42C1A4h)] 
    --> 00413767  mov         esi,eax 
                return retval;
        00413769  mov         eax,esi 
        0041376B  call        __SEH_epilog4 (411745h) 
        00413770  ret              
    I don't understand what's going on at all, and since this is for a Uni. assignment, my lecturer has specified that the game should run as expected under both 'Debug' and 'Release' mode.

    ANY advice/solutions are gladly welcome, because I'm rather desparate now after having spent over a day debugging and searching on the internet.

    Thanks heaps in advance!

  2. #2
    Join Date
    Oct 2006

    Re: OpenGL - Debug to Release program crash

    When you reach the access violation point in your code,
    try examining the call stack and observe the pointer values at different functions. Probably some passed pointer was uninitialized or released and you tried to dereference it, or you tried accessing an out of bounds index in an array.

    There are many things that will work just fine in Debug and won't work at all in Release mode. It usually has to do with initializing variables, reseting allocated memory, and such - this is usually done automatically in Debug and not done at all in Release.
    The call stack usually reveals who is to blame.


Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)