Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / fpc-pascal / 2013-09

FPCUnit test + raise E;

13 messages · 3 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Marcos Douglas

Hi,

1) I have a code like that:

procedure TghSQLConnector.Connect;
begin
  try
    FLib.Connect;
  except
    on E: Exception do
      DoOnException(E);
  end;
end;

https://github.com/mdbs99/Greyhound/blob/0.1.8/src/ghsql.pas#L1565

2) DoOnException was implemented so:

procedure TghSQLHandler.DoOnException(E: Exception);
begin
  if Assigned(FOnException) then
    FOnException(Self, E)
  else
    raise E;
end;

https://github.com/mdbs99/Greyhound/blob/0.1.8/src/ghsql.pas#L443

So, as you see, if occurs a Exception the code checks if the event (OnException) was setted. If yes, call user implementation; if no, call raise E;
It works... but not when I uses in FPCUnit tests.

See a simple test (this works):

procedure TghSQLConnectorTest.TestOnException;
begin
  // catch
  FConn.OnException := @DoOnException;
  FConn.Script.Text := 'foo';
  FConn.Execute;
end;

https://github.com/mdbs99/Greyhound/blob/0.1.8/test/ghsqltest.pas#L246

The code DoOnException is:

procedure TghSQLTest.DoOnException(Sender: TObject; E: Exception);
begin
  AssertTrue(Assigned(E));
end;

https://github.com/mdbs99/Greyhound/blob/0.1.8/test/ghsqltest.pas#L141

So, if I change the test like bellow... BUM! SIGSEGV!!

procedure TghSQLConnectorTest.TestOnException;
begin
  // removed >>> FConn.OnException := @DoOnException;
  FConn.Script.Text := 'foo';
  FConn.Execute;
end;

The ERROR is:
[Content]
Project test raised exception class 'External: SIGSEGV'.

At address 40B758

Can you explain this?

Marcos Douglas

Reply by email

Marcos Douglas
to Marcos Douglas
Marcos Douglas wrote 75 lines
Hi, 1) I have a code like that: procedure TghSQLConnector.Connect; begin try FLib.Connect; except on E: Exception do DoOnException(E); end; end; https://github.com/mdbs99/Greyhound/blob/0.1.8/src/ghsql.pas#L1565 2) DoOnException was implemented so: procedure TghSQLHandler.DoOnException(E: Exception); begin if Assigned(FOnException) then FOnException(Self, E) else raise E; end; https://github.com/mdbs99/Greyhound/blob/0.1.8/src/ghsql.pas#L443 So, as you see, if occurs a Exception the code checks if the event (OnException) was setted. If yes, call user implementation; if no, call raise E; It works... but not when I uses in FPCUnit tests. See a simple test (this works): procedure TghSQLConnectorTest.TestOnException; begin // catch FConn.OnException := @DoOnException; FConn.Script.Text := 'foo'; FConn.Execute; end; https://github.com/mdbs99/Greyhound/blob/0.1.8/test/ghsqltest.pas#L246 The code DoOnException is: procedure TghSQLTest.DoOnException(Sender: TObject; E: Exception); begin AssertTrue(Assigned(E)); end; https://github.com/mdbs99/Greyhound/blob/0.1.8/test/ghsqltest.pas#L141 So, if I change the test like bellow... BUM! SIGSEGV!! procedure TghSQLConnectorTest.TestOnException; begin // removed >>> FConn.OnException := @DoOnException; FConn.Script.Text := 'foo'; FConn.Execute; end; The ERROR is: [Content] Project test raised exception class 'External: SIGSEGV'. At address 40B758 Can you explain this?

I forgot. I'm using Lazarus 1.1 r42461 FPC 2.6.2 i386-win32-win32/win64 I want to know if there is a problem in FPCUnit to catch some exceptions. That's all.

Marcos Douglas

Reply by email

Graeme Geldenhuys

FPCUnit and DUnit and FPTest frameworks have special test methods for testing exceptions. In the latter two frameworks it is CheckException(). I know FPCUnit has something similar. I think for the DUnit compatibility interface of FPCUnit I implemented the CheckException method too.

G.

Reply by email

Sven Barth
to Marcos Douglas: 1) I have a code like that: procedure TghSQLConnector.Connect; begin try FLib.Connect;…
Marcos Douglas wrote 72 lines
Hi, 1) I have a code like that: procedure TghSQLConnector.Connect; begin try FLib.Connect; except on E: Exception do DoOnException(E); end; end; https://github.com/mdbs99/Greyhound/blob/0.1.8/src/ghsql.pas#L1565 2) DoOnException was implemented so: procedure TghSQLHandler.DoOnException(E: Exception); begin if Assigned(FOnException) then FOnException(Self, E) else raise E; end; https://github.com/mdbs99/Greyhound/blob/0.1.8/src/ghsql.pas#L443 So, as you see, if occurs a Exception the code checks if the event (OnException) was setted. If yes, call user implementation; if no, call raise E; It works... but not when I uses in FPCUnit tests. See a simple test (this works): procedure TghSQLConnectorTest.TestOnException; begin // catch FConn.OnException := @DoOnException; FConn.Script.Text := 'foo'; FConn.Execute; end; https://github.com/mdbs99/Greyhound/blob/0.1.8/test/ghsqltest.pas#L246 The code DoOnException is: procedure TghSQLTest.DoOnException(Sender: TObject; E: Exception); begin AssertTrue(Assigned(E)); end; https://github.com/mdbs99/Greyhound/blob/0.1.8/test/ghsqltest.pas#L141 So, if I change the test like bellow... BUM! SIGSEGV!! procedure TghSQLConnectorTest.TestOnException; begin // removed >>> FConn.OnException := @DoOnException; FConn.Script.Text := 'foo'; FConn.Execute; end; The ERROR is: [Content] Project test raised exception class 'External: SIGSEGV'. At address 40B758

Could you as a test replace the

raise E

with

raise E at get_caller_addr(get_frame), get_caller_frame(get_frame);

and check whether this makes a difference?

Could you also compile the RTL with debug information and maybe also without optimizations (CROSSOPT="-gl -O-") and rerun your test and display the stack trace (you'll need to enable "-gl" for your test as well)?

Regards,
Sven

Reply by email

Marcos Douglas
to Sven Barth
Sven Barth wrote 85 lines
On 15.09.2013 03:21, Marcos Douglas wrote: > > Hi, > > 1) I have a code like that: > > procedure TghSQLConnector.Connect; > begin > try > FLib.Connect; > except > on E: Exception do > DoOnException(E); > end; > end; > > https://github.com/mdbs99/Greyhound/blob/0.1.8/src/ghsql.pas#L1565 > > > 2) DoOnException was implemented so: > > procedure TghSQLHandler.DoOnException(E: Exception); > begin > if Assigned(FOnException) then > FOnException(Self, E) > else > raise E; > end; > > https://github.com/mdbs99/Greyhound/blob/0.1.8/src/ghsql.pas#L443 > > > So, as you see, if occurs a Exception the code checks if the event > (OnException) was setted. If yes, call user implementation; if no, > call raise E; > It works... but not when I uses in FPCUnit tests. > > See a simple test (this works): > > procedure TghSQLConnectorTest.TestOnException; > begin > // catch > FConn.OnException := @DoOnException; > FConn.Script.Text := 'foo'; > FConn.Execute; > end; > > https://github.com/mdbs99/Greyhound/blob/0.1.8/test/ghsqltest.pas#L246 > > > The code DoOnException is: > > procedure TghSQLTest.DoOnException(Sender: TObject; E: Exception); > begin > AssertTrue(Assigned(E)); > end; > > https://github.com/mdbs99/Greyhound/blob/0.1.8/test/ghsqltest.pas#L141 > > So, if I change the test like bellow... BUM! SIGSEGV!! > > procedure TghSQLConnectorTest.TestOnException; > begin > // removed >>> FConn.OnException := @DoOnException; > FConn.Script.Text := 'foo'; > FConn.Execute; > end; > > > The ERROR is: > [Content] > Project test raised exception class 'External: SIGSEGV'. > > At address 40B758 Could you as a test replace the raise E with raise E at get_caller_addr(get_frame), get_caller_frame(get_frame); and check whether this makes a difference?

I tried. No makes difference.
(could you explain which the difference to call "raise" using "raise E at [...]"?)

I implemented -- but not up to Git yet -- some like that:
procedure TghSQLHandler.DoOnException(E: Exception);
var
  NewEx: EghSQLError;
begin
  if Assigned(FOnException) then
    FOnException(Self, E)
  else
  begin
    NewEx := EghSQLError.Create(Self, E.Message);   // <<<
    NewEx.InnerException := E;                                  // <<<
    raise NewEx;
  end;
end;

So, if I recreate the Exception, it works in any cases. As you see, I created a new property (InnerException) to save the original exception to know what the real Exception happened... But I think this introduces much more overhead to processing.

In my code I have classes that inherited from TghSQLHandler. This class have the DoOnException method.
So DoOnException can be call many times in override methods. Maybe the program "broke" the stack because "raise E" can be call and raise an exception; the next "level" raise another; and next call again. :/

Show quoted text 6 lines
Could you also compile the RTL with debug information and maybe also without optimizations (CROSSOPT="-gl -O-") and rerun your test and display the stack trace (you'll need to enable "-gl" for your test as well)? Regards, Sven

I will try too.

Marcos Douglas

Reply by email

Sven Barth
to Marcos Douglas
Marcos Douglas wrote 90 lines
On Sun, Sep 15, 2013 at 6:56 AM, Sven Barth wrote: > On 15.09.2013 03:21, Marcos Douglas wrote: >> >> Hi, >> >> 1) I have a code like that: >> >> procedure TghSQLConnector.Connect; >> begin >> try >> FLib.Connect; >> except >> on E: Exception do >> DoOnException(E); >> end; >> end; >> >> https://github.com/mdbs99/Greyhound/blob/0.1.8/src/ghsql.pas#L1565 >> >> >> 2) DoOnException was implemented so: >> >> procedure TghSQLHandler.DoOnException(E: Exception); >> begin >> if Assigned(FOnException) then >> FOnException(Self, E) >> else >> raise E; >> end; >> >> https://github.com/mdbs99/Greyhound/blob/0.1.8/src/ghsql.pas#L443 >> >> >> So, as you see, if occurs a Exception the code checks if the event >> (OnException) was setted. If yes, call user implementation; if no, >> call raise E; >> It works... but not when I uses in FPCUnit tests. >> >> See a simple test (this works): >> >> procedure TghSQLConnectorTest.TestOnException; >> begin >> // catch >> FConn.OnException := @DoOnException; >> FConn.Script.Text := 'foo'; >> FConn.Execute; >> end; >> >> https://github.com/mdbs99/Greyhound/blob/0.1.8/test/ghsqltest.pas#L246 >> >> >> The code DoOnException is: >> >> procedure TghSQLTest.DoOnException(Sender: TObject; E: Exception); >> begin >> AssertTrue(Assigned(E)); >> end; >> >> https://github.com/mdbs99/Greyhound/blob/0.1.8/test/ghsqltest.pas#L141 >> >> So, if I change the test like bellow... BUM! SIGSEGV!! >> >> procedure TghSQLConnectorTest.TestOnException; >> begin >> // removed >>> FConn.OnException := @DoOnException; >> FConn.Script.Text := 'foo'; >> FConn.Execute; >> end; >> >> >> The ERROR is: >> [Content] >> Project test raised exception class 'External: SIGSEGV'. >> >> At address 40B758 > > > Could you as a test replace the > > raise E > > with > > raise E at get_caller_addr(get_frame), get_caller_frame(get_frame); > > and check whether this makes a difference? I tried. No makes difference. (could you explain which the difference to call "raise" using "raise E at [...]"?)

The raise-at statement allows you to raise an exception for a specific address. This allows you to have e.g. a error handling procedure (to wrap a more compilated generation of a exception class) but have the exception address still point to the original call site. E.g.:

=== code begin ===

procedure Error(aArg: Boolean);
begin
   if aArg then
     raise Exception.Create('Test')
   else
     raise Exception.Create('Test') at get_caller_addr(get_frame),
get_caller_frame(get_frame);
end;
procedure Test1;
begin
   Error(True);
end;
procedure Test2;
begin
   Error(False);
end;
begin
   try
     Test1;
   except
     DumpExceptionBackTrace(Output);
   end;
   try
     Test2;
   except
     DumpExceptionBackTrace(Output);
   end;
end;

=== code end ===

In case one the stack trace will contain Test1 and Error in case two the stack trace will be only Test2.

Show quoted text 19 lines
I implemented -- but not up to Git yet -- some like that: procedure TghSQLHandler.DoOnException(E: Exception); var NewEx: EghSQLError; begin if Assigned(FOnException) then FOnException(Self, E) else begin NewEx := EghSQLError.Create(Self, E.Message); // <<< NewEx.InnerException := E; // <<< raise NewEx; end; end; So, if I recreate the Exception, it works in any cases. As you see, I created a new property (InnerException) to save the original exception to know what the real Exception happened... But I think this introduces much more overhead to processing.

Can you access fields of the InnerException? Maybe it's a problem of reraising an existing exception...

Show quoted text 5 lines
In my code I have classes that inherited from TghSQLHandler. This class have the DoOnException method. So DoOnException can be call many times in override methods. Maybe the program "broke" the stack because "raise E" can be call and raise an exception; the next "level" raise another; and next call again. :/

Could possibly be. If you could reproduce it in an as simple example as possible that would help.

Another thing you could try (just for testing): change your exception handler procedure to a function that returns bool and use it like this:

=== code begin ===

procedure TghSQLConnector.Connect;
begin
   try
     FLib.Connect;
   except
     on E: Exception do
       if not DoOnException(E) then
         raise;
   end;
end;

=== code end ===

Regards,
Sven

Reply by email

Marcos Douglas
to Sven Barth
Sven Barth wrote 53 lines
On 15.09.2013 13:05, Marcos Douglas wrote: > > [[cut]] > > > I tried. No makes difference. > (could you explain which the difference to call "raise" using "raise E > at [...]"?) The raise-at statement allows you to raise an exception for a specific address. This allows you to have e.g. a error handling procedure (to wrap a more compilated generation of a exception class) but have the exception address still point to the original call site. E.g.: === code begin === procedure Error(aArg: Boolean); begin if aArg then raise Exception.Create('Test') else raise Exception.Create('Test') at get_caller_addr(get_frame), get_caller_frame(get_frame); end; procedure Test1; begin Error(True); end; procedure Test2; begin Error(False); end; begin try Test1; except DumpExceptionBackTrace(Output); end; try Test2; except DumpExceptionBackTrace(Output); end; end; === code end === In case one the stack trace will contain Test1 and Error in case two the stack trace will be only Test2.

Ok, thanks for the explanation!

Show quoted text 23 lines
> I implemented -- but not up to Git yet -- some like that: > procedure TghSQLHandler.DoOnException(E: Exception); > var > NewEx: EghSQLError; > begin > if Assigned(FOnException) then > FOnException(Self, E) > else > begin > NewEx := EghSQLError.Create(Self, E.Message); // <<< > NewEx.InnerException := E; // <<< > raise NewEx; > end; > end; > > So, if I recreate the Exception, it works in any cases. As you see, I > created a new property (InnerException) to save the original > exception to know what the real Exception happened... > But I think this introduces much more overhead to processing. Can you access fields of the InnerException? Maybe it's a problem of reraising an existing exception...

Yes, I have access but no, this is not the problem. I had coded InnerException property after the problem to solve it, creating a new Exception but not missing the original one.

Show quoted text 9 lines
> In my code I have classes that inherited from TghSQLHandler. This > class have the DoOnException method. > So DoOnException can be call many times in override methods. Maybe the > program "broke" the stack because "raise E" can be call and raise an > exception; the next "level" raise another; and next call again. :/ Could possibly be. If you could reproduce it in an as simple example as possible that would help.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
In attachment.
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Show quoted text 22 lines
Another thing you could try (just for testing): change your exception handler procedure to a function that returns bool and use it like this: === code begin === procedure TghSQLConnector.Connect; begin try FLib.Connect; except on E: Exception do if not DoOnException(E) then raise; end; end; === code end === Regards, Sven

The only difference is the use of raise; instead raise E; right?

Marcos Douglas

Reply by email

Marcos Douglas
to Marcos Douglas
Marcos Douglas wrote 130 lines
On Sun, Sep 15, 2013 at 4:25 PM, Sven Barth wrote: > On 15.09.2013 13:05, Marcos Douglas wrote: >> >> [[cut]] >> >> >> I tried. No makes difference. >> (could you explain which the difference to call "raise" using "raise E >> at [...]"?) > > > The raise-at statement allows you to raise an exception for a specific > address. This allows you to have e.g. a error handling procedure (to wrap a > more compilated generation of a exception class) but have the exception > address still point to the original call site. E.g.: > > === code begin === > > procedure Error(aArg: Boolean); > begin > if aArg then > raise Exception.Create('Test') > else > raise Exception.Create('Test') at get_caller_addr(get_frame), > get_caller_frame(get_frame); > end; > > procedure Test1; > begin > Error(True); > end; > > procedure Test2; > begin > Error(False); > end; > > begin > try > Test1; > except > DumpExceptionBackTrace(Output); > end; > try > Test2; > except > DumpExceptionBackTrace(Output); > end; > end; > > === code end === > > In case one the stack trace will contain Test1 and Error in case two the > stack trace will be only Test2. Ok, thanks for the explanation! >> I implemented -- but not up to Git yet -- some like that: >> procedure TghSQLHandler.DoOnException(E: Exception); >> var >> NewEx: EghSQLError; >> begin >> if Assigned(FOnException) then >> FOnException(Self, E) >> else >> begin >> NewEx := EghSQLError.Create(Self, E.Message); // <<< >> NewEx.InnerException := E; // <<< >> raise NewEx; >> end; >> end; >> >> So, if I recreate the Exception, it works in any cases. As you see, I >> created a new property (InnerException) to save the original >> exception to know what the real Exception happened... >> But I think this introduces much more overhead to processing. > > > Can you access fields of the InnerException? Maybe it's a problem of > reraising an existing exception... Yes, I have access but no, this is not the problem. I had coded InnerException property after the problem to solve it, creating a new Exception but not missing the original one. >> In my code I have classes that inherited from TghSQLHandler. This >> class have the DoOnException method. >> So DoOnException can be call many times in override methods. Maybe the >> program "broke" the stack because "raise E" can be call and raise an >> exception; the next "level" raise another; and next call again. :/ > > > Could possibly be. If you could reproduce it in an as simple example as > possible that would help. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! In attachment. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! > Another thing you could try (just for testing): change your exception > handler procedure to a function that returns bool and use it like this: > > === code begin === > > > procedure TghSQLConnector.Connect; > begin > try > FLib.Connect; > except > on E: Exception do > if not DoOnException(E) then > raise; > end; > end; > > === code end === > > > Regards, > Sven The only difference is the use of raise; instead raise E; right? Marcos Douglas

In project in attachment before, if you change the line 50 from:

    raise E;
to:
    raise Exception.Create(E.Message);

Will work... but is this correct?

Lazarus 1.1 r42461 FPC 2.6.2 i386-win32-win32/win64

Best regards,
Marcos Douglas

PS: Sorry for my late, Sven.

Reply by email

Sven Barth
to Marcos Douglas: Ok, thanks for the explanation! Yes, I have access but no, this is not the problem. I had…
Marcos Douglas wrote 27 lines
>> I implemented -- but not up to Git yet -- some like that: >> procedure TghSQLHandler.DoOnException(E: Exception); >> var >> NewEx: EghSQLError; >> begin >> if Assigned(FOnException) then >> FOnException(Self, E) >> else >> begin >> NewEx := EghSQLError.Create(Self, E.Message); // <<< >> NewEx.InnerException := E; // <<< >> raise NewEx; >> end; >> end; >> >> So, if I recreate the Exception, it works in any cases. As you see, I >> created a new property (InnerException) to save the original >> exception to know what the real Exception happened... >> But I think this introduces much more overhead to processing. > > > Can you access fields of the InnerException? Maybe it's a problem of > reraising an existing exception... Yes, I have access but no, this is not the problem. I had coded InnerException property after the problem to solve it, creating a new Exception but not missing the original one.

Was just an idea that something got freed while you didn't expect it to get freed...

Show quoted text 14 lines
>> In my code I have classes that inherited from TghSQLHandler. This >> class have the DoOnException method. >> So DoOnException can be call many times in override methods. Maybe the >> program "broke" the stack because "raise E" can be call and raise an >> exception; the next "level" raise another; and next call again. :/ > > > Could possibly be. If you could reproduce it in an as simple example as > possible that would help. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! In attachment. !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

Will take a look when I find the time (or someone else of the devs can take a look as well ^^)

Show quoted text 24 lines
> Another thing you could try (just for testing): change your exception > handler procedure to a function that returns bool and use it like this: > > === code begin === > > > procedure TghSQLConnector.Connect; > begin > try > FLib.Connect; > except > on E: Exception do > if not DoOnException(E) then > raise; > end; > end; > > === code end === > > > Regards, > Sven The only difference is the use of raise; instead raise E; right?

Basically, yes. But "raise;" can only be used inside an "except ... end" block, so it would not compile inside your DoOnException method.

Regards,
Sven

Reply by email

Sven Barth
to Marcos Douglas: In project in attachment before, if you change the line 50 from: raise E; to: raise…
Marcos Douglas wrote 36 lines
On Tue, Sep 17, 2013 at 12:18 PM, Marcos Douglas wrote: >> Another thing you could try (just for testing): change your exception >> handler procedure to a function that returns bool and use it like this: >> >> === code begin === >> >> >> procedure TghSQLConnector.Connect; >> begin >> try >> FLib.Connect; >> except >> on E: Exception do >> if not DoOnException(E) then >> raise; >> end; >> end; >> >> === code end === >> >> >> Regards, >> Sven > > The only difference is the use of raise; instead raise E; right? > > Marcos Douglas In project in attachment before, if you change the line 50 from: raise E; to: raise Exception.Create(E.Message); Will work... but is this correct?

So this seems to be indeed a problem of freeing exceptions. Whether you misuse the exception system or you encountered a bug needs to be determined...

Lazarus 1.1 r42461 FPC 2.6.2 i386-win32-win32/win64

Could you test your original one with 2.7.1 as well?

PS: Sorry for my late, Sven.

No problem. :)

Regards,
Sven

Reply by email

Marcos Douglas
to Sven Barth
Sven Barth wrote 46 lines
On 17.09.2013 17:27, Marcos Douglas wrote: > > On Tue, Sep 17, 2013 at 12:18 PM, Marcos Douglas wrote: >>> >>> Another thing you could try (just for testing): change your exception >>> handler procedure to a function that returns bool and use it like this: >>> >>> === code begin === >>> >>> >>> procedure TghSQLConnector.Connect; >>> begin >>> try >>> FLib.Connect; >>> except >>> on E: Exception do >>> if not DoOnException(E) then >>> raise; >>> end; >>> end; >>> >>> === code end === >>> >>> >>> Regards, >>> Sven >> >> >> The only difference is the use of raise; instead raise E; right? >> >> Marcos Douglas > > > In project in attachment before, if you change the line 50 > from: > raise E; > > to: > raise Exception.Create(E.Message); > > Will work... but is this correct? So this seems to be indeed a problem of freeing exceptions. Whether you misuse the exception system or you encountered a bug needs to be determined...

If this is a bug I can register in bug tracker.

> Lazarus 1.1 r42461 FPC 2.6.2 i386-win32-win32/win64 Could you test your original one with 2.7.1 as well?

I can't compile Lazarus with FPC 2.7.1 (as you saw in lazarus-list) so, I can't test... :(

> PS: Sorry for my late, Sven. No problem. :)

Thanks,

Marcos Douglas

Reply by email

Sven Barth
to Marcos Douglas
"Marcos Douglas" wrote
On Tue, Sep 17, 2013 at 2:41 PM, Sven Barth
> On 17.09.2013 17:27, Marcos Douglas wrote: >> >> On Tue, Sep 17, 2013 at 12:18 PM, Marcos Douglas
>>>> >>>> Another thing you could try (just for testing): change your exception >>>> handler procedure to a function that returns bool and use it like

this:

Show quoted text 42 lines
>>>> >>>> === code begin === >>>> >>>> >>>> procedure TghSQLConnector.Connect; >>>> begin >>>> try >>>> FLib.Connect; >>>> except >>>> on E: Exception do >>>> if not DoOnException(E) then >>>> raise; >>>> end; >>>> end; >>>> >>>> === code end === >>>> >>>> >>>> Regards, >>>> Sven >>> >>> >>> The only difference is the use of raise; instead raise E; right? >>> >>> Marcos Douglas >> >> >> In project in attachment before, if you change the line 50 >> from: >> raise E; >> >> to: >> raise Exception.Create(E.Message); >> >> Will work... but is this correct? > > > So this seems to be indeed a problem of freeing exceptions. Whether you > misuse the exception system or you encountered a bug needs to be > determined... If this is a bug I can register in bug tracker.

I don't know yet whether it's a bug or a mistake...

Show quoted text 8 lines
>> Lazarus 1.1 r42461 FPC 2.6.2 i386-win32-win32/win64 > > > Could you test your original one with 2.7.1 as well? I can't compile Lazarus with FPC 2.7.1 (as you saw in lazarus-list) so, I can't test... :(

It's ok if you use a 2.7.1 before the merge of the cpstrrtl branch. There AFAIK weren't any exception related changes since then.

Regards,
Sven

Reply by email

Marcos Douglas
to Sven Barth
Sven Barth wrote 70 lines
Am 18.09.2013 23:34 schrieb "Marcos Douglas" : > > On Tue, Sep 17, 2013 at 2:41 PM, Sven Barth > wrote: > > On 17.09.2013 17:27, Marcos Douglas wrote: > >> > >> On Tue, Sep 17, 2013 at 12:18 PM, Marcos Douglas > >> wrote: > >>>> > >>>> Another thing you could try (just for testing): change your exception > >>>> handler procedure to a function that returns bool and use it like > >>>> this: > >>>> > >>>> === code begin === > >>>> > >>>> > >>>> procedure TghSQLConnector.Connect; > >>>> begin > >>>> try > >>>> FLib.Connect; > >>>> except > >>>> on E: Exception do > >>>> if not DoOnException(E) then > >>>> raise; > >>>> end; > >>>> end; > >>>> > >>>> === code end === > >>>> > >>>> > >>>> Regards, > >>>> Sven > >>> > >>> > >>> The only difference is the use of raise; instead raise E; right? > >>> > >>> Marcos Douglas > >> > >> > >> In project in attachment before, if you change the line 50 > >> from: > >> raise E; > >> > >> to: > >> raise Exception.Create(E.Message); > >> > >> Will work... but is this correct? > > > > > > So this seems to be indeed a problem of freeing exceptions. Whether you > > misuse the exception system or you encountered a bug needs to be > > determined... > > If this is a bug I can register in bug tracker. I don't know yet whether it's a bug or a mistake... > > >> Lazarus 1.1 r42461 FPC 2.6.2 i386-win32-win32/win64 > > > > > > Could you test your original one with 2.7.1 as well? > > I can't compile Lazarus with FPC 2.7.1 (as you saw in lazarus-list) > so, I can't test... :( It's ok if you use a 2.7.1 before the merge of the cpstrrtl branch. There AFAIK weren't any exception related changes since then.

For now I resolved use re-raise the original Exception using FPC 2.6.2.

Thank you again.

Marcos Douglas

Reply by email