Question

I am getting a heap corruption error when trying to compile my program. The code in question is a pointer

cparticle * particles. 

It is initialized to NULL and then set to

particles = new cparticle[amount]

I am only using delete once in the destructor, and it is causing windows to trigger a breakpoint. I have attempted to use application verifier, and it give me this info:

===========================================================
VERIFIER STOP 0000000000000013: pid 0x17C0: first chance access violation for current     stack trace 

000000001D54A0A4 : Invalid address being accessed
0000000055741DC6 : Code performing invalid access
000000000025E9D0 : Exception record. Use .exr to display it.
000000000025E4E0 : Context record. Use .cxr to display it.
===========================================================
This verifier stop is continuable. 
After debugging it use `go' to continue.
===========================================================



=======================================
VERIFIER STOP 00000013: pid 0x17C0: First chance access violation for current stack trace. 

1D54A0A4 : Invalid address causing the exception.
55741DC6 : Code address executing the invalid access.
001DF30C : Exception record.
001DF35C : Context record.


=======================================
This verifier stop is continuable.
After debugging it use `go' to continue.

=======================================

I am unsure what I am doing wrong, so any help will be appreciated.

Was it helpful?

Solution

The first thing you're doing wrong is you're not using std::vector<particle>.

The second thing is presumably that you're writing to memory past the end of your array of particles.

OTHER TIPS

Have you reproduced this in a small standalone program? Are you sure it's not caused by some other memory violation from before that went undetected until now? Are you using the correct delete operator?

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top