Board index » off-topic » Re: #440007 Debuger resumes suspended thread on exception in mainthread
Fernando Madruga
Delphi Developer |
Fernando Madruga
Delphi Developer |
Re: #440007 Debuger resumes suspended thread on exception in mainthread2007-04-09 05:58:10 AM off-topic6 Fernando Madruga wrote: QuoteAlexB wrote: |
AlexB
Delphi Developer |
2007-04-09 01:17:22 PM
Re:Re: #440007 Debuger resumes suspended thread on exception in mainthread
Fernando Madruga wrote:
Quote>AlexB wrote: It is an obvious typo, correct report number is 44007. Quoteif I can confirm and reproduce the steps, I'll flag it for a higher QuoteOn 2nd thought, I can't check it! I only have Delphi for Win32. unit Unit2; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; type TForm2 = class(TForm) Button1: TButton; Label1: TLabel; procedure Button1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); end; var Form2: TForm2; implementation {$R *.dfm} type TMyThread = class(TThread) public X: integer; constructor Create; procedure Execute; override; procedure Show; end; constructor TMyThread.Create; begin inherited Create(false); X:=0; end; procedure TMyThread.Execute; begin while(not Terminated) do begin Suspend; Inc(X); Synchronize(Show); end; end; procedure TMyThread.Show; begin Form2.Label1.Caption:='Counter: '+IntToStr(X); end; //---------------------------------------------------------------------- ----- var t: TMyThread; procedure TForm2.FormCreate(Sender: TObject); begin t:=TMyThread.Create; end; procedure TForm2.FormDestroy(Sender: TObject); begin t.Terminate; t.Resume; t.WaitFor; t.Free; end; procedure TForm2.Button1Click(Sender: TObject); begin raise Exception.Create('Exception'); end; end. ------------- I've got the same result in Delphi2006. ------------- There is no this bug in BCB5. -- Alex. |
Fernando Madruga
Delphi Developer |
2007-04-09 05:42:25 PM
Re:Re: #440007 Debuger resumes suspended thread on exception in mainthread
AlexB wrote:
QuoteIf we'll start to report bugs more actively (like you), we'll reach Not even after "fixing" your translation to Delphi... :) Here's the unit source I used: 01 unit Unit1; 02 03 interface 04 05 uses 06 Windows, Messages, SysUtils, Variants, Classes, 07 Graphics, Controls, Forms, Dialogs, StdCtrls; 08 09 type 10 TForm1 = class(TForm) 11 Label1 : TLabel; 12 Button1: TButton; 13 procedure Button1Click( Sender: TObject ); 14 private 15 public 16 constructor Create( aOwner: TComponent ); override; 17 destructor Destroy; override; 18 end; 19 20 var 21 Form1: TForm1; 22 23 implementation 24 25 {$R *.dfm} 26 27 type TMyThread = class(TThread) 28 public 29 X: integer; 30 constructor Create; 31 procedure Execute; override; 32 procedure Show; 33 end; 34 35 constructor TMyThread.Create; 36 begin 37 inherited Create(false); 38 X:=0; 39 end; 40 41 procedure TMyThread.Execute; 42 begin 43 while(not Terminated) do begin 44 Suspend; 45 Inc(X); 46 Synchronize(Show); 47 end; 48 end; 49 50 procedure TMyThread.Show; 51 begin 52 Form1.Label1.Caption:='Counter: '+IntToStr(X); 53 end; 54 //----------------------------------------------------------- 55 56 var t: TMyThread; 57 58 constructor TForm1.Create( aOwner: TComponent ); 59 begin 60 inherited Create( aOwner ); 61 t := TMyThread.Create; 62 end; 63 64 destructor TForm1.Destroy; 65 begin 66 t.Terminate; 67 t.Resume; 68 t.WaitFor; 69 t.Free; 70 inherited Destroy; 71 end; 72 73 procedure TForm1.Button1Click(Sender: TObject); 74 begin 75 raise Exception.Create('Exception'); 76 end; 77 78 end. I've set a breakpoint in lines 43 and 44 (just in case!) and followed your steps and could not duplicate that bug in Delphi 2007. Can you try this source in BDS 2006 and let me know if the same thing happens? Later, Madruga {smallsort} |
Fernando Madruga
Delphi Developer |
2007-04-09 06:54:07 PM
Re:Re: #440007 Debuger resumes suspended thread on exception in mainthread
Fernando Madruga wrote:
QuoteAs for the bug itself, I cannot reproduce it in Delphi for Win32 2007. Form's OnXX events!), it does behave the same, i.e., cannot reproduce that behavior in Delphi 2007. 01 unit Unit1; 02 03 interface 04 05 uses 06 Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, 07 Dialogs, StdCtrls; 08 09 type 10 TForm1 = class(TForm) 11 Label1 : TLabel; 12 Button1: TButton; 13 procedure Button1Click( Sender: TObject ); 14 procedure FormDestroy ( Sender: TObject ); 15 procedure FormCreate ( Sender: TObject ); 16 private 17 public 18 end; 19 20 var 21 Form1: TForm1; 22 23 implementation 24 25 {$R *.dfm} 26 27 type TMyThread = class(TThread) 28 public 29 X: integer; 30 constructor Create; 31 procedure Execute; override; 32 procedure Show; 33 end; 34 35 constructor TMyThread.Create; 36 begin 37 inherited Create(false); 38 X:=0; 39 end; 40 41 procedure TMyThread.Execute; 42 begin 43 while(not Terminated) do begin 44 Suspend; 45 Inc(X); 46 Synchronize(Show); 47 end; 48 end; 49 50 procedure TMyThread.Show; 51 begin 52 Form1.Label1.Caption:='Counter: '+IntToStr(X); 53 end; 54 //--------------------------------------------------------------------- 55 56 var t: TMyThread; 57 58 procedure TForm1.FormCreate(Sender: TObject); 59 begin 60 t := TMyThread.Create; 61 end; 62 63 procedure TForm1.FormDestroy(Sender: TObject); 64 begin 65 t.Terminate; 66 t.Resume; 67 t.WaitFor; 68 t.Free; 69 end; 70 71 procedure TForm1.Button1Click(Sender: TObject); 72 begin 73 raise Exception.Create('Exception'); 74 end; 75 76 end. |
AlexB
Delphi Developer |
2007-04-10 02:28:16 PM
Re:Re: #440007 Debuger resumes suspended thread on exception in mainthread
Fernando Madruga wrote:
QuoteHere's the unit source I used of main thread. It was revealed during debugging the real project when the external device (weighing a 100 kg) began to move spontaneously; it looked as revolt of machines :). Then this effect has been reproduced in the separate test application. Quotecannot reproduce that behavior in Delphi 2007. In what environment you made the test (main OS or VM)? Probably the bug has been fixed in the D2007. In that case it is very good. -- Alex. |
Fernando Madruga
Delphi Developer |
2007-04-10 05:03:44 PM
Re:Re: #440007 Debuger resumes suspended thread on exception in mainthread
AlexB wrote:
Quoteit looked as revolt of machines :). QuoteIn what environment you made the test (main OS or VM)? QuoteProbably the bug has been fixed in the D2007. In that case it is very |
Fernando Madruga
Delphi Developer |
2007-04-10 05:53:54 PM
Re:Re: #440007 Debuger resumes suspended thread on exception in mainthread
Yep. Definitely seems to have been fixed in D2007. Tested the same thing
on my machine (XP SP2) and the only time it hits the breakpoint is on app start. Clicking the button and "continuing" on the exception will *not* trigger the BP nor consequently increment the counter... Now, all you need to know is *when* there will be a C++ 2007, but that is something for which you won't get a date from anyone: at most an unofficial rough estimate... As for getting that fixed for BDS 2006, I would probably not count on that either since they'll be releasing the new studio sometime... |
AlexB
Delphi Developer |
2007-04-10 08:37:19 PM
Re:Re: #440007 Debuger resumes suspended thread on exception in mainthread
Fernando Madruga wrote:
QuoteDefinitely seems to have been fixed in D2007. Tested the same QuoteAs for getting that fixed for BDS 2006, I would probably not count -- Alex. |