memory allocation problem



I'm having a memory allocation problem that I'm hoping someone can
shed some light on. I'm betting that you'll tell me that I've
done something bad to the heap, and after another 4 or 5 days looking
for the problem I'll probably find that's the case. But I'm
seeing some strange things that I thought might indicate some other
problem.

My application fails intermittently when its release build is launched
outside of visual studio (I'm using Visual C++ .NET 2003 on Windows
XP). I haven't been able to reproduce the problem launching it from
Visual Studio, or launching the debug build outside of Visual Studio.
I have tracked the problem down to the creation of a new object. The
relevant part of the call stack at the time of failure seems to be:

msvcr71.dll!_heap_alloc(unsigned int size=11927992)
msvcr71.dll!_nh_malloc(unsigned int size=11927552, int nhFlag=0)
> msvcr71.dll!_heap_alloc(unsigned int size=28)
msvcr71.dll!_nh_malloc(unsigned int size=28, int nhFlag=0)
msvcr71.dll!malloc(unsigned int size=28)
MFC71.dll!operator new(unsigned int nSize=28)
USCT_FrameExtractor.exe!CIPImage::MakeLabel(int minCompSize=200, bool
filterSideJunk=true)

It looks to me like the size of the block that's getting allocated
gets messed up after the call to HeapAlloc in _heap_alloc_base. I
noticed that the value of _crtheap in the call to HeapAlloc is exactly
the value of the messed up size parameter in the _nh_malloc call. So
somehow it seems like the value of _crtheap param in the call to
HeapAlloc is getting morphed into the size param for future calls. Is
that the kind of thing that I would expect to happen if I've somehow
messed up the heap?

Thanks in advance for any help.

Seth

.


Loading