Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
When I build my project and run game, I get this error always.

Unhandled exception at 0x76fb2073 in Screen.exe: 0xC0000005: Access violation writing location 0x00000338 or sometimes 0x00000000.

When I debug this error, I can see the free.c source file.

else    //  __active_heap == __SYSTEM_HEAP
    #endif  /* _WIN64 */
    {
        retval = HeapFree(_crtheap, 0, pBlock);
        **if (retval == 0)                  // Here, error occured**
            {
            errno = _get_errno_from_oserr(GetLastError());
            }
        }
    }


When I trace this debug path, I found that error occured on this line on my screen.cpp file.

C++
if(FAILED(D3DXLoadMeshFromX(szName, D3DXMESH_SYSTEMMEM,
        m_pd3dDevice, &pAdjacencyBuffer,
        &pD3DXMtrlBuffer, NULL, &pMesh->dwNumMaterial,
        &pMesh->pMesh)))


I can't know why this error occur all time when I run this game.

Need your help!
Posted
Updated 23-Nov-11 2:55am
v2
Comments
RKS324 23-Nov-11 9:46am    
Is there any body who can help me?
I have no time.
Please help.

1 solution

So run it under the debugger and make sure all of the pointers are valid (not null). The error you cite generlly means you're either accessing a null pointer, or overflowing a boundary.
 
Share this answer
 
v2
Comments
Albert Holguin 23-Nov-11 8:59am    
Likely the issue, may be accessing a pointer that's already been freed somewhere else as well... +5
RKS324 23-Nov-11 9:04am    
Well, szName is not null, and m_pd3ddevice is too. Also pMesh is not null, Only the null parameter is pAdjacencyBuffer,pD3DXMtrlBuffer,pMesh->dwNumMaterial = 0 , pMesh->pMesh
RKS324 23-Nov-11 9:07am    
The interesting thing is that When I press F5 , whether the mode is window or full-screen, it works very well. Only press Ctrl + F5, the error occur.
#realJSOP 23-Nov-11 10:20am    
When you run under the debugger, variables are initialized automatically. You can turn this off in the compiler options. At that point, you'll find your issue.
Sergey Alexandrovich Kryukov 23-Nov-11 11:33am    
Right advice, my 5.
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900