Page 2 of 2

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

Posted: Tue Jul 31, 2018 5:04 pm
by madshi
Have you run this inside or outside of the IDE debugger?

I've tried this in a simple test project:

Code: Select all

procedure HiddenHandler(const exceptIntf: IMEException; var handled: boolean);
begin
  handled := true;
end;

var i1   : integer;
    time : dword;
begin
  RegisterHiddenExceptionHandler(HiddenHandler, stDontSync);

  time := GetTickCount;
  for i1 := 0 to 999 do
    try
      raise Exception.Create('test');
    except end;
  time := GetTickCount - time;
  MessageBoxA(0, PAnsiChar(AnsiString(IntToStr(time) + ' ms')), 'time', 0);
end.
It takes 3.8 seconds on my development PC. That's about 3.8 milliseconds per exception. Of course it'd be nice to have no delay at all. But I think 3.8 milliseconds per exceptions is so terribly bad?

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

Posted: Thu Aug 02, 2018 12:50 am
by car_hack89
Hi,
madshi wrote:Have you run this inside or outside of the IDE debugger?
Outside of the IDE debugger

I understand that in your test the time is good, 3.8 seconds for the 1,000 iterations, but the performance can change, adding the following variants:

1. 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.
2. The performance changes depending on the platform
     the application, x32 or x64 bits
3. PC hardware

I appreciate the support, but HiddenExceptionHandler I can not use it, in an Application Server (multithreading application with high level of concurrency), where performance is a vital element, but thank you very much.

Just a question. Considering my objective, which is to save in a file the error message and the respective call stack which are Access Violation, I did the following,
and I was able to solve my goal, and without any impact on my performance:

Code: Select all

unit madExcept;

...
var OnAppHookExceptions: procedure(const pException: TObject; const exceptAddr: Pointer) = nil;
...

implementation
...

   procedure InterceptFreeExceptObject(exceptObject: TObject);
   begin
      ...
      if (GetCurrentThreadId <> HandleExceptionTid) and
	     ((@OnAppHookExceptions <> nil) Or ((HiddenHandlers ...) or (HiddenHandlersOO ...))) and
		 (exceptObject <> nil) and ... then begin
		 if @OnAppHookExceptions <> nil then
		    OnAppHookExceptions(exceptObject, System.ExceptAddr);
         if ((HiddenHandlers ...) or (HiddenHandlersOO ...)) then
            HandleException(etHidden, ...);		 
      end;//if
	  ...
   end;
   
   procedure HandleHiddenException(exceptObject: TObject; RaiseList: pointer);
   var ...;
   begin
      if exceptObject <> nil then begin
	     try
		    ...
		 except end;
		 if (GetCurrentThreadId <> HandleExceptionTid) and
		    ((@OnAppHookExceptions <> nil) Or ((HiddenHandlers ...) or (HiddenHandlersOO ...))) and (RaiseList <> nil) and
			(MadException(...)...) and
			IsValidObject(...) then begin
		    ea:= nil;
            TryRead(...);
			if @OnAppHookExceptions <> nil then
		       OnAppHookExceptions(exceptObject, ea);
            if ((HiddenHandlers ...) or (HiddenHandlersOO ...)) then
               HandleException(etHidden, ...);
		 end;
	  end;
   end;
Any suggestion or opinion of the source code added to the madExcept unit?

Thanks in advance.

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

Posted: Mon Aug 06, 2018 1:45 pm
by car_hack89
Any suggestion or opinion of the source code added to the madExcept unit?
Thanks in advance.

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

Posted: Thu Aug 09, 2018 1:47 pm
by madshi
I suppose it should work fine that way.