Board index » off-topic » Re: #440007 Debuger resumes suspended thread on exception in mainthread

Re: #440007 Debuger resumes suspended thread on exception in mainthread


2007-04-09 05:58:10 AM
off-topic6
Fernando Madruga wrote:
Quote
AlexB wrote:
>QC #440007 Debuger resumes suspended thread on exception in main thread
>
>Reproduced on 2 computers.
>Please check this issue and open the report.

I don't think we can! We'll have to wait a few years until that report
number comes along! :) (440.007!)

I'll take a look at 44.007: if I can confirm and reproduce the steps,
I'll flag it for a higher level.
On 2nd thought, I can't check it! I only have Delphi for Win32. Maybe
some C++ user will give it a try...
 
 

Re:Re: #440007 Debuger resumes suspended thread on exception in mainthread

Fernando Madruga wrote:
Quote
>AlexB wrote:
>QC #440007 Debuger resumes suspended thread on exception in main
>thread
I don't think we can! We'll have to wait a few years until that
report number comes along! :) (440.007!)
If we'll start to report bugs more actively (like you), we'll reach
this number very soon. :))
It is an obvious typo, correct report number is 44007.
Quote
if I can confirm and reproduce the steps, I'll flag it for a higher
level.
Thank you.
Quote
On 2nd thought, I can't check it! I only have Delphi for Win32.
It's not big deal to check it in Delphi:
-----------
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.
 

Re:Re: #440007 Debuger resumes suspended thread on exception in mainthread

AlexB wrote:
Quote
If we'll start to report bugs more actively (like you), we'll reach
this number very soon. :))
:)
As for the bug itself, I cannot reproduce it in Delphi for Win32 2007.
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}

Re:Re: #440007 Debuger resumes suspended thread on exception in mainthread

Fernando Madruga wrote:
Quote
As for the bug itself, I cannot reproduce it in Delphi for Win32 2007.
Not even after "fixing" your translation to Delphi... :)
Even in the "unfixed" version (I suddenly realized, while testing
another bug report, that it wasn't a bad conversion but rather using the
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.
 

Re:Re: #440007 Debuger resumes suspended thread on exception in mainthread

Fernando Madruga wrote:
Quote
Here's the unit source I used
...
There is no difference what style to use, the problem (at least on my
side) is: after exception debuger resumes the secondary thread instead
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.
Quote
cannot reproduce that behavior in Delphi 2007.
Hmm. I definitely see this effect on 2 different computers with 2
different OS (W2k and WinXP) in 2 personalities (C++ and D) of BDS2006.
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.
 

Re:Re: #440007 Debuger resumes suspended thread on exception in mainthread

AlexB wrote:
Quote
it looked as revolt of machines :).
That could have been dangerous! :)
Quote
In what environment you made the test (main OS or VM)?
I tested in my VM with Windows 2003 and Delphi 2007. I can test also on
my main machine with XP. I'll let you know later.
Quote
Probably the bug has been fixed in the D2007. In that case it is very
good.
That would be my guess! :)
 

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...
 

Re:Re: #440007 Debuger resumes suspended thread on exception in mainthread

Fernando Madruga wrote:
Quote
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.
OK, good news :)
Thank you.
Quote
As for getting that fixed for BDS 2006, I would probably not count
on that
The report hasn't yet independent confirmation and official resolution
so it's too early to speak about patches. :)
--
Alex.