C++ Debugging problem

G

Guest

Hi,

I am writing a Thread pooled P2P application, I have a constant flow of
actions that produce a certain problem, though I cannot find it’s cause.
I get “Free Heap block 356c00 modified at 356c34 after it was freedâ€,
following is a list of actions I have done while trying to find the cause:
1. Usage of compuwares BoundsChecker  didn’t find anything special.
2. using a binary search revealed calling a specific method caused this
problem, surprisingly the method being called is of the following form:
STDMETHODCALL DataNode::MyMethod(void) {
Return E_FAIL;
}

Following is the exact error description as provided by VS2005 debugger:

HEAP: Free Heap block 356c00 modified at 356c34 after it was freed
Windows has triggered a breakpoint in DataNodeLuncher.exe.

This may be due to a corruption of the heap, and indicates a bug in
DataNodeLuncher.exe or any of the DLLs it has loaded.

The output window may have more diagnostic information

I am really desperate about this.

Any help would be appreciated.
 
M

Marcus Heege

Hi Nadav,

Nadav said:
Hi,

I am writing a Thread pooled P2P application, I have a constant flow of
actions that produce a certain problem, though I cannot find it's cause.
I get "Free Heap block 356c00 modified at 356c34 after it was freed",
following is a list of actions I have done while trying to find the cause:
1. Usage of compuwares BoundsChecker ? didn't find anything special.
2. using a binary search revealed calling a specific method caused this
problem, surprisingly the method being called is of the following form:
STDMETHODCALL DataNode::MyMethod(void) {
Return E_FAIL;
}

Following is the exact error description as provided by VS2005 debugger:

HEAP: Free Heap block 356c00 modified at 356c34 after it was freed
Windows has triggered a breakpoint in DataNodeLuncher.exe.

This may be due to a corruption of the heap, and indicates a bug in
DataNodeLuncher.exe or any of the DLLs it has loaded.

The output window may have more diagnostic information

I am really desperate about this.

Any help would be appreciated.

It seems your problem is not a memory leak, but a synchronization problem. A
thread tries to access an object after it has been accessed by another
thread. I am not sure that the function mentioned you mentioned is the
function that actually causes the poblem. When the breakpoint occurs, it
does not help that much to investigate the call stack, because the detection
of this illegal modification does not happen during the modification of the
deleted object, but at a later time.

Is the poblem always occuring with the same address? If yes, try to use a
data breakpoint to find the illegal modification. If no, I would try to
guess the class whose instance is illegally modified. I would modify that
class to that the constructor logs the this pointer and something
identifying the object to a log file. When you repoduce the error, you can
use the heap block address and the log data to find out what object has
caused the problem. Once you know that you can identify where the object has
been deleted and why that is too early ...
 
C

Chris Edgington

You could try printing your "this" pointers from your constructors and
destructors to see if any of your instantiated objects corresponds
directly to the addresses in the error message. If that turns out to be
the case, and if the offset of the modification is always 0x34 bytes
from the start, you could figure out what member data that offset
refers to, which would point you to the code doing the modification.



-Chris

Qualnetics Corporation
cedgington at qualnetics.com
 
O

Oleg Starodumov

I am writing a Thread pooled P2P application, I have a constant flow of
actions that produce a certain problem, though I cannot find it's cause.
I get "Free Heap block 356c00 modified at 356c34 after it was freed",
following is a list of actions I have done while trying to find the cause:
1. Usage of compuwares BoundsChecker ? didn't find anything special.
2. using a binary search revealed calling a specific method caused this
problem, surprisingly the method being called is of the following form:
STDMETHODCALL DataNode::MyMethod(void) {
Return E_FAIL;
}

Following is the exact error description as provided by VS2005 debugger:

HEAP: Free Heap block 356c00 modified at 356c34 after it was freed
Windows has triggered a breakpoint in DataNodeLuncher.exe.

This may be due to a corruption of the heap, and indicates a bug in
DataNodeLuncher.exe or any of the DLLs it has loaded.

The output window may have more diagnostic information

Try to run the application under WinDbg with PageHeap enabled, and it should
raise an access violation when something attempts to access the freed block.
Then do '!heap -p -a <address>' to see the call stack at the moment when
the heap block was freed (<address> is the address of the heap block).
This should give you more info about the reasons of the race condition.

Here is how to enable PageHeap (and related links):
http://www.debuginfo.com/tips/userbpntdll.html

Regards,
Oleg
[VC++ MVP http://www.debuginfo.com/]
 
C

Chris Edgington

Since this forum is "dotnet" - I assumed, maybe incorrectly, that his
app is a .NET app.

Nadav, is this a managed app or not?

-Chris

Qualnetics Corporation
cedgington at qualnetics.com
 
O

Oleg Starodumov

Since this forum is "dotnet" - I assumed, maybe incorrectly, that his
app is a .NET app.

The app is at least mixed, since it uses COM, and the error comes from
the native Win32 heap manager.

Oleg
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top