Questions tagged [heap-corruption]

A type of memory corruption that occurs in a computer program when the contents of a memory location are unintentionally modified due to programming errors

Memory corruption occurs in a computer program when the contents of a memory location are unintentionally modified due to programming errors; this is termed violating memory safety. When the corrupted memory contents are used later in that program, it leads either to program crash or to strange and bizarre program behavior. If a memory pointer is null, a dangling pointer (pointing to memory that has already been freed), or to a memory location outside of current stack or heap bounds, it is referring to memory that is not then possessed by the program.

http://en.wikipedia.org/wiki/Memory_corruption

355 questions
49
votes
4 answers

Is there a way to mark a chunk of allocated memory readonly?

if I allocate some memory using malloc() is there a way to mark it readonly. So memcpy() fails if someone attempt to write to it? This is connected to a faulty api design where users are miss-using a const pointer returned by a method GetValue()…
particle
  • 3,042
  • 3
  • 24
  • 38
36
votes
2 answers

How to debug corruption in the managed heap

My program throws an error which it cannot handle by a catch(Exception e) block and then it crashes: Access Violation Corrupted State Exception. This is the weird thing, because, as I know, corrupted state exceptions are thrown from unmanaged…
net_prog
  • 8,810
  • 14
  • 52
  • 68
29
votes
2 answers

How to use Microsoft Application Verifier

Using C++ and discovered today during a demo that I'm suffering from a corrupted heap (but only on important occasions!!). I found a few posts here on SO and decided to download Application Verifier and Debugging tool. I am current running Visual…
chikuba
  • 3,988
  • 6
  • 39
  • 74
23
votes
3 answers

Do (statically linked) DLLs use a different heap than the main program?

I'm new to Windows programming and I've just "lost" two hours hunting a bug which everyone seems aware of: you cannot create an object on the heap in a DLL and destroy it in another DLL (or in the main program). I'm almost sure that on Linux/Unix…
Emiliano
  • 16,994
  • 10
  • 41
  • 59
14
votes
2 answers

GFlags setting to catch heap corruption (other than Page Heap)?

On one production site our application(*) crashes repeatedly, but non-reproducibly. Analyzing the crash dumps clearly shows that it's a heap corruption: The crashes are at different location, but always access violations inside…
Martin Ba
  • 33,741
  • 27
  • 150
  • 304
14
votes
3 answers

Immediate detection of heap corruption errors on Windows. How?

I can't sleep! :) I have a reasonably large project on Windows and encountered some heap corruption issues. I have read all SO, including this nice topic: How to debug heap corruption errors?, however nothing was suitable to help me out-of-the-box.…
Sergey K.
  • 23,426
  • 13
  • 95
  • 167
13
votes
3 answers

Critical error detected c0000374 - C++ dll returns pointer off allocated memory to C#

I have a c++ dll which serving some functionality to my main c# application. Here i try to read a file, load it to memory and then return some information such as the Pointer to loaded data and count of memory blocks to c#. The Dll reads file to…
2i3r
  • 383
  • 1
  • 2
  • 10
12
votes
1 answer

.NET 4: Can the managed code alone cause a heap corruption?

I have a heap corruption in my multi-threaded managed program. Doing some tests I found that the corruption happens only when the background threads active in the program (they are switchable). The threads use some 3rd party components. After…
net_prog
  • 8,810
  • 14
  • 52
  • 68
9
votes
4 answers

Can new throws in a case of heap corruption?

In a case of a heap corruption, can new throw? If I understand it correctly, in a case of a heap corruption, all bets are off, and anything can happen. Is this correct?
BЈовић
  • 57,268
  • 38
  • 158
  • 253
9
votes
2 answers

What is the difference between glibc's MALLOC_CHECK_, M_CHECK_ACTION, and mcheck?

glibc seems to have more than one way of doing some heap checking: mallopt with the M_CHECK_ACTION parameter the MALLOC_CHECK_ environment variable the mcheck family of functions I find the available documentation to be confusing. The manual…
Paul Coccoli
  • 497
  • 1
  • 4
  • 13
8
votes
1 answer

How to turn GCStress on in Windows 7?

I am debugging a GC heap corruption and came to the step where I want to try running the program under WinDbg + PageHeap + AppVerifier + GCStress. I found in the article Software crash: faulting module mscorwks.dll, version 1.1.4322.2379 that I can…
net_prog
  • 8,810
  • 14
  • 52
  • 68
8
votes
3 answers

Heap corruption when returning from function inside a dll

I have a function with a prototype like the following: void function(std::string str); This function is called in my main function in another program that loads and uses that dll. function("some string value here"); When returning from this…
atoMerz
  • 6,868
  • 14
  • 56
  • 99
7
votes
2 answers

Heap corruption - "Free Heap block 61af0f0 modified at 61af194 after it was freed" C++

In my application I'm getting this error: HEAP[App.exe]: HEAP: Free Heap block 61af0f0 modified at 61af194 after it was freed Here is a call stack: ntdll.dll!_RtlpBreakPointHeap@4() Unknown ntdll.dll!@RtlpAllocateHeap@24() Unknown …
7
votes
1 answer

boost::threads example and heap corruption message

I'm quite new to boost::threads, I read the documentation and but i'm having some trouble applying it in practice, perhaps you can help? First of all, I have taken the time to write a self contained code listing that demonstrates 2 types of behavior…
AlexS
  • 496
  • 2
  • 6
  • 20
6
votes
7 answers

C++/msvc6 application crashes due to heap corruption, any hints?

About the application It runs on Windows XP Professional SP2. It's built with Microsoft Visual C++ 6.0 with Service Pack 6. It's MFC based. It uses several external dlls (e.g. Xerces, ZLib or ACE). It has high performance requirements. It does a…
davidag
  • 2,505
  • 3
  • 23
  • 40
1
2 3
23 24