troubles with heap memory!

  • Thread starter Thread starter Steven Cool
  • Start date Start date
S

Steven Cool

Please help, this is driving me crazy...

I'm busy with an application which uses 2 unmanaged dll's, a wrapper
class and a c# application. each part is compiled with multi-threaded
Debug DLL (/MDd). Each time I run the application, I get an error.
This error occurs each time after another time and each time at
another place.

this is the error:

HEAP[CanTracer.exe]: HEAP: Free Heap block 81b6a70 modified at 81b6a9c
after it was freed
Unhandled exception at 0x77f97704 (NTDLL.DLL) in CanTracer.exe: User
breakpoint.

I have already tried boundschecker but I haven't found the solution.
Please help me because I'm not sleeping for 3 days now.

regards Steven





NTDLL.DLL!DbgBreakPoint()
NTDLL.DLL!RtlpNtEnumerateSubKey() + 0x5a17
NTDLL.DLL!RtlDestroyHandleTable() + 0x453
NTDLL.DLL!RtlpNtEnumerateSubKey() + 0x36fe
NTDLL.DLL!RtlDestroyHandleTable() + 0x177
NTDLL.DLL!RtlSizeHeap() + 0x52
msvcr71d.dll!_heap_alloc_base(unsigned int size=0x00000084) Line
212 C
msvcr71d.dll!_heap_alloc_dbg(unsigned int nSize=0x00000060, int
nBlockUse=0x00000001, const char * szFileName=0x00000000, int
nLine=0x00000000) Line 397 + 0x9 C
msvcr71d.dll!_nh_malloc_dbg(unsigned int nSize=0x00000060, int
nhFlag=0x00000000, int nBlockUse=0x00000001, const char *
szFileName=0x00000000, int nLine=0x00000000) Line 260 + 0x15 C
msvcr71d.dll!malloc(unsigned int nSize=0x00000060) Line 139 +
0x15 C
msvcp71d.dll!operator new(unsigned int size=0x00000060) Line 12 +
0xa C++
msvcp71d.dll!std::_Allocate<char>(unsigned int _Count=0x00000060,
char * __formal=0x00000000) Line 34 + 0x9 C++
msvcp71d.dll!std::allocator<char>::allocate(unsigned int
_Count=0x00000060) Line 143 + 0xb C++
msvcp71d.dll!std::basic_stringbuf said:
::overflow(int _Meta=0x0000006c) Line 111 + 0xf C++
msvcp71d.dll!std::basic_streambuf said:
::xsputn(const char * _Ptr=0x081a6740, int _Count=0x0000000f) Line
337 + 0x18 C++
msvcp71d.dll!std::basic_streambuf said:
::sputn(const char * _Ptr=0x081a6740, int _Count=0x0000000f) Line
154 C++
msvcp71d.dll!std::operator said:
(std::basic_ostream<char,std::char_traits<char> > & _Ostr={...},
const char * _Val=0x081a6740) Line 729 + 0x29 C++
CanDlld.dll!operator said:
& os={...}, const CANPicanolMsgIdentifier & id={...}) Line 321 +
0x28 C++
CanDlld.dll!operator said:
& os={...}, const CANPicanolCANBlock & cob={...}) Line 353 +
0x1a C++
 
Get some sleep first.

1) Enable page heap, Check the gflags tool.
2) Add HeapValidate calls to your code to isolate possible places causing
problem.
3) If the memory location corruptted is stable, add a watch on it and step
through your code.
4) If the memory location corruptted is stable, use a debugger which
supports breakpoint on memory access (cdb from microsoft has ba (breakpoint
on access) command).

Good luck
 
Feng Yuan said:
Get some sleep first.

1) Enable page heap, Check the gflags tool.
2) Add HeapValidate calls to your code to isolate possible places causing
problem.
3) If the memory location corruptted is stable, add a watch on it and step
through your code.
4) If the memory location corruptted is stable, use a debugger which
supports breakpoint on memory access (cdb from microsoft has ba (breakpoint
on access) command).

Good luck

thank you for the reply. The problem is I'm not such an experienced
user with all that stuff...
I've never heard about the gflags tool.

I followed your advice and i slept a little bit.
Then, I got up for another look-at-the-problem-day.

I have a UT for my unmanaged dll and I do some things there but I
never get an error. So the problem is in my managed code. On a certain
time, I see in the memory that something is written on a place that
already was used by other code. So I think there is my problem. But
how do I solve that?
I've also looked with boundschecker and it reports a memory overrun. I
don't know what that means but i think it can be an important message.
Any suggestions?
 
Feng Yuan said:
Get some sleep first.

1) Enable page heap, Check the gflags tool.
2) Add HeapValidate calls to your code to isolate possible places causing
problem.
3) If the memory location corruptted is stable, add a watch on it and step
through your code.
4) If the memory location corruptted is stable, use a debugger which
supports breakpoint on memory access (cdb from microsoft has ba (breakpoint
on access) command).

Good luck


I've enabled page Heap and I each time I run my program (it is still crashing)
BUT!!! it shows a message:

Page heap: block @ 07BA8930 is corrupted (reason 80)
Page heap: reason: corrupted infix pattern for freed block

troubles, troubles troubles
 
Page heap is supposed to detect the problem easier. Check the calling stack
to see if you are getting closer to your problem.
 
Back
Top