Re: [fpc-devel] Segmentation fault for Firebird exception inside thread

2011-10-26 Thread Michael Van Canneyt


What happens if you comipile with -gl and  run the program under GDB ? 
can you post a backtrace ?
Note that you may need to add a {$linklib pthread} to the program source, 
otherwise gdb may complain about missing threads support.


The backtrace will show us exactly where the error occurs (or it should).

Michael.

On Wed, 26 Oct 2011, Stefan wrote:

Ok, today I installed the fixes_2_4 branch of fpc subversion repository on 
Ubuntu 11.10 64-bits.


Then I compiled the code from my initial post like this:

code
stefan@PSERVER:~/Development/ProgramasLazarus/src$ fpc -dUseCThreads 
-ofbthreadtest fbthreadtest.lpr

Free Pascal Compiler version 2.4.5 [2011/10/26] for x86_64
Copyright (c) 1993-2010 by Florian Klaempfl
Target OS: Linux for x86-64
Compiling fbthreadtest.lpr
fbthreadtest.lpr(6,2) Note: APPTYPE is not supported by the target OS
fbthreadtest.lpr(33,9) Warning: Symbol Resume is deprecated
Linking fbthreadtest
/usr/bin/ld: warning: link.res contains output sections; did you forget -T?
90 lines compiled, 0.5 sec
1 warning(s) issued
1 note(s) issued
/code

Then I called the program:

code
stefan@PSERVER:~/Development/ProgramasLazarus/src$./fbthreadtest
select...
...exception
Violación de segmento
/code

This is the output when in fact a connection to the Firebird database has 
been established.


When the connection to the database could not be established, for example 
because the

database does not exist, the program returns nothing.

I've installed Firebird 2.5.1 with the corresponding client library, but I 
think that the poblem is on

the FreePascal side.

Thanks for all the suggestions so far,

Stefan



El 25/10/2011 14:23, Joost van der Sluis escribió:

On Tue, 2011-10-25 at 14:10 +0200, Ludo Brands wrote:

I'm using FPC 2.2.5, so perhaps the error is already known,
but I did not find any solution in the web.

I tested the code on Windows 32 bits and Linux 32 bits too,
but there everything seems ok.

Tried your code on ubuntu 10.04 x86_64 using both libfbclient and 
libfbembed

2.1, fpc 2.7.1. It doesn't create a SIGSEGV. Just a EIBDataBaseError.
Problem seems to have been solved in the mean time.

Stefan, maybe that the debugger had problems showing the error. Please
try to run your application outside the debugger. Maybe that in that
case you'll see an EIBDatabaseError.

Joost.

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


[fpc-devel] Segmentation fault for Firebird exception inside thread

2011-10-25 Thread Stefan

Hello, this is my first post and I hope this is the correct list for my 
question.

I'm getting a segmentation fault ('violación de segmento' in spanish)
when running the code from below on a Linux 64-bit machine (OpenSuse 10.2 
64-bits).

I'm using FPC 2.2.5, so perhaps the error is already known, but I did not find 
any solution in the web.

I tested the code on Windows 32 bits and Linux 32 bits too, but there 
everything seems ok.

The example is about opening a Firebird connection in a thread.
When there is a Firebird exception inside this connection,
the application terminates with the segmentation fault.

Does anyone know about this error, or can anyone give me a hint, where to look 
for a solution?

This is the example code:

code
program fbthreadtest;
{$IFDEF FPC}
  {$MODE DELPHI}{$H+}
{$ENDIF}

{$APPTYPE CONSOLE}

uses
  {$IFDEF UNIX}
  cthreads,
  cwstring,
  {$ENDIF}
  Classes,
  IBConnection, sqldb;

type
  TFBThread = class(TThread)
  private
  protected
procedure Execute; override;
  public
constructor Create;
  end;

constructor TFBThread.Create;
begin
  inherited Create(True);
  FreeOnTerminate := False;
  Resume;
end;

procedure TFBThread.Execute;
var
  db: TIBConnection;
  tr: TSQLTransaction;
  q: TSQLQuery;
begin
  db := TIBConnection.Create(nil);
  try
db.DatabaseName := 'localhost:/home/data/Database/ssstst.gdb';
db.LoginPrompt := False;
db.HostName := '';
db.UserName := 'SYSDBA';
db.Password := 'masterkey';
db.Connected := TRUE;
tr := TSQLTransaction.Create(nil);
try
  tr.DataBase := db;
  tr.Action   := caCommit;
  tr.Params.Clear;
  tr.Params.Add('isc_tpb_read_committed');
  tr.Params.Add('isc_tpb_rec_version');
  tr.Params.Add('isc_tpb_nowait');
  db.Transaction := tr;
  tr.Active := True;
  q := TSQLQuery.Create(nil);
  try
q.Database:= db;
q.Transaction := tr;

try
  Writeln('select...');
  // the following line raises an exception because rdb$databases 
doesn't exist.
  q.SQL.Text := 'select count(*) from rdb$databases';
  q.Prepare;
except
  Writeln('...exception');
end;
  finally
q.Free;
  end;
finally
  tr.Commit;
  tr.Free;
end;
  finally
db.Connected := False;
db.Free;
  end;
end;

begin
  with TFBThread.Create do begin
WaitFor;
Free;
  end;
end.
/code

Thanks,

Stefan
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] Segmentation fault for Firebird exception inside thread

2011-10-25 Thread michael . vancanneyt



On Tue, 25 Oct 2011, Stefan wrote:

Hello, this is my first post and I hope this is the correct list for my 
question.


I'm getting a segmentation fault ('violación de segmento' in spanish)
when running the code from below on a Linux 64-bit machine (OpenSuse 10.2 
64-bits).


I'm using FPC 2.2.5, so perhaps the error is already known, but I did not 
find any solution in the web.


I tested the code on Windows 32 bits and Linux 32 bits too, but there 
everything seems ok.


The example is about opening a Firebird connection in a thread.
When there is a Firebird exception inside this connection,
the application terminates with the segmentation fault.


What do you mean by 'a firebird exception' ?

An exception generated by the firebird engine itself (i.e. fbclient.so) ?

Michael.___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] Segmentation fault for Firebird exception inside thread

2011-10-25 Thread LacaK
May be that is is (or not ;-)) related to 
http://bugs.freepascal.org/view.php?id=17360

-Laco.
Hello, this is my first post and I hope this is the correct list for 
my question.


I'm getting a segmentation fault ('violación de segmento' in spanish)
when running the code from below on a Linux 64-bit machine (OpenSuse 
10.2 64-bits).


I'm using FPC 2.2.5, so perhaps the error is already known, but I did 
not find any solution in the web.


I tested the code on Windows 32 bits and Linux 32 bits too, but there 
everything seems ok.


The example is about opening a Firebird connection in a thread.
When there is a Firebird exception inside this connection,
the application terminates with the segmentation fault.

Does anyone know about this error, or can anyone give me a hint, where 
to look for a solution?


This is the example code:

code
program fbthreadtest;
{$IFDEF FPC}
  {$MODE DELPHI}{$H+}
{$ENDIF}

{$APPTYPE CONSOLE}

uses
  {$IFDEF UNIX}
  cthreads,
  cwstring,
  {$ENDIF}
  Classes,
  IBConnection, sqldb;

type
  TFBThread = class(TThread)
  private
  protected
procedure Execute; override;
  public
constructor Create;
  end;

constructor TFBThread.Create;
begin
  inherited Create(True);
  FreeOnTerminate := False;
  Resume;
end;

procedure TFBThread.Execute;
var
  db: TIBConnection;
  tr: TSQLTransaction;
  q: TSQLQuery;
begin
  db := TIBConnection.Create(nil);
  try
db.DatabaseName := 'localhost:/home/data/Database/ssstst.gdb';
db.LoginPrompt := False;
db.HostName := '';
db.UserName := 'SYSDBA';
db.Password := 'masterkey';
db.Connected := TRUE;
tr := TSQLTransaction.Create(nil);
try
  tr.DataBase := db;
  tr.Action   := caCommit;
  tr.Params.Clear;
  tr.Params.Add('isc_tpb_read_committed');
  tr.Params.Add('isc_tpb_rec_version');
  tr.Params.Add('isc_tpb_nowait');
  db.Transaction := tr;
  tr.Active := True;
  q := TSQLQuery.Create(nil);
  try
q.Database:= db;
q.Transaction := tr;

try
  Writeln('select...');
  // the following line raises an exception because 
rdb$databases doesn't exist.

  q.SQL.Text := 'select count(*) from rdb$databases';
  q.Prepare;
except
  Writeln('...exception');
end;
  finally
q.Free;
  end;
finally
  tr.Commit;
  tr.Free;
end;
  finally
db.Connected := False;
db.Free;
  end;
end;

begin
  with TFBThread.Create do begin
WaitFor;
Free;
  end;
end.
/code

Thanks,

Stefan
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel



___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] Segmentation fault for Firebird exception inside thread

2011-10-25 Thread michael . vancanneyt



On Tue, 25 Oct 2011, LacaK wrote:

May be that is is (or not ;-)) related to 
http://bugs.freepascal.org/view.php?id=17360


I don't think linux has vectored exception handling ?

Michael.


-Laco.
Hello, this is my first post and I hope this is the correct list for my 
question.





I'm getting a segmentation fault ('violación de segmento' in spanish)
when running the code from below on a Linux 64-bit machine (OpenSuse 10.2 
64-bits).


I'm using FPC 2.2.5, so perhaps the error is already known, but I did not 
find any solution in the web.


I tested the code on Windows 32 bits and Linux 32 bits too, but there 
everything seems ok.


The example is about opening a Firebird connection in a thread.
When there is a Firebird exception inside this connection,
the application terminates with the segmentation fault.

Does anyone know about this error, or can anyone give me a hint, where to 
look for a solution?


This is the example code:

code
program fbthreadtest;
{$IFDEF FPC}
  {$MODE DELPHI}{$H+}
{$ENDIF}

{$APPTYPE CONSOLE}

uses
  {$IFDEF UNIX}
  cthreads,
  cwstring,
  {$ENDIF}
  Classes,
  IBConnection, sqldb;

type
  TFBThread = class(TThread)
  private
  protected
procedure Execute; override;
  public
constructor Create;
  end;

constructor TFBThread.Create;
begin
  inherited Create(True);
  FreeOnTerminate := False;
  Resume;
end;

procedure TFBThread.Execute;
var
  db: TIBConnection;
  tr: TSQLTransaction;
  q: TSQLQuery;
begin
  db := TIBConnection.Create(nil);
  try
db.DatabaseName := 'localhost:/home/data/Database/ssstst.gdb';
db.LoginPrompt := False;
db.HostName := '';
db.UserName := 'SYSDBA';
db.Password := 'masterkey';
db.Connected := TRUE;
tr := TSQLTransaction.Create(nil);
try
  tr.DataBase := db;
  tr.Action   := caCommit;
  tr.Params.Clear;
  tr.Params.Add('isc_tpb_read_committed');
  tr.Params.Add('isc_tpb_rec_version');
  tr.Params.Add('isc_tpb_nowait');
  db.Transaction := tr;
  tr.Active := True;
  q := TSQLQuery.Create(nil);
  try
q.Database:= db;
q.Transaction := tr;

try
  Writeln('select...');
  // the following line raises an exception because rdb$databases 
doesn't exist.

  q.SQL.Text := 'select count(*) from rdb$databases';
  q.Prepare;
except
  Writeln('...exception');
end;
  finally
q.Free;
  end;
finally
  tr.Commit;
  tr.Free;
end;
  finally
db.Connected := False;
db.Free;
  end;
end;

begin
  with TFBThread.Create do begin
WaitFor;
Free;
  end;
end.
/code

Thanks,

Stefan
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel



___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel
___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel


Re: [fpc-devel] Segmentation fault for Firebird exception inside thread

2011-10-25 Thread Joost van der Sluis
On Tue, 2011-10-25 at 14:10 +0200, Ludo Brands wrote:
  I'm using FPC 2.2.5, so perhaps the error is already known, 
  but I did not find any solution in the web.
  
  I tested the code on Windows 32 bits and Linux 32 bits too, 
  but there everything seems ok.
  
 
 Tried your code on ubuntu 10.04 x86_64 using both libfbclient and libfbembed
 2.1, fpc 2.7.1. It doesn't create a SIGSEGV. Just a EIBDataBaseError.
 Problem seems to have been solved in the mean time.

Stefan, maybe that the debugger had problems showing the error. Please
try to run your application outside the debugger. Maybe that in that
case you'll see an EIBDatabaseError.

Joost.
-- 
My Lazarus blog: http://www.lazarussupport.com/lazarus/weblog

___
fpc-devel maillist  -  fpc-devel@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-devel