How to save all the exceptions of type "EAccessViolation"?

delphi package - automated exception handling

How to save all the exceptions of type "EAccessViolation"?

Postby car_hack89 » Fri Jul 20, 2018 12:45 am

Hello,

Is it possible to save all the exceptions of type "EAccessViolation" in the bug report, even if the code has try-except ?. As in the following example:

Code: Select all
procedure FuncX ();
var strList: TStringList;
begin
    try
        strList.Clear; // Here occurs Access Violation
        // ..
    except on E: Exception do
       ShowMessage (E.Message);
    end;
end;


The goal is to save the bug report automatically, so I do not have to manually put it in all try-except of my application.

Thanks in advance.
car_hack89
 
Posts: 21
Joined: Tue Mar 27, 2018 1:30 am

Re: How to save all the exceptions of type "EAccessViolation

Postby madshi » Fri Jul 20, 2018 6:21 am

You can use RegisterHiddenExceptionHandler(). If you set "handled := false" in such a handler, madExcept will start report such "hidden" (handled by a try..except block) exceptions, too.
madshi
Site Admin
 
Posts: 9827
Joined: Sun Mar 21, 2004 5:25 pm

Re: How to save all the exceptions of type "EAccessViolation

Postby car_hack89 » Fri Jul 20, 2018 3:12 pm

Just what I needed.

Thank you!
car_hack89
 
Posts: 21
Joined: Tue Mar 27, 2018 1:30 am

Re: How to save all the exceptions of type "EAccessViolation

Postby car_hack89 » Thu Jul 26, 2018 4:47 pm

Hello,

The proc. RegisterHiddenExceptionHandler(), it was useful, but it impacted the performance of my application. I have the following sample code:

Code: Select all
iCount: = 0;
While iCount <= 1000 do begin
    try
       raise Exception.Create('My test exception');
    except on E: Exception do
    end;
    Inc (iCount);
end;


My result of the previous example is the following:

1) Using the proc. RegisterHiddenExceptionHandler(): 2 minutes, and on some computers it may take 5 or 10 minutes

2) Without the use of proc. RegisterHiddenExceptionHandler(): 0.056 seconds.

Any recommendations with the madExcept configuration?

I tried with TExceptEvent and TExceptEventOO, as well as I tried with the three TSyncType (stDontSync, stTrySyncCallOnSuccess, stTrySyncCallAlways).

Thanks in advance.
car_hack89
 
Posts: 21
Joined: Tue Mar 27, 2018 1:30 am

Re: How to save all the exceptions of type "EAccessViolation

Postby madshi » Thu Jul 26, 2018 5:48 pm

Well, analyzing exceptions costs time, and using HiddenExceptionHandler with "handled := false" means that madExcept is going to analyze every exception is full detail.

What you could do is try to figure out in your HiddenExceptionHandler if the exception is of interest to you or not, by looking at the "exceptIntf" properties. Do not use "exceptIntf.BugReport", though, because that will force madExcept to calculate the full bug report before returning to you.

Hope that helps?
madshi
Site Admin
 
Posts: 9827
Joined: Sun Mar 21, 2004 5:25 pm

Re: How to save all the exceptions of type "EAccessViolation

Postby car_hack89 » Thu Jul 26, 2018 6:41 pm

In my HiddenExceptionHandler I evaluate the exceptions of type "Exception". I also tried, removing the code from my HiddenExceptionHandler, and the performance problem persists.

Any other recommendation, to intercept the exceptions that have try-except?
car_hack89
 
Posts: 21
Joined: Tue Mar 27, 2018 1:30 am

Re: How to save all the exceptions of type "EAccessViolation

Postby madshi » Thu Jul 26, 2018 6:43 pm

Originally, you only asked for EAccessViolation. So why don't you do something like:

Code: Select all
handled := (exceptIntf.ExceptClass = nil) or (not (exceptIntf.ExceptClass is EAccessViolation));
madshi
Site Admin
 
Posts: 9827
Joined: Sun Mar 21, 2004 5:25 pm

Re: How to save all the exceptions of type "EAccessViolation

Postby car_hack89 » Thu Jul 26, 2018 7:04 pm

The code of my HiddenExceptionHandler is the following:

Code: Select all
procedure MyHiddenExceptionHandler (const exceptIntf: IMEException; var handled: Boolean);
begin
    //I removed my code temporarily,
    //and the performance problem persists.
end;
car_hack89
 
Posts: 21
Joined: Tue Mar 27, 2018 1:30 am

Re: How to save all the exceptions of type "EAccessViolation

Postby madshi » Thu Jul 26, 2018 7:49 pm

What about my suggestion? Have you tried it?
madshi
Site Admin
 
Posts: 9827
Joined: Sun Mar 21, 2004 5:25 pm

Re: How to save all the exceptions of type "EAccessViolation

Postby car_hack89 » Thu Jul 26, 2018 9:30 pm

Yes, I already tried it, and the result is the same. Based on my tests, I think the performance problem is before executing my HiddenExceptionHandler, maybe in the function madExcept.FireHandlers() or madExcept.ReceiveHandleException().
car_hack89
 
Posts: 21
Joined: Tue Mar 27, 2018 1:30 am

Re: How to save all the exceptions of type "EAccessViolation

Postby madshi » Sat Jul 28, 2018 10:01 am

Ok, found a recently introduced bug which slowed this down a lot. Here's a test build which should speed this up noticeably:

http://madshi.net/madCollectionBeta.exe

It'll still be slower than not using the HiddenExceptionHandler stuff, of course (there's no free lunch, obviously), but I hope it will be acceptable now?
madshi
Site Admin
 
Posts: 9827
Joined: Sun Mar 21, 2004 5:25 pm

Re: How to save all the exceptions of type "EAccessViolation

Postby car_hack89 » Sat Jul 28, 2018 3:47 pm

First of all, I appreciate it. Improved performance by 65%.

Can I use the BETA release that you sent me in my productive applications?

**Even with the cost of using HiddenExceptionHandler, it would be very good if it were faster, I will be aware of any subsequent performance improvement.

Thank you very much.
car_hack89
 
Posts: 21
Joined: Tue Mar 27, 2018 1:30 am

Re: How to save all the exceptions of type "EAccessViolation

Postby madshi » Sat Jul 28, 2018 4:16 pm

Strange, for me the performance improvement was much much more than 65%. You did use stDontSync?
madshi
Site Admin
 
Posts: 9827
Joined: Sun Mar 21, 2004 5:25 pm

Re: How to save all the exceptions of type "EAccessViolation

Postby car_hack89 » Sat Jul 28, 2018 6:48 pm

Let me check it, and perform more tests.
car_hack89
 
Posts: 21
Joined: Tue Mar 27, 2018 1:30 am

Re: How to save all the exceptions of type "EAccessViolation

Postby car_hack89 » Mon Jul 30, 2018 5:19 pm

Hello, after several tests, the result was the following:

1.- The time with HiddenExceptionHandler, is variable depending on the location of the source code, for example:

If the code of the "While" with 1,000 iterations is in the FormCreate of my TForm, it takes 25 seconds.

But if I move it to a global/static procedure within the same unit, it now takes 7 seconds.

2.- During the tests, initially the times were 40 seconds, then 36 and finally 25 seconds.

3.- The time with HiddenExceptionHandler, of an application of x32 bits, and of one of x64 bits is 10 seconds of difference, that is, it takes 10 seconds more.

4.- The time, also increases if within the try-except is added more code apart from the raise Exception, for example creation of TDataSet's, etc.

Thanks in advance.
car_hack89
 
Posts: 21
Joined: Tue Mar 27, 2018 1:30 am

Next

Return to madExcept

Who is online

Users browsing this forum: No registered users and 1 guest