Boost logo

Boost Users :

Subject: [Boost-users] [SmartPtr] Memory Leak Perhaps
From: Hossein Haeri (powerprogman_at_[hidden])
Date: 2010-09-19 07:52:11


Dear all,

(Sorry for cross-posting.)

I have a container which stores boost::shared_ptr's. The container has a strange behaviour upon insertion of a SPECIFIC pointer into it. The insertion itself happens with no problem and I can successfully do all my desired operations. Yet, I receive the following strange Win32 exceptions when I'm done and my program is ending (i.e., after the last instruction in my main function):

1) When I run the program from the CodeBlocks IDE (GCC 4.5.1, MinGW, WinXP-SP3), a message box from the JIT debugger pops up which says: "An unhandled Win32 exception occurred in ... [29436]".

2) When I run the same program from MSCV2008, an MSVC++ Debug Library message box pops up which says: "Program ... File f:\dd\... Line 52 Exception _BLOCK_TYPE_IS_VALID(pHead->nBlockUse)...".

I call the above error messages strange because of the observations below:

1) The error reported by MSVC2008 refers to a file on my drive F: whereas, basically, I don't have such a drive on my system!

2) The CodeBlocks debugger (a GUI wrapped around GDB) runs the program with no problems over the debug sessions. Despite that, there are several "Program received signal SIGTRAP, Trace/breakpoint trap." messages in the GDB debug log. Unfortunately, I don't know how to locate the place where these are related to.

3) MSVC2008 has the same behaviour over the debug session. The output of debug session ends with "The program '[29312] EE1Debugger.exe: Native' has exited with code 3 (0x3)." (Please find a copy of the debug log at the P.S. if you're interested.)

My first guess was a memory leak but I didn't spot anything which smells like that over numerous debug sessions. I'm generally dubious about that because I'm using shared_ptr's. Shallow copy can't be the problem either again 'cause I only insert shared_ptr's (from just-allocated dynamic memory) into my container.

On the other hand, the problem only occurs upon insertion of a SPECIFIC entry into my container. Strangely enough, if I delete that specific entry manually before the end of my program, everything goes fine! I even checked the count of that specific shared_ptr and it was 1, i.e., I'm not deleting anybody else's memory. I am really confused and left with no clue... Any suggestions?

P.S.

'EE1Debugger.exe': Loaded 'D:\...\EE1Debugger.exe', Symbols loaded.
'EE1Debugger.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll'
'EE1Debugger.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll'
'EE1Debugger.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_597c3456\msvcr90d.dll', Symbols loaded.
'EE1Debugger.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.VC90.DebugCRT_1fc8b3b9a1e18e3b_9.0.21022.8_x-ww_597c3456\msvcp90d.dll', Symbols loaded.
First-chance exception at 0x7c812afb in EE1Debugger.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0012f550..
First-chance exception at 0x7c812afb in EE1Debugger.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0012f5a8..
First-chance exception at 0x7c812afb in EE1Debugger.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0012f5a8..
First-chance exception at 0x7c812afb in EE1Debugger.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0012f5a8..
First-chance exception at 0x7c812afb in EE1Debugger.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0012f5a8..
First-chance exception at 0x7c812afb in EE1Debugger.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0012f5a8..
First-chance exception at 0x7c812afb in EE1Debugger.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0012f5a8..
First-chance exception at 0x7c812afb in EE1Debugger.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0012f5a8..
First-chance exception at 0x7c812afb in EE1Debugger.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0012f5a8..
First-chance exception at 0x7c812afb in EE1Debugger.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0012f5a8..
First-chance exception at 0x7c812afb in EE1Debugger.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0012f5a8..
First-chance exception at 0x7c812afb in EE1Debugger.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0012f5a8..
First-chance exception at 0x7c812afb in EE1Debugger.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0012f5a8..
First-chance exception at 0x7c812afb in EE1Debugger.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0012f5a8..
First-chance exception at 0x7c812afb in EE1Debugger.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0012f5a8..
First-chance exception at 0x7c812afb in EE1Debugger.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0012f5a8..
First-chance exception at 0x7c812afb in EE1Debugger.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0012f5a8..
First-chance exception at 0x7c812afb in EE1Debugger.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0012f5a8..
First-chance exception at 0x7c812afb in EE1Debugger.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0012f5a8..
First-chance exception at 0x7c812afb in EE1Debugger.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0012f5a8..
First-chance exception at 0x7c812afb in EE1Debugger.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0012f5a8..
First-chance exception at 0x7c812afb in EE1Debugger.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0012f5a8..
First-chance exception at 0x7c812afb in EE1Debugger.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0012f5a8..
First-chance exception at 0x7c812afb in EE1Debugger.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0012f5a8..
First-chance exception at 0x7c812afb in EE1Debugger.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0012f5a8..
First-chance exception at 0x7c812afb in EE1Debugger.exe: Microsoft C++ exception: std::runtime_error at memory location 0x0012f5a8..
'EE1Debugger.exe': Loaded 'C:\WINDOWS\system32\user32.dll'
'EE1Debugger.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll'
'EE1Debugger.exe': Loaded 'C:\WINDOWS\system32\imm32.dll'
'EE1Debugger.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll'
'EE1Debugger.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll'
'EE1Debugger.exe': Loaded 'C:\WINDOWS\system32\secur32.dll'
'EE1Debugger.exe': Loaded 'C:\WINDOWS\system32\lpk.dll'
'EE1Debugger.exe': Loaded 'C:\WINDOWS\system32\usp10.dll'
'EE1Debugger.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll'
'EE1Debugger.exe': Loaded 'C:\WINDOWS\system32\GDX32.dll', Binary was not built with debug information.
'EE1Debugger.exe': Loaded 'C:\WINDOWS\system32\acaptuser32.dll', Binary was not built with debug information.
'EE1Debugger.exe': Unloaded 'C:\WINDOWS\system32\acaptuser32.dll'
'EE1Debugger.exe': Loaded 'C:\WINDOWS\system32\uxtheme.dll'
'EE1Debugger.exe': Loaded 'C:\WINDOWS\system32\MSCTF.dll'
'EE1Debugger.exe': Loaded 'C:\Program Files\Trusteer\Rapport\bin\rooksbas.dll'
'EE1Debugger.exe': Loaded 'C:\WINDOWS\system32\version.dll'
'EE1Debugger.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll'
'EE1Debugger.exe': Loaded 'C:\WINDOWS\system32\psapi.dll'
'EE1Debugger.exe': Loaded 'C:\WINDOWS\system32\shell32.dll'
'EE1Debugger.exe': Loaded 'C:\WINDOWS\system32\ole32.dll'
'EE1Debugger.exe': Loaded 'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.5512_x-ww_35d4ce83\comctl32.dll'
'EE1Debugger.exe': Loaded 'C:\WINDOWS\system32\comctl32.dll'
'EE1Debugger.exe': Loaded 'C:\WINDOWS\system32\MSCTFIME.IME'
'EE1Debugger.exe': Loaded 'C:\WINDOWS\system32\PickWord.dll', Binary was not built with debug information.
'EE1Debugger.exe': Loaded 'C:\Program Files\Dell\QuickSet\dadkeyb.dll', Binary was not built with debug information.
'EE1Debugger.exe': Loaded 'C:\WINDOWS\system32\hccutils.dll', Binary was not built with debug information.
'EE1Debugger.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll'
The program '[29312] EE1Debugger.exe: Native' has exited with code 3 (0x3).


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net