Exception possibly causing recursion in exception handler.

delphi package - automated exception handling
Post Reply
DamienWright
Posts: 2
Joined: Wed Sep 27, 2017 11:57 am

Exception possibly causing recursion in exception handler.

Post by DamienWright »

We are experiencing a strange exception which seems to eventually lead to a Stack overflow exception with the following call stack. The error seems to possibly be caused by RtlProcessFlsData and I did find an article here with similar callstack and an explanation as to the cause. (Though our code is native Delphi 32 bit using Delphi 10.1)

https://support.microsoft.com/en-us/hel ... -not-freed

Code: Select all

processors         : 8x Intel(R) Core(TM) i7-7700 CPU @ 3.60GHz
physical memory    : 2420/8058 MB (free/total)
free disk space    : (C:) 885.26 GB
display mode       : 1920x1080, 32 bit
process id         : $56e8
allocated memory   : 133.99 MB
largest free block : 1006.55 MB
executable         : DatalogMV.exe
exec. date/time    : 2019-02-15 09:23
version            : 103.0.1.64
compiled with      : Delphi 10.1 Berlin
madExcept version  : 4.0.20
callstack crc      : $f19b1617, $d57e1117, $a1cfc21d
exception number   : 487
exception class    : EStackOverflow
exception message  : Stack overflow.

thread $508:
004125aa +00e DatalogMV.exe System          1294 +0 LoadResString
00433155 +055 DatalogMV.exe System.SysUtils         CreateAVObject
0043337d +065 DatalogMV.exe System.SysUtils         GetExceptionObject
006dd89c +04c DatalogMV.exe madExcept               InterceptExceptionHandler
773e1ab1 +021 ntdll.dll                             KiUserExceptionDispatcher
773d189f +11f ntdll.dll                             RtlProcessFlsData
773b876c +05c ntdll.dll                             LdrShutdownThread
773d69e7 +047 ntdll.dll                             RtlExitUserThread
006dd23d +069 DatalogMV.exe madExcept               InterceptExceptProc
006dd8aa +05a DatalogMV.exe madExcept               InterceptExceptionHandler
773e1ab1 +021 ntdll.dll                             KiUserExceptionDispatcher
773d189f +11f ntdll.dll                             RtlProcessFlsData
773b876c +05c ntdll.dll                             LdrShutdownThread
773d69e7 +047 ntdll.dll                             RtlExitUserThread
006dd23d +069 DatalogMV.exe madExcept               InterceptExceptProc
006dd8aa +05a DatalogMV.exe madExcept               InterceptExceptionHandler
773e1ab1 +021 ntdll.dll                             KiUserExceptionDispatcher
773d189f +11f ntdll.dll                             RtlProcessFlsData
773b876c +05c ntdll.dll                             LdrShutdownThread
773d69e7 +047 ntdll.dll                             RtlExitUserThread
006dd23d +069 DatalogMV.exe madExcept               InterceptExceptProc
006dd8aa +05a DatalogMV.exe madExcept               InterceptExceptionHandler
773e1ab1 +021 ntdll.dll                             KiUserExceptionDispatcher
773d189f +11f ntdll.dll                             RtlProcessFlsData
773b876c +05c ntdll.dll                             LdrShutdownThread
773d69e7 +047 ntdll.dll                             RtlExitUserThread
006dd23d +069 DatalogMV.exe madExcept               InterceptExceptProc
006dd8aa +05a DatalogMV.exe madExcept               InterceptExceptionHandler
773e1ab1 +021 ntdll.dll                             KiUserExceptionDispatcher
773d189f +11f ntdll.dll                             RtlProcessFlsData
773b876c +05c ntdll.dll                             LdrShutdownThread
773d69e7 +047 ntdll.dll                             RtlExitUserThread
006dd23d +069 DatalogMV.exe madExcept               InterceptExceptProc
006dd8aa +05a DatalogMV.exe madExcept               InterceptExceptionHandler
773e1ab1 +021 ntdll.dll                             KiUserExceptionDispatcher
773d189f +11f ntdll.dll                             RtlProcessFlsData
773b876c +05c ntdll.dll                             LdrShutdownThread
773d69e7 +047 ntdll.dll                             RtlExitUserThread
006dd23d +069 DatalogMV.exe madExcept               InterceptExceptProc
006dd8aa +05a DatalogMV.exe madExcept               InterceptExceptionHandler
773e1ab1 +021 ntdll.dll                             KiUserExceptionDispatcher
773d189f +11f ntdll.dll                             RtlProcessFlsData
773b876c +05c ntdll.dll                             LdrShutdownThread
773d69e7 +047 ntdll.dll                             RtlExitUserThread
006dd23d +069 DatalogMV.exe madExcept               InterceptExceptProc
006dd8aa +05a DatalogMV.exe madExcept               InterceptExceptionHandler
773e1ab1 +021 ntdll.dll                             KiUserExceptionDispatcher
773d189f +11f ntdll.dll                             RtlProcessFlsData
773b876c +05c ntdll.dll                             LdrShutdownThread
773d69e7 +047 ntdll.dll                             RtlExitUserThread
006dd23d +069 DatalogMV.exe madExcept               InterceptExceptProc
006dd8aa +05a DatalogMV.exe madExcept               InterceptExceptionHandler
773e1ab1 +021 ntdll.dll                             KiUserExceptionDispatcher
773d189f +11f ntdll.dll                             RtlProcessFlsData
773b876c +05c ntdll.dll                             LdrShutdownThread
773d69e7 +047 ntdll.dll                             RtlExitUserThread
006dd23d +069 DatalogMV.exe madExcept               InterceptExceptProc
006dd8aa +05a DatalogMV.exe madExcept               InterceptExceptionHandler
773e1ab1 +021 ntdll.dll                             KiUserExceptionDispatcher
773d189f +11f ntdll.dll                             RtlProcessFlsData
773b876c +05c ntdll.dll                             LdrShutdownThread
773d69e7 +047 ntdll.dll                             RtlExitUserThread
006dd23d +069 DatalogMV.exe madExcept               InterceptExceptProc
006dd8aa +05a DatalogMV.exe madExcept               InterceptExceptionHandler
773e1ab1 +021 ntdll.dll                             KiUserExceptionDispatcher
773d189f +11f ntdll.dll                             RtlProcessFlsData
773b876c +05c ntdll.dll                             LdrShutdownThread
773d69e7 +047 ntdll.dll                             RtlExitUserThread
0040c479 +015 DatalogMV.exe System          1294 +0 EndThread
004cded2 +0a6 DatalogMV.exe System.Classes          ThreadProc
0040c3dc +028 DatalogMV.exe System          1294 +0 ThreadWrapper
006ddddd +00d DatalogMV.exe madExcept               CallThreadProcSafe
006dde42 +032 DatalogMV.exe madExcept               ThreadExceptFrame
761a8672 +022 KERNEL32.DLL                          BaseThreadInitThunk

main thread ($37d0):
75e76605 +095 KERNELBASE.dll                                SleepEx
75e7655a +00a KERNELBASE.dll                                Sleep
0040ad8f +033 DatalogMV.exe  System                1294  +0 TMonitor.TSpinWait.SpinCycle
0040b136 +09a DatalogMV.exe  System                1294  +0 TMonitor.Enter
004cdc70 +084 DatalogMV.exe  System.Classes                 CheckSynchronize
004ceeae +08a DatalogMV.exe  System.Classes                 TThread.WaitFor
00f8d4fa +01e DatalogMV.exe  ProcessWD               48  +3 TProcessWDThread.Destroy
0040a624 +008 DatalogMV.exe  System                1294  +0 TObject.Free
00f922fa +1ba DatalogMV.exe  HostPlugin             567 +18 THostPlugin.TerminatePlugin
00f91cfa +026 DatalogMV.exe  HostPlugin             469  +2 THostPlugin.Restart
00f982bf +06f DatalogMV.exe  HostPlugin            1424  +5 THostPlugin.OnServerRPCStateChange
00f710bf +00f DatalogMV.exe  DVRRPC                 462  +2 TRPCMessenger.TransportStateChange
00f72376 +012 DatalogMV.exe  DVRRPC                 772  +3 TRPCTransport.ChangeState
00f72e4d +00d DatalogMV.exe  DVRRPC                 998  +1 TRPCTransportTCP.OnSocketDisconnect
00ee8018 +018 DatalogMV.exe  OverbyteIcsWSocketS    805  +2 TCustomWSocketServer.TriggerClientDisconnect
00ee80d8 +06c DatalogMV.exe  OverbyteIcsWSocketS    850  +7 TCustomWSocketServer.WMClientClosed
00ee7c8a +02a DatalogMV.exe  OverbyteIcsWSocketS    663  +5 TCustomWSocketServer.WndProc
00ea35e7 +087 DatalogMV.exe  OverbyteIcsWndControl 1141  +6 TIcsWndHandler.WndProc
00ea26a3 +04f DatalogMV.exe  OverbyteIcsWndControl  473 +30 WndControlWindowsProc
75ff8c1b +00b user32.dll                                    DispatchMessageW
006136c7 +0f3 DatalogMV.exe  Vcl.Forms                      TApplication.ProcessMessage
0061370a +00a DatalogMV.exe  Vcl.Forms                      TApplication.HandleMessage
00613a3d +0c9 DatalogMV.exe  Vcl.Forms                      TApplication.Run
0115cc98 +0d4 DatalogMV.exe  DatalogMV               56 +16 initialization
761a8672 +022 KERNEL32.DLL                                  BaseThreadInitThunk
Whilst the underlying error is probably in the code being invoked by TProcessWDThread.Destroy I suspect this might be leading to some kind of recursion in the exception handler leading to a stack overflow. Please could you double check if this is possible on the 4.0.20 release of MadExcept ? We are in the process of updating to the subscription service to obtain the latest versions (but our internal process for this kind of procurement is slow).

Best regards,

Damien.
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Exception possibly causing recursion in exception handle

Post by madshi »

It seems that madExcept's call to "ExitThread" results in another exception being raised, which again is captured by madExcept, which results in another try to close the thread by calling "ExitThread". To be honest, I'm not sure what I'm supposed other than calling "ExitThread"? If such a simple an essential win32 API keeps crashing, what could madExcept possibly do about it?
bkdroid13
Posts: 4
Joined: Fri Jun 07, 2019 8:43 am

Re: Exception possibly causing recursion in exception handle

Post by bkdroid13 »

Its great post and help me a lot. please keep continue posting. thats just what i wanted to know. :D
Post Reply