Unhandled win32 Exception: Access Violation Reading Location

  • I made trivial changes. Now I face an unhandled exception immediately upon the start of a run, even though I am pretty sure I restored everything to the original.

    It appears that the problem occurs at
    void * __cdecl _malloc_base (size_t size)
    res = _heap_alloc(size);

    When I build I get two warnings:
    "getenv may be unsafe" and "vc100.pdb missing"

    Running in debug I get
    “The inferior stopped because it triggered an exception. Read access violation at :0x0, flags 0x0."

    In the disassembler:
    "0x65396efa <+0x004a> mov ecx,dword ptr [ebx+124h]"

    Any suggestions would be welcomed! I'm stuck!

  • Hi there,
    First of all the use of malloc is not really a C++ way to go if you ask me. Using the "new" to allocate memory is much more OS independent.
    A couple of questions to ask your self in the code:

    • Did the malloc get the memory requested? (when the system is busy it might even not give you the requested memory)
    • When using the pointer does it point to anything (a NULL returned if the malloc failed).
      Given the warning of the debugger (Read acces violation at 0x0) you probably have a NULL pointer that is used to read or write data with. The OS protects against read/write operations outside the heap and stack of the program.
      Hope this helps, but I would suggest using "new" and "delete" for the memory allocation.

Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.