Exceptions not cached by madExcept

delphi package - automated exception handling
Post Reply
shragam
Posts: 14
Joined: Thu Mar 17, 2022 10:41 am

Exceptions not cached by madExcept

Post by shragam »

Hi
I have a win 32 application on win10 and the application just shutdown by windows randomly without and exception in madExcept.
The application create threads while execute and the thread have try except blocks.
If I'm looking in the event viewer, I can see that windows close it.
Log Name: Application
Source: Application Error
Date: 07/11/2022 09:04:01
Event ID: 1000
Task Category: (100)
Level: Error
Keywords: Classic
User: N/A
Computer: DESKTOP-NFTHH7F
Description:
Faulting application name: Mate_Srv.exe, version: 4.0.0.0, time stamp: 0x6368ad67
Faulting module name: unknown, version: 0.0.0.0, time stamp: 0x00000000
Exception code: 0xc0000005
Fault offset: 0x0a0376dc
Faulting process id: 0x558
Faulting application start time: 0x01d8f27716412ba3
Faulting application path: C:\Moked_Azakot\Mate_Srv.exe
Faulting module path: unknown
Report Id: e0eec279-ac18-41d4-b31f-56122da73b8f
Faulting package full name:
Faulting package-relative application ID:
Event Xml:
<Event xmlns="http://schemas.microsoft.com/win/2004/08/events/event">
<System>
<Provider Name="Application Error" />
<EventID Qualifiers="0">1000</EventID>
<Version>0</Version>
<Level>2</Level>
<Task>100</Task>
<Opcode>0</Opcode>
<Keywords>0x80000000000000</Keywords>
<TimeCreated SystemTime="2022-11-07T07:04:01.7102510Z" />
<EventRecordID>10817</EventRecordID>
<Correlation />
<Execution ProcessID="0" ThreadID="0" />
<Channel>Application</Channel>
<Computer>DESKTOP-NFTHH7F</Computer>
<Security />
</System>
<EventData>
<Data>Mate_Srv.exe</Data>
<Data>4.0.0.0</Data>
<Data>6368ad67</Data>
<Data>unknown</Data>
<Data>0.0.0.0</Data>
<Data>00000000</Data>
<Data>c0000005</Data>
<Data>0a0376dc</Data>
<Data>558</Data>
<Data>01d8f27716412ba3</Data>
<Data>C:\Moked_Azakot\Mate_Srv.exe</Data>
<Data>unknown</Data>
<Data>e0eec279-ac18-41d4-b31f-56122da73b8f</Data>
<Data>
</Data>
<Data>
</Data>
</EventData>
</Event>
Why madExcept doesn't catch this exception ?
Thanks
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Re: Exceptions not cached by madExcept

Post by madshi »

Is it a normal application or a service? What happens if you intentionally raise a test exception, e.g. an access violation by doing "integer(nil^) := 0"? Does madExcept catch that?

Generally, madExcept only cares about unhandled exceptions. If you have try..except blocks in your threads that "handle" exceptions, madExcept won't become active. If you want madExcept to catch and report exceptions, maybe you want to remove those try..except blocks? Or call "madExcept.HandleException()" in them? I don't think that explains the sudden shutdowns, though.

If your program suddenly shuts down, that can have multiple reasons. I assume it's in the middle of its runtime? In that case, it could be:

1) There could have been a buffer overrun, overwriting important memory, resulting in catastrophic problems.
2) Maybe the memory manager stopped working, which will also impact madExcept's ability to work. This could be due to out of memory problems (although madExcept has some protection against out of memory problems), or memory corruption or other things.
3) There could be endless recursion in the main thread, resulting in a stack overflow.
4) Probably some other reasons...

As a first test, I'd recommend trying to activate leak reporting and/or the "instantly crash on buffer overrun" features in madExcept. These features will heavily increase your RAM consumption, though, so if you have bad luck, your program might run into "out of memory" problems quickly. If you can compile and run your program as 64bit, please do that, when using these madExcept features, that will help a lot avoiding "out of memory" problems. If you're lucky, these features might work and point you to problems in your program which might cause these issues.
shragam
Posts: 14
Joined: Thu Mar 17, 2022 10:41 am

Re: Exceptions not cached by madExcept

Post by shragam »

Sorry for the late response.
This is a VCL win32 application .
I'll create a specific test as you advice and update you.
The interesting thins is every thread was in try .. except block in the execute and still crash while running a few seconds or minutes randomly.
There is no recursion in my code.
I can compile my application in 64 bit, but I also try your recommendation.
Thank
Shraga
shragam
Posts: 14
Joined: Thu Mar 17, 2022 10:41 am

Re: Exceptions not cached by madExcept

Post by shragam »

I found the exception in my code :-)
It was in code with try finally that not raised it.
Thanks
Post Reply