Solved

Madexcept no bugreport

Posted on 2011-02-15
30
844 Views
Last Modified: 2012-06-27
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;
0
Comment
Question by:chrislock
  • 17
  • 12
30 Comments
 
LVL 19

Expert Comment

by:Thommy
ID: 34895556
What is your timer interval???
0
 

Author Comment

by:chrislock
ID: 34895607
1 second
0
 

Author Comment

by:chrislock
ID: 34895619
have just increased to 5 - no change
0
 
LVL 19

Expert Comment

by:Thommy
ID: 34895668
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
 
LVL 19

Expert Comment

by:Thommy
ID: 34895707
OK, after activating Range checking in Compiler options, I do get bug reports , both in Formcreate and in timer event ThreadedTimer1Timer...
0
 
LVL 19

Expert Comment

by:Thommy
ID: 34895716
I'm working with madexcept 3.0h.

What is you madexcept version???
0
 
LVL 19

Expert Comment

by:Thommy
ID: 34895728
Is this your post at madshi.net???

http://forum.madshi.net/viewtopic.php?f=4&t=25595
0
 
LVL 19

Expert Comment

by:Thommy
ID: 34895737
Do you have range check activated in Compiler options???
0
 

Author Comment

by:chrislock
ID: 34895752
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
 
LVL 19

Expert Comment

by:Thommy
ID: 34895759
Try to set yout compiler options according to mine and let's see if it also works for you...
CompilerOptions.JPG
0
 

Author Comment

by:chrislock
ID: 34895767
Out of sync!!
3.0l (latest)
Yes my post
Yes range check activated
0
 

Author Comment

by:chrislock
ID: 34895785
I have changed my compiler options to yours and no difference. madexcept catches first error but not the timer error.
0
 

Author Comment

by:chrislock
ID: 34895788
I have a feeling that Madexcept is producing the report but not displaying it for some reason
0
 

Author Comment

by:chrislock
ID: 34895802
Thommy - do you get the same results?
0
 
LVL 19

Expert Comment

by:Thommy
ID: 34895830
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
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 19

Assisted Solution

by:Thommy
Thommy earned 250 total points
ID: 34895839
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
 

Author Comment

by:chrislock
ID: 34895869
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
 
LVL 19

Expert Comment

by:Thommy
ID: 34895899
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
 

Author Comment

by:chrislock
ID: 34895908
OK - I will try exactly as you have stated
0
 

Author Comment

by:chrislock
ID: 34895972
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
 
LVL 19

Expert Comment

by:Thommy
ID: 34895974
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
 

Author Comment

by:chrislock
ID: 34895992
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
 

Author Comment

by:chrislock
ID: 34896136
I've just installed Eurekalog - exactly the same results!!!
0
 

Author Comment

by:chrislock
ID: 34896168
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
 
LVL 19

Expert Comment

by:Thommy
ID: 34899353
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
 

Author Comment

by:chrislock
ID: 34899470
Ok - have to go myself now - will get back in 15 hrs with sources
0
 

Author Comment

by:chrislock
ID: 34905777
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
 

Author Comment

by:chrislock
ID: 34926719
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
 
LVL 32

Accepted Solution

by:
ewangoya earned 250 total points
ID: 34940019
  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
 

Author Closing Comment

by:chrislock
ID: 34940977
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

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Does the idea of dealing with bits scare or confuse you? Does it seem like a waste of time in an age where we all have terabytes of storage? If so, you're missing out on one of the core tools in every professional programmer's toolbox. Learn how to …
This is about my first experience with programming Arduino.
This tutorial covers a step-by-step guide to install VisualVM launcher in eclipse.
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now