Link to home
Start Free TrialLog in
Avatar of chrislock
chrislock

asked on

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;
Avatar of Thommy
Thommy
Flag of Germany image

What is your timer interval???
Avatar of chrislock
chrislock

ASKER

1 second
have just increased to 5 - no change
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???
OK, after activating Range checking in Compiler options, I do get bug reports , both in Formcreate and in timer event ThreadedTimer1Timer...
I'm working with madexcept 3.0h.

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

http://forum.madshi.net/viewtopic.php?f=4&t=25595
Do you have range check activated in Compiler options???
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.
Try to set yout compiler options according to mine and let's see if it also works for you...
CompilerOptions.JPG
Out of sync!!
3.0l (latest)
Yes my post
Yes range check activated
I have changed my compiler options to yours and no difference. madexcept catches first error but not the timer error.
I have a feeling that Madexcept is producing the report but not displaying it for some reason
Thommy - do you get the same results?
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...


SOLUTION
Avatar of Thommy
Thommy
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.
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...
OK - I will try exactly as you have stated
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
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';

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!!
I've just installed Eurekalog - exactly the same results!!!
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?
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).
Ok - have to go myself now - will get back in 15 hrs with sources
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.
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;
ASKER CERTIFIED SOLUTION
Avatar of Ephraim Wangoya
Ephraim Wangoya
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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.