Re: 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.
>

Yes, if the error happens during heap allocation, heap corruption
is very probable. You can check for heap corruptions e.g. using PageHeap,
see configuration steps here:
http://www.debuginfo.com/tips/userbpntdll.html

> 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:
>

How exactly does the application fail?
What is the complete call stack at the moment of failure?

Intermittent failures nonreproducible under debugger can also happen
because of race conditions (if the application is multithreaded).

> 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.

Could you please explain with a bit more details how have you noticed this effect?
I am not sure that I understand the steps that lead to this situation.

Regards,
Oleg
[VC++ MVP]




.



Relevant Pages

  • Re: A solution for the allocation failures problem
    ... better clean up after myself and report a failure up the call chain". ... Code that has cleanly written checks for allocation failures is easier ... If the error handling is done sensibly, ... that resources are only cleaned up on failure if they were allocated ...
    (comp.lang.c)
  • Re: When to check the return value of malloc
    ... code to handle the failure of every single allocation. ... most of the time the program will fail to get memory again ... meanwhile the app may be able to do other useful things. ... In other cases - such as the one I mentioned - an allocation failure is ...
    (comp.lang.c)
  • Re: Operator new failing in windows after several days of operation
    ... I'm working on a large Windows ... The application manages to make over 4 billion memory ... > allocation counter rolls over. ... > do NOT get heap corruption errors under a debug build. ...
    (microsoft.public.vc.language)
  • Operator new failing in windows after several days of operation
    ... I'm working on a large Windows ... allocation counter rolls over. ... the application is maintaining about a 70MB memory ... Am I dealing with a heap corruption issue? ...
    (microsoft.public.vc.language)
  • Re: Panic in multiple kernels: IA64 SBA IOMMU: Culprit commit on Mar 28, 2008
    ... CC'ed linux-parisc since the same problem could happen to parisc. ... IOMMU driver uses size-aligned allocation algorithm. ... I think that you hit the allocation failure due to this problem ...
    (Linux-Kernel)

Loading