Re: Debug help please...



See below...
On Wed, 1 Aug 2007 10:42:35 +0100, "GT" <ContactGT_remove_@xxxxxxxxxxx> wrote:

I have just discovered a bug in my application. This bug is only present in
the debug version, so the release version is fine.
****
No, it isn't. The release version is also broken, but unlike the debug version, IT DOES
NOT REPORT THE PROBLEM, and therefore it is not noticed. However, the program is almost
certainly broken. Just because the release version doesn't report it does not mean the
bug does not exist. So you find and fix the bug.
****
Restoring backups shows
that the bug has been there for months - way back to when the application
barely worked, so it is something fundamental. Problem is that I have never
seen this error message before and don't know where to start diagnosing the
problem. The application stops with a 3 line message box:

Windows has triggered a breakpoint in Circa.exe.

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

The output window may have more diagnostic information

The output window is pretty long, so I have included it at the end of this
message. When I press the 'break' button and step into the place in the code
where the error is being reported, nothing makes sense - the break seems to
be in one of 2 places - one is half way through an OnInit method in a dialog
that I haven't even called. (A breakpoint in there, isn't hit). The other
place is in the childframe when loading an icon, but again attempts to debug
don't make sense - a watch on any of the local variables in the method where
the crash is reported can't be evaluated, so I guess the debugger is getting
confused and showing me the wrong thread place???

I suspect that the line towards the end of the output window is the key -
"Heap block 24b0f0 modified at 24b110 after it was freed", but how do I go
about debugging this problem. Or would you say something else is the root of
the problem and this is just a symptom?

Help!


My Output Window:

'Circa.exe': Loaded 'D:\Tassc\Circa\Testarea Debug\Circa.exe', Symbols
loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\ntdll.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\kernel32.dll', No symbols loaded.
'Circa.exe': Loaded 'D:\Tassc\Circa\Testarea Debug\Model.dll', Symbols
loaded.
'Circa.exe': Loaded
'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugMFC_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_257740a4\mfc80d.dll',
Symbols loaded.
'Circa.exe': Loaded
'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.DebugCRT_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_5490cd9f\msvcr80d.dll',
Symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\msvcrt.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\gdi32.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\user32.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\shlwapi.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\advapi32.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\rpcrt4.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\shell32.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\oleaut32.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\ole32.dll', No symbols loaded.
'Circa.exe': Loaded
'C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.2982_x-ww_ac3f9c03\comctl32.dll',
No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\winmm.dll', No symbols loaded.
'Circa.exe': Loaded
'C:\WINDOWS\WinSxS\x86_Microsoft.VC80.MFCLOC_1fc8b3b9a1e18e3b_8.0.50727.762_x-ww_91481303\mfc80ENU.dll',
Binary was not built with debug information.
'Circa.exe': Loaded 'C:\WINDOWS\system32\msimg32.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\uxtheme.dll', No symbols loaded.
Warning: no shared menu for document template #129.
Warning: no shared menu for document template #129.
'Circa.exe': Loaded 'C:\WINDOWS\system32\clbcatq.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\comres.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\version.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\xpsp2res.dll', Binary was not built
with debug information.
'Circa.exe': Loaded 'C:\WINDOWS\system32\riched32.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\riched20.dll', No symbols loaded.
Warning: CMDIFrameWnd without a default menu.
Warning: Could not load type library from d:\Tassc\Circa\Testarea
Debug\Circa.exe
'Circa.exe': Loaded 'C:\WINDOWS\system32\SASE.OCX', Binary was not built
with debug information.
'Circa.exe': Loaded 'C:\WINDOWS\system32\olepro32.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\sxs.dll', No symbols loaded.
TRACE Warning: Navigator window not available yet in
CMainFrame::GetDocument() (GT)
'Circa.exe': Loaded 'C:\WINDOWS\system32\shdocvw.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\crypt32.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\msasn1.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\cryptui.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\wintrust.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\imagehlp.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\netapi32.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\wininet.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\wldap32.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\secur32.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\setupapi.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\urlmon.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\shdoclc.dll', Binary was not built
with debug information.
'Circa.exe': Loaded 'C:\WINDOWS\system32\mlang.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\mshtml.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\msls31.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\psapi.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\msimtf.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\msctf.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\imm32.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\apphelp.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\Program Files\Common Files\Microsoft
Shared\DAO\dao360.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\msjet40.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\mswstr10.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\vbajet32.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\expsrv.dll', No symbols loaded.
'Circa.exe': Unloaded 'C:\WINDOWS\system32\vbajet32.dll'
'Circa.exe': Loaded 'C:\WINDOWS\system32\msjtes40.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\vbajet32.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\msjter40.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\msjint40.dll', No symbols loaded.
****
Essentially, you can ignore all the "No symbols loaded" messages
****

DAO Call Failed.
m_pQueryDef->m_pDAOQueryDef->_30_OpenRecordset(
COleVariant((long)m_nOpenType), COleVariant((long)m_nOptions),
&m_pDAORecordset)
In file f:\sp\vctools\vc7libs\ship\atlmfc\src\mfc\daocore.cpp on line 3420
scode = 800A0C06

Error Code = 3078
Source = DAO.Database
Description = The Microsoft Jet database engine cannot find the input table
or query 'TEreportsettingssecond'. Make sure it exists and that its name is
spelled correctly.
First-chance exception at 0x7c812a5b in Circa.exe: Microsoft C++ exception:
CDaoException at memory location 0x0012d5a8..
'Circa.exe': Loaded 'C:\WINDOWS\system32\wdmaud.drv', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\msacm32.drv', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\msacm32.dll', No symbols loaded.
'Circa.exe': Loaded 'C:\WINDOWS\system32\midimap.dll', No symbols loaded.
Warning: calling DestroyWindow in CDialog::~CDialog --
OnDestroy or PostNcDestroy in derived class will not be called.
Warning: calling DestroyWindow in CDialog::~CDialog --
OnDestroy or PostNcDestroy in derived class will not be called.
Warning: calling DestroyWindow in CDialog::~CDialog --
OnDestroy or PostNcDestroy in derived class will not be called.
Warning: calling DestroyWindow in CDialog::~CDialog --
OnDestroy or PostNcDestroy in derived class will not be called.
HEAP[Circa.exe]: HEAP: Free Heap block 24b0f0 modified at 24b110 after it
was freed
Windows has triggered a breakpoint in Circa.exe.
****
This is a pretty obvious message! It says that you modified a block of memory after it
was freed. For example
MyStructure * p = new MyStructure;
p->field = value;
delete p;
p->field = value;
will generate this error. Going back to my original comment, this bug was ALWAYS there,
even in the release version, but guess what---the release library does not do the extra
checks required to detect and report this error, so you will not get an error in the
release version. That's why we have "Debug" and "Release" versions...you don't even
bother to build a release version until the debug version is fully checked.

So you need to carefully inspect every place you do a delete and make sure that the
structure is not accessed. In the simple case above, I might consider doing
delete somepointer->thing;
somepointer->thing = NULL;

so the more obvious errors are caught by taking a null-pointer access. This doesn't
happen if you have multiple pointers, such as
somepointer->thing = new whatever;
...
otherpointer->thing = somepointer->thing;
...
delete somepointer->thing;
somepointer->thing = NULL;

otherpointer->thing->field = 17;

note that the second pointer still exists, even though the delete has rendered it
meaningless., and the error you see above will be generated.

Essentially, you have a serious bug and you have to fix it. Just because the release
version doesn't TELL you that you have a bug does not mean there is not a bug.

Another possibility, less likely, is that you had a buffer overrun that happened to
clobber some free storage, for example
int * someting = new int[20];
something[30] = 5;
note that you have a bounds error, but because you went 'way beyond the end of the
storage, thus skipping the header of the next block (thus avoiding the error message that
a header has been corrupted). One way to avoid this kind of error is to always use CArray
or std::vector which are bound-checked.

If you don't know how storage allocators work, see my essay on this on my MVP Tips site.

One way to find these a bit more quickly is to download the Application Verifier from the
Microsoft Web site, and run your app with the AppVerifier enabled. This applies even
stronger checks, such as allocating one object per page, and when the object is deleted,
the page is removed from the page map, so any attempt to write into it, even from another
poitner, causes an access failure.
joe
****

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

The output window may have more diagnostic information

Joseph M. Newcomer [MVP]
email: newcomer@xxxxxxxxxxxx
Web: http://www.flounder.com
MVP Tips: http://www.flounder.com/mvp_tips.htm
.



Relevant Pages

  • Debug help please...
    ... I have just discovered a bug in my application. ... the debug version, so the release version is fine. ... The output window is pretty long, so I have included it at the end of this ... Binary was not built with debug information. ...
    (microsoft.public.vc.mfc)
  • Re: [off topic]Strange Behaviour -- adding printf change the progra execution
    ... i just simply adding few debug like below and it changes program ... and a corresponding delay in the execution of other ... The problem is, if you've got a bug in your code, it has a pretty good ... source code, making it harder to detect the real defect. ...
    (comp.lang.c)
  • Re: trouble creating array of objects
    ... >> might try refactoring, but I would preserve the original in case I had ... > is debugging as in getting the bugs out, ... it was so badly written that it was effectively impossible to debug. ... The bug ...
    (alt.comp.lang.learn.c-cpp)
  • Re: Real pain with SegFoult
    ... It is obvious that real bug have place ... This kind of bugs are just a bit more difficult to debug ... always works fine at home but on Solaris it gives me Seqmentation Foults ... I have used a debugger a lot. ...
    (comp.lang.c)
  • ThisApplication_Startup event not firing
    ... However the event will not fire in debug. ... not built with debug information. ... InitializeTrace ...
    (microsoft.public.vsnet.vstools.office)