View Issue Details

IDProjectCategoryView StatusLast Update
0038544LazarusLCLpublic2021-03-05 12:19
ReporterCudaText man Assigned ToJuha Manninen  
PrioritynormalSeverityminorReproducibilityalways
Status closedResolutionfixed 
Product Version2.1 (SVN) 
Summary0038544: Poor crash message if exception occurs in OnTimer
DescriptionLazarus 2.1.0 r64665 FPC 3.2.1 x86_64-linux-gtk2

run attached demo w/o debugging.
expected: message with text which I pass to TException.Create()
reality: it shows poor message about error. only "Access violation".
TagsNo tags attached.
Fixed in Revisionr64745
LazTarget-
WidgetsetGTK 2
Attached Files

Activities

CudaText man

2021-02-25 15:25

reporter  

err.png (26,226 bytes)   
err.png (26,226 bytes)   
tst-timer-crash.zip (2,550 bytes)

Juha Manninen

2021-02-25 15:51

developer   ~0129160

Last edited: 2021-02-25 16:01

View 2 revisions

Exception and Access violation are 2 different things.
Access violation is always wrong and means you should fix the code.

Looks like yet another crappy bug report.

Bart Broersma

2021-02-25 20:45

developer   ~0129164

I have reported (on ML I think) similar problems with raising exceptions in an OnTimer event on Windows.
Currently if I raise an exception in an OnTimer event, the exception does NOT bubble up.
Nothing happens at all, the program simply continues.

Just a simple form with a button and a timer.

procedure TForm1.FormCreate(Sender: TObject);
begin
end;

procedure TForm1.Timer1Timer(Sender: TObject);
begin
  writeln('Timer1: raising an exception');
  raise exception.create('foo');
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  Timer1.Enabled := True;
end;

It will continously spit out:
Timer1: raising an exception
Timer1: raising an exception
Timer1: raising an exception
Timer1: raising an exception
Timer1: raising an exception
Timer1: raising an exception
Timer1: raising an exception
Timer1: raising an exception
etc. etc.

Bart Broersma

2021-02-25 20:52

developer   ~0129165

Running the same program from my note abov on Linux GTK2 gives exactly the errormessage that is attached to this bugreport.

CudaText man

2021-02-25 21:44

reporter   ~0129167

Last edited: 2021-02-25 21:46

View 2 revisions

Juha, no, not crap report, look at the demo code.
I must see my own exception. in reality I see "AV".

delfion

2021-02-26 13:24

reporter   ~0129170

customtimer.pas: CustomApplication is nil.

procedure TCustomTimer.Timer;
begin
  {$IFDEF VerboseTimer}
  DebugLn(['TCustomTimer.Timer ',dbgsName(Self),' ',FEnabled,' ',FInterval]);
  {$ENDIF}
  if (FEnabled) and (FInterval > 0) then
    try
      DoOnTimer;
    except
      CustomApplication.HandleException(nil);
    end;
end;

CudaText man

2021-03-02 18:09

reporter   ~0129326

added the fix! note - 'Forms' must be used in 'implementation'. (otherwise- circular reference).
fix.diff (669 bytes)   
Index: lcl/customtimer.pas
===================================================================
--- lcl/customtimer.pas	(revision 64723)
+++ lcl/customtimer.pas	(working copy)
@@ -20,7 +20,7 @@
 interface
 
 uses
-  Classes, SysUtils, LCLProc, LCLStrConsts, LCLType, InterfaceBase, CustApp;
+  Classes, SysUtils, LCLProc, LCLStrConsts, LCLType, InterfaceBase;
 
 type
 
@@ -56,6 +56,9 @@
 
 implementation
 
+uses
+  Forms;
+
 const
   cIdNoTimer = THandle(-1);        { timer ID for an invalid timer }
 
@@ -150,7 +153,7 @@
     try
       DoOnTimer;
     except
-      CustomApplication.HandleException(nil);
+      Application.HandleException(nil);
     end;
 end;
 
fix.diff (669 bytes)   

Juha Manninen

2021-03-05 11:01

developer   ~0129396

Ok, it was a real bug.
I synchronized CustomApplication with Application instead of using variable Application and creating a circular reference.
I think it is logically correct.
Please test.

Issue History

Date Modified Username Field Change
2021-02-25 15:25 CudaText man New Issue
2021-02-25 15:25 CudaText man File Added: err.png
2021-02-25 15:25 CudaText man File Added: tst-timer-crash.zip
2021-02-25 15:51 Juha Manninen Note Added: 0129160
2021-02-25 16:01 Juha Manninen Note Edited: 0129160 View Revisions
2021-02-25 20:45 Bart Broersma Note Added: 0129164
2021-02-25 20:52 Bart Broersma Note Added: 0129165
2021-02-25 21:44 CudaText man Note Added: 0129167
2021-02-25 21:46 CudaText man Note Edited: 0129167 View Revisions
2021-02-26 13:24 delfion Note Added: 0129170
2021-03-02 18:09 CudaText man Note Added: 0129326
2021-03-02 18:09 CudaText man File Added: fix.diff
2021-03-05 09:08 Juha Manninen Assigned To => Juha Manninen
2021-03-05 09:08 Juha Manninen Status new => assigned
2021-03-05 11:01 Juha Manninen Status assigned => resolved
2021-03-05 11:01 Juha Manninen Resolution open => fixed
2021-03-05 11:01 Juha Manninen Fixed in Revision => r64745
2021-03-05 11:01 Juha Manninen LazTarget => -
2021-03-05 11:01 Juha Manninen Widgetset GTK 2 => GTK 2
2021-03-05 11:01 Juha Manninen Note Added: 0129396
2021-03-05 12:19 CudaText man Status resolved => closed