Madexcept no bugreport

Hi
D7 XP
I wrote a quick app containing a threaded timer to test Madexcept.

Why does it not detect the identical range error in the timer section? (arr[1..10])

procedure TForm1.ThreadedTimer1Timer(Sender: TObject);
var
x:integer;
begin
x:=1000; // No bugreport
arr[x]:=1;
end;

procedure TForm1.FormCreate(Sender: TObject);
var x:integer;
begin
x:=1000;
arr[x]:=1; // Bugreport OK
ThreadedTimer1.Enabled:=true;
end;
chrislockAsked:
Who is Participating?
 
Ephraim WangoyaConnect With a Mentor Commented:
  try
..
     except // NOT HANDLED!!!
    end;


  except
    if Assigned(ApplicationHandleException) then
      ApplicationHandleException(Self);
  end;


These codes already handle the exceptions so MadExcept will not catch or log them by default.

To log Handled Exceptions, add
RegisterHiddenExceptionHandler(TAExceptionHanlder.MadException_HiddenExceptionHandler, False);

0
 
ThommyCommented:
What is your timer interval???
0
 
chrislockAuthor Commented:
1 second
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
chrislockAuthor Commented:
have just increased to 5 - no change
0
 
ThommyCommented:
I have activated madexcept and tried out your code.

Do not get any bug report in either of the two cases.

No bugreport in FormCreate and no bug report in timer event!!!

My array ist defined as follows:

var
  arr: array [1..10] of integer;

What about the definition of your array???
0
 
ThommyCommented:
OK, after activating Range checking in Compiler options, I do get bug reports , both in Formcreate and in timer event ThreadedTimer1Timer...
0
 
ThommyCommented:
I'm working with madexcept 3.0h.

What is you madexcept version???
0
 
ThommyCommented:
Is this your post at madshi.net???

http://forum.madshi.net/viewtopic.php?f=4&t=25595
0
 
ThommyCommented:
Do you have range check activated in Compiler options???
0
 
chrislockAuthor Commented:
same as yours -
check that 'project compiler options Range checking enabled' and 'tools debugger options - integrated debugging and lang exceptions - stop on Delphi exceptions' checked.
Disable Madexcept and run - Delphi will give 'range check err' on formcreate
uncheck stop on Delphi exceptions.
Now enable madexcept and recompile and run - Madexcept gives bugreport on formcreate but not on the timer section.
0
 
ThommyCommented:
Try to set yout compiler options according to mine and let's see if it also works for you...
CompilerOptions.JPG
0
 
chrislockAuthor Commented:
Out of sync!!
3.0l (latest)
Yes my post
Yes range check activated
0
 
chrislockAuthor Commented:
I have changed my compiler options to yours and no difference. madexcept catches first error but not the timer error.
0
 
chrislockAuthor Commented:
I have a feeling that Madexcept is producing the report but not displaying it for some reason
0
 
chrislockAuthor Commented:
Thommy - do you get the same results?
0
 
ThommyCommented:
Comment out arr[x]:=1 in FormCreate:

//arr[x]:=1

Now you will get the bug report in Timer event.

MadExcept captures the first range error in FormCreate and then exits FormCreate if you press "Continue application".

Your timer gets not enabled, because the line "ThreadedTimer1.Enabled:=true;" will not be carried out;

Change the two lines from FormCreate to call "ThreadedTimer1.Enabled:=true;" before "arr[x]:=1", and you will get bug reports for both...


0
 
ThommyConnect With a Mentor Commented:
This is the solution...

Only the order of two lines in FormCreate is changed!!!

ThreadedTimer1.Enabled:=true;
arr[x]:=1; // Bugreport OK

procedure TForm1.ThreadedTimer1Timer(Sender: TObject);
var 
x:integer;
begin
x:=1000; // No bugreport
arr[x]:=1;
end;

procedure TForm1.FormCreate(Sender: TObject);
var x:integer;
begin
x:=1000;
ThreadedTimer1.Enabled:=true;
arr[x]:=1; // Bugreport OK
end;

Open in new window

0
 
chrislockAuthor Commented:
You may be correct - However - we are not running the same code.

I have just changed the threaded timer to a standard one and everything works as expected.

This is the threadedtimer I wish to use       http://www.carlosb.com/ctrl.php?fm=delphicomps

There must be something odd within the source.
0
 
ThommyCommented:
It's not a question of the timer component.

The point is, that the actual block is aborted after an exception (FormCreate-Block) and therefore the timer does not get enabled.

If you enable the timer at design time or set timer property "ENABLED" before the line, which produces the error, you will get both bug reports when continuing the app...
0
 
chrislockAuthor Commented:
OK - I will try exactly as you have stated
0
 
chrislockAuthor Commented:
I am correct - Madexcept will not give an exception on this timer section if you use the Threaded timer component. It runs normally with an ordinary timer.
You can see that the timer section runs by putting a breakpoint in.
As I said before, there must be something odd within the component source (which you can get free from the link above)
I've had a look at it but I cant see anything wrong.
I would just like to find out what it is!!!!!
Chris
0
 
ThommyCommented:
To check if  the timer is active you can place a label on your form and toogle its caption in the first line of the timer event:

with label1 do
  if caption='2' then caption:='1' else caption:='2';

0
 
chrislockAuthor Commented:
I've done that - the problem is definitely within the component - it must somehow prevent Madexcept working properly. I have used this component in several projects without a problem and I dont want to change the component to suit the debugger!!
0
 
chrislockAuthor Commented:
I've just installed Eurekalog - exactly the same results!!!
0
 
chrislockAuthor Commented:
If I disable Eurekalog (and Madexcept) and enable 'tools - stop on delphi exeptions', the Delphi IDE picks up the range check error in the timer section  with no problems - What on earth is happening?
Thommy-have you tried this comonent?
0
 
ThommyCommented:
Sorry, for late feedback!!! Was prevented to get back because of a long meeting.


No, I don't know Eurekalog.

But range check can only be detected and caught, if timer event is called!!!

Have you checked, if timer event is really carried out!!!

You stated that you have checked that by toggling a test label, but you haven't told me what the result was.

Can you see a change of the label.caption, which would prove, that the code in timer event is really carried out???

Please provide sources of your current FormCreate and timer event (ThreadedTimer1Timer).
0
 
chrislockAuthor Commented:
Ok - have to go myself now - will get back in 15 hrs with sources
0
 
chrislockAuthor Commented:
Put a listbox  and a timer on an empty form. My timer is a JVthreadtimer, but you can use a standard timer.
Set timer to 1000 ms.

If you comment out the arr[x]:=1 then no problems, otherwise both delphi debugger and Madexcept will find both errors.

If you replace the timer with http://www.carlosb.com/ctrl.php?fm=delphicomps and recompile then Delphi will pick up both range errors  but Madexcept (and Eurekalog) will only pick up the error on formcreate.(disable delphi stop on error when using Madexcept)
This is my problem!!!!




Source as follows:
unit exep;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls, ThdTimer, ExtCtrls,
  JvThreadTimer, JvComponentBase;

type
  TForm1 = class(TForm)
    ListBox1: TListBox;
    JvThreadTimer1: TJvThreadTimer;

    procedure ThreadedTimer1Timer(Sender: TObject);
    procedure FormCreate(Sender: TObject);


  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  arr:array[1..10] of integer;

implementation

{$R *.dfm}

procedure TForm1.ThreadedTimer1Timer(Sender: TObject);
var
x:integer;
begin
x:=1000;
arr[x]:=1; // ERROR HERE
listbox1.Items.add('XXX');
end;

procedure TForm1.FormCreate(Sender: TObject);
var x:integer;
begin
x:=1000;
JvThreadTimer1.Enabled:=true;
arr[x]:=1;  // ERROR HERE
end;

end.
0
 
chrislockAuthor Commented:
Is there no-one out there????


I've looked at the source code of 2 timers JvThread timer, and ThdTimer (carlosB).
Is it true that if you do not handle any exception (Tthreadedtimer), whilst the timer is in its event, then any exception that occurs will not be picked up by Madexcept?
NOTE the lines
   ' if Assigned(ApplicationHandleException) then
      ApplicationHandleException(Self);'
 in the JVthreadtimer.


*********************************

procedure TJvThreadTimer.DoOnTimer;
begin
  if csDestroying in ComponentState then
    Exit;

  try
    if Assigned(FOnTimer) then
      FOnTimer(Self);
  except
    if Assigned(ApplicationHandleException) then
      ApplicationHandleException(Self);
  end;
end;

*************************************************
procedure TThreadedTimer.DoTimer;
begin

  // We have to check FEnabled in the primary thread
  // Otherwise we get AV when the program is closed
  if FEnabled and Assigned(FOnTimer) and not (csDestroying in ComponentState) then
    try
      FOnTimer(Self);
    except // NOT HANDLED!!!
    end;
end;
0
 
chrislockAuthor Commented:
Thanks all -
I managed to get the hang of the CPU panes and I realised what was happening in the end. The registerhiddenexceptions will be handy!
 I have split the points.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.