Main thread hang but madExcept doesn't generate bug report

delphi package - automated exception handling
Post Reply
laconical
Posts: 6
Joined: Thu Feb 04, 2010 12:28 am

Main thread hang but madExcept doesn't generate bug report

Post by laconical »

Hi all,

I've recently updated an application from RAD Studio 2009 to RAD Studio XE6 (C++). I'm now encountering a problem where the application randomly hangs, so I enabled the CheckForFrozenMainThread option and set the FreezeTimeout to 30000. Well the application froze again today but even after leaving it for a number of minutes there was no bug report generated. I created a minidump and was able use a tool (https://github.com/andremussche/asmprofiler) to get a stack trace of all of the threads (the main thread stack is listed below). Any ideas on why madExcept isn't generating a bug report when the main thread freezes? I'm also confused as to what would be causing the hang since the last thing executed seems to be a FreeMem call in rtl200.bpl...

Thanks

Andrew

Code: Select all

(000042A2){borlndmm.dll} [500352A2] Unknown function at @Borlndmm@SysFreeMem$qqrpv + $EE
(00008974){rtl200.bpl  } [50059974] System.@FreeMem + $4
(00013689){rtl200.bpl  } [50064689] System.@DynArrayClear + $35
(0002F34C){dbrtl200.bpl} [50BA034C] Data.Db.TStringField.GetValue + $DC
(0000F242){rtl200.bpl  } [50060242] System.@HandleFinally + $5A
(00010640){madBasic_.bpl} [57011640] Madtools.FindModule + $F4
(0000DF27){KERNELBASE.dll} [7774EF27] VirtualQueryEx + $17
(0000DFF4){KERNELBASE.dll} [7774EFF4] VirtualQuery + $10
(0001DB57){madExcept_.bpl} [5981EB57] Madexcept.GetThreadCreatorAddr + $50F
(0000F006){rtl200.bpl  } [50060006] System.@HandleAnyException + $D2
(00011845){madBasic_.bpl} [57012845] Madtools.IsBadReadPtr2 + $11
(00008958){rtl200.bpl  } [50059958] System.@GetMem + $4
(0000FEEF){rtl200.bpl  } [50060EEF] System.@NewAnsiString + $F
(00010152){rtl200.bpl  } [50061152] System.@LStrFromPCharLen + $2A
(0001DB1E){madExcept_.bpl} [5981EB1E] Madexcept.GetThreadCreatorAddr + $4D6
(00008974){rtl200.bpl  } [50059974] System.@FreeMem + $4
(0000FF68){rtl200.bpl  } [50060F68] System.@UStrClr + $1C
(0001DB57){madExcept_.bpl} [5981EB57] Madexcept.GetThreadCreatorAddr + $50F
(00008974){rtl200.bpl  } [50059974] System.@FreeMem + $4
(00010411){rtl200.bpl  } [50061411] System.@LStrAsg + $41
(0001DB1E){madExcept_.bpl} [5981EB1E] Madexcept.GetThreadCreatorAddr + $4D6
(00008974){rtl200.bpl  } [50059974] System.@FreeMem + $4
(0000FF68){rtl200.bpl  } [50060F68] System.@UStrClr + $1C
(0001DB57){madExcept_.bpl} [5981EB57] Madexcept.GetThreadCreatorAddr + $50F
(00008974){rtl200.bpl  } [50059974] System.@FreeMem + $4
(00010411){rtl200.bpl  } [50061411] System.@LStrAsg + $41
(0001DB1E){madExcept_.bpl} [5981EB1E] Madexcept.GetThreadCreatorAddr + $4D6
(00008974){rtl200.bpl  } [50059974] System.@FreeMem + $4
(0000FF68){rtl200.bpl  } [50060F68] System.@UStrClr + $1C
(0001DB57){madExcept_.bpl} [5981EB57] Madexcept.GetThreadCreatorAddr + $50F
(0001DBF2){madExcept_.bpl} [5981EBF2] Madexcept.GetThreadCreatorAddr + $5AA
(0000DC7A){KERNELBASE.dll} [7774EC7A] ReadProcessMemory + $15
(0001DD19){madExcept_.bpl} [5981ED19] Madexcept.GetThreadCreatorAddr + $6D1
(000005C2){madExcept_.bpl} [598015C2]  + $0
(0000F006){rtl200.bpl  } [50060006] System.@HandleAnyException + $D2
(0002E222){dbrtl200.bpl} [50B9F222] Data.Db.TField.SetData + $9A
(0002E271){dbrtl200.bpl} [50B9F271] Data.Db.TField.SetData + $E9
(00003275){mosaic_desktop.exe} [00404275]  + $0
(0019AE91){mosaic_desktop.exe} [0059BE91]  + $0
(0014B43A){mosaic_desktop.exe} [0054C43A] ..\VisRep\frStat.cpp.tblStatCalcFields (Line 206, "..\VisRep\frStat.cpp") + $D2
(00003437){oleaut32.dll} [777D4437] Unknown function at GetErrorInfo + $516
(0006D313){rtl200.bpl  } [500BE313] System.@Variants.VarToUStr + $5D7
(00008958){rtl200.bpl  } [50059958] System.@GetMem + $4
(0000FEAE){rtl200.bpl  } [50060EAE] System.@NewUnicodeString + $E
(000100DF){rtl200.bpl  } [500610DF] System.@UStrFromPWCharLen + $B
(00003652){RDAXE6.bpl  } [007C4652] Cached.pas.TCachedDataSet.GetFieldData$qqrp14Data.Db.TFieldr25System.%DynamicArray$tuc% (Line 623, "Cached.pas") + $8
(00067BBD){rtl200.bpl  } [500B8BBD] System.@Variants.VarClr + $1
(0002BD9C){CompMOSAIC.bpl} [0751CD9C] ..\CompMOSAIC\MosTable.cpp.GetFieldData (Line 993, "..\CompMOSAIC\MosTable.cpp") + $9
(0003FAE4){dbrtl200.bpl} [50BB0AE4] Data.Db.TDataSet.GetFieldData + $38
(00003AA8){CompMOSAIC.bpl} [074F4AA8] ..\CompMOSAIC\MosaicQuery.cpp.TCachedDataSet.GetFieldData (Line 223, "r:\devxe6\rda\Cached.hpp") + $1C
(0002BDC4){CompMOSAIC.bpl} [0751CDC4] ..\CompMOSAIC\MosTable.cpp.GetFieldData (Line 1001, "..\CompMOSAIC\MosTable.cpp") + $D
(0002D2ED){dbrtl200.bpl} [50B9E2ED] Data.Db.TField.GetData + $A1
(00013535){rtl200.bpl  } [50064535] System.@DynArraySetLength + $5
(0002F2E7){dbrtl200.bpl} [50BA02E7] Data.Db.TStringField.GetValue + $77
(0002F17E){dbrtl200.bpl} [50BA017E] Data.Db.TStringField.GetAsVariant + $1E
(0004E527){cxDataRS20.bpl} [03E6F527] cxDB.GetFieldValue$qqrp14Data.Db.TField (Line 394, "cxDB.pas") + $8
(0005CB6E){cxDataRS20.bpl} [03E7DB6E] cxDBData.TcxValueDefDBReader.GetValue$qqrp25Cxdatastorage.TcxValueDef (Line 3391, "cxDBData.pas") + $6
(000110DF){cxDataRS20.bpl} [03E320DF] cxDataStorage.TcxDataStorage.ReadRecord$qqrip31Cxdatastorage.TcxValueDefReader (Line 2343, "cxDataStorage.pas") + $B
(0003B1DE){cxDataRS20.bpl} [03E5C1DE] cxCustomData.LoadData (Line 7187, "cxCustomData.pas") + $F
(0003B360){cxDataRS20.bpl} [03E5C360] cxCustomData.TcxCustomDataController.LoadStorage$qqrv (Line 7226, "cxCustomData.pas") + $1
(00060E44){cxDataRS20.bpl} [03E81E44] cxDBData.TcxDBDataController.LoadStorage$qqrv (Line 5213, "cxDBData.pas") + $3
(0003BA56){cxDataRS20.bpl} [03E5CA56] cxCustomData.TcxCustomDataController.UpdateStorage$qqro (Line 7453, "cxCustomData.pas") + $5
(0003BD94){cxDataRS20.bpl} [03E5CD94] cxCustomData.TcxCustomDataController.DataChanged$qqr26Cxcustomdata.TcxDataChangeii (Line 7555, "cxCustomData.pas") + $5
(00043A47){cxDataRS20.bpl} [03E64A47] cxCustomData.TcxCustomDataProvider.DataChanged$qqr26Cxcustomdata.TcxDataChangeii (Line 11422, "cxCustomData.pas") + $12
(00058A26){cxDataRS20.bpl} [03E79A26] cxDBData.TcxDBDataLink.DataSetChanged$qqrv (Line 1616, "cxDBData.pas") + $F
(000396CE){dbrtl200.bpl} [50BAA6CE] Data.Db.TDataLink.DataEvent + $BA
(00058838){cxDataRS20.bpl} [03E79838] cxDBData.TcxDBDataLink.DataEvent$qqr18Data.Db.TDataEventi (Line 1557, "cxDBData.pas") + $9
(00039C5F){dbrtl200.bpl} [50BAAC5F] Data.Db.TDataSource.NotifyLinkTypes + $43
(00039C92){dbrtl200.bpl} [50BAAC92] Data.Db.TDataSource.NotifyDataLinks + $1E
(00039CBF){dbrtl200.bpl} [50BAACBF] Data.Db.TDataSource.DataEvent + $23
(0004102C){dbrtl200.bpl} [50BB202C] Data.Db.TDataSet.DataEvent + $17C
(0004179D){dbrtl200.bpl} [50BB279D] Data.Db.TDataSet.Resync + $18D
(0002B576){CompMOSAIC.bpl} [0751C576] ..\CompMOSAIC\MosTable.cpp.Resync (Line 837, "..\CompMOSAIC\MosTable.cpp") + $6
(00041EFC){dbrtl200.bpl} [50BB2EFC] Data.Db.TDataSet.Refresh + $54
(0014B679){mosaic_desktop.exe} [0054C679] ..\VisRep\frStat.cpp.timRefreshTimer (Line 254, "..\VisRep\frStat.cpp") + $9
(000EA17B){vcl200.bpl  } [505AB17B] Vcl.Extctrls.TTimer.Timer + $F
(000EA05F){vcl200.bpl  } [505AB05F] Vcl.Extctrls.TTimer.WndProc + $2B
(001256E4){rtl200.bpl  } [501766E4] System.Classes.TDataModule.WriteHeight + $20
(000152F7){user32.dll  } [778762F7] Unknown function at gapfnScSendMessage + $32F
(00015D35){user32.dll  } [77876D35] Unknown function at GetThreadDesktop + $D2
(00015CE3){user32.dll  } [77876CE3] Unknown function at GetThreadDesktop + $80
(000167BF){user32.dll  } [778777BF] Unknown function at CharPrevW + $133
(00016885){user32.dll  } [77877885] DispatchMessageW + $A
(00181EDF){vcl200.bpl  } [50642EDF] Vcl.Forms.TApplication.ProcessMessage + $F3
(00181F22){vcl200.bpl  } [50642F22] Vcl.Forms.TApplication.HandleMessage + $A
(00182255){vcl200.bpl  } [50643255] Vcl.Forms.TApplication.Run + $C9
(00003CFA){mosaic_desktop.exe} [00404CFA] MOSAIC_Desktop.cpp.WinMain (Line 85, "MOSAIC_Desktop.cpp" + -8971) + $7
(00098665){CC32150MT.DLL} [32F99665] __startup + $14D
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Main thread hang but madExcept doesn't generate bug repo

Post by madshi »

I'm not sure if we can fully trust the stack trace from the minidump. Anyway, according to the stack trace, an exception occurred while doing database stuff, then madExcept got active and tries to analyze the crash. And if the stack trace is correct, it got stuck in FreeMem. Of course if the memory manager freezes, for some reason, then madExcept can't report the freeze, because in order to do so madExcept needs the memory manager to work.

What happens if the crash occurs and you then run the "madTraceProcess.exe" tool from the madExcept\Tools folder? Do you get a proper bug report then? I suppose not, but it's worth a try...
laconical
Posts: 6
Joined: Thu Feb 04, 2010 12:28 am

Re: Main thread hang but madExcept doesn't generate bug repo

Post by laconical »

Thanks for the response - turns out I had some sort of memory corruption caused by a TDataSet descendant class that wasn't updated correctly when I upgraded from RAD Studio 2009 to XE6. Rewrote that and no more freezing.
madshi wrote:I'm not sure if we can fully trust the stack trace from the minidump. Anyway, according to the stack trace, an exception occurred while doing database stuff, then madExcept got active and tries to analyze the crash. And if the stack trace is correct, it got stuck in FreeMem. Of course if the memory manager freezes, for some reason, then madExcept can't report the freeze, because in order to do so madExcept needs the memory manager to work.

What happens if the crash occurs and you then run the "madTraceProcess.exe" tool from the madExcept\Tools folder? Do you get a proper bug report then? I suppose not, but it's worth a try...
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Main thread hang but madExcept doesn't generate bug repo

Post by madshi »

Good to hear you got it sorted out. But yes, memory corruption can cause all sorts of weird problems. It can totally screw up the memory manager, and that could very well stop madExcept from working correctly.
Post Reply