Subject | Firebird exits after using UDF, idle, rollback and exit |
---|---|
Author | Vitali Voroth |
Post date | 2013-06-12T18:47:43Z |
Hi!
I'm not sure if the following is a bug, so i try it here first before posting it to
firebird-devel. Chances are that somebody on this list can help me.
I am running the 64-bit version of Firebird 2.5.2 (26540) on Windows 7.
I noticed that the server crashes after using a udf compiled with FreePascal,
letting the transaction open and idle for a few minutes and then exit the client.
There are no helpful entries in the firebird.log file or in Windows event log.
I tried to trace the server with FB TraceManager 3 Lite but it simply loses its
server connection when the other client exits forcing the server to shutdown.
Steps to reproduce with the example database from Firebird release:
C:\Program Files\Firebird\FB25_GDI_23053\bin>isql LOCALHOST/23053:D:\dev\EMPLOYEE.FDB -u sysdba -p masterkey
Database: LOCALHOST/23053:D:\dev\EMPLOYEE.FDB, User: sysdba
SQL> DECLARE EXTERNAL FUNCTION RUNDEN
CON> DOUBLE PRECISION, INTEGER
CON> RETURNS DOUBLE PRECISION BY VALUE
CON> ENTRY_POINT 'fn_Runden' MODULE_NAME 'gdi_udf3';
SQL> select Runden(3.14159265358979, 2) from rdb$database;
RUNDEN
=======================
3.140000000000000
-- WAIT A FEW MINUTES (3 to 5) before:
SQL> rollback;
SQL> exit;
Actually it's not important whether you rollback, commit or just exit.
It's important to let the connection open for a few minutes, though!
Usually the isql client exits instant but when the error described above
force the server to shutdown the exit step takes a few seconds.
Any help or hints are appreciated.
The Sources of the udf, in case somebody wants to see it:
1. The lazarus main project file (udf_mini.lpr)
library UDF_MINI;
{$mode objfpc}{$H+}
uses
Classes, udf3_mini;
exports
fn_Runden name 'fn_Runden';
begin
end.
2. The unit with the actual function (udf3_mini.pas)
unit udf3_mini;
{$IFDEF FPC}
{$MODE Delphi}
{$ENDIF}
interface
uses
Classes;
type
ISC_Integer = Integer;
ISC_Double = Double;
function fn_Runden(var Value: ISC_Double; var nk : ISC_Integer): ISC_Double; cdecl; export;
implementation
function fn_Runden(var Value: ISC_Double; var nk : ISC_Integer): ISC_Double; cdecl; export;
var
Hoch,i : Integer;
wert : Double;
begin
Result := 0.0;
Hoch := 1;
for i := 1 to nk do
hoch := hoch * 10;
wert := Value * Hoch;
if wert >= 0 then
wert := wert + 0.501
else
wert := wert - 0.501;
Result := (System.Int(wert) / Hoch);
end;
end.
[Non-text portions of this message have been removed]
I'm not sure if the following is a bug, so i try it here first before posting it to
firebird-devel. Chances are that somebody on this list can help me.
I am running the 64-bit version of Firebird 2.5.2 (26540) on Windows 7.
I noticed that the server crashes after using a udf compiled with FreePascal,
letting the transaction open and idle for a few minutes and then exit the client.
There are no helpful entries in the firebird.log file or in Windows event log.
I tried to trace the server with FB TraceManager 3 Lite but it simply loses its
server connection when the other client exits forcing the server to shutdown.
Steps to reproduce with the example database from Firebird release:
C:\Program Files\Firebird\FB25_GDI_23053\bin>isql LOCALHOST/23053:D:\dev\EMPLOYEE.FDB -u sysdba -p masterkey
Database: LOCALHOST/23053:D:\dev\EMPLOYEE.FDB, User: sysdba
SQL> DECLARE EXTERNAL FUNCTION RUNDEN
CON> DOUBLE PRECISION, INTEGER
CON> RETURNS DOUBLE PRECISION BY VALUE
CON> ENTRY_POINT 'fn_Runden' MODULE_NAME 'gdi_udf3';
SQL> select Runden(3.14159265358979, 2) from rdb$database;
RUNDEN
=======================
3.140000000000000
-- WAIT A FEW MINUTES (3 to 5) before:
SQL> rollback;
SQL> exit;
Actually it's not important whether you rollback, commit or just exit.
It's important to let the connection open for a few minutes, though!
Usually the isql client exits instant but when the error described above
force the server to shutdown the exit step takes a few seconds.
Any help or hints are appreciated.
The Sources of the udf, in case somebody wants to see it:
1. The lazarus main project file (udf_mini.lpr)
library UDF_MINI;
{$mode objfpc}{$H+}
uses
Classes, udf3_mini;
exports
fn_Runden name 'fn_Runden';
begin
end.
2. The unit with the actual function (udf3_mini.pas)
unit udf3_mini;
{$IFDEF FPC}
{$MODE Delphi}
{$ENDIF}
interface
uses
Classes;
type
ISC_Integer = Integer;
ISC_Double = Double;
function fn_Runden(var Value: ISC_Double; var nk : ISC_Integer): ISC_Double; cdecl; export;
implementation
function fn_Runden(var Value: ISC_Double; var nk : ISC_Integer): ISC_Double; cdecl; export;
var
Hoch,i : Integer;
wert : Double;
begin
Result := 0.0;
Hoch := 1;
for i := 1 to nk do
hoch := hoch * 10;
wert := Value * Hoch;
if wert >= 0 then
wert := wert + 0.501
else
wert := wert - 0.501;
Result := (System.Int(wert) / Hoch);
end;
end.
[Non-text portions of this message have been removed]