Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

UDF crash after 2.5.1 update [CORE3747] #4091

Closed
firebird-automations opened this issue Jan 31, 2012 · 5 comments
Closed

UDF crash after 2.5.1 update [CORE3747] #4091

firebird-automations opened this issue Jan 31, 2012 · 5 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: André Müller Pereira (andremp)

Attachments:
accessUDF.dll

I have a UDF in FB2.1 used in many clients, without problems.
I'm testing the FB2.5 and with the same UDF and 4 from 6 functions from this UDF crash the connection.
I don´t see nothing new in documentation only the FREE_IT, I test but still the same problem.

Have some changes that I don't read ?

example:

DECLARE EXTERNAL FUNCTION FormatDate
TIMESTAMP,
CSTRING(80)
RETURNS CSTRING(80)
ENTRY_POINT 'FormatDate' MODULE_NAME 'accessUDF';

SQL:
select IntToDate(45000) from rdb$database --> this function Crash connection
select DateToInt(current_timestamp) from rdb$database --> OK! return 40939

DELPHI part of code
unit myfuncs;
uses
SysUtils, DateUtils, ibase, ib_externals, fb_descriptors, math;

function DateToInt(ib_date: PISC_QUAD): Integer; cdecl; export;
function IntToDate(val1: PParamDsc): PISC_QUAD; cdecl; export;
...
procedure SetaConfiguracoesRegionais;

implementation
function DateToInt(ib_date: PISC_QUAD): Integer; cdecl; export;
var
Data: TDateTime;
begin
Data := isc_decode_TDateTime(ib_date);
if (Data < EncodeDate(1899,12,30)) then
begin
result := 0;
Exit;
end;
result := DaysBetween(Data,EncodeDate(1899,12,30));
end;

function IntToDate(val1: PParamDsc): PISC_QUAD; cdecl; export;
var
Data: TDateTime;
v1: Int64;
begin
if (val1 = nil) or ((val1^.dsc_flags and DSC_null) <> 0) then
begin
result := nil;
Exit;
end;
get_int_type(val1, v1);
Data := EncodeDate(1899,12,30) + v1;
isc_encode_TDateTime(Data,result);
end;
...
//code from IBO
function isc_decode_TDateTime(const Src: PISC_QUAD): TDateTime;
begin
Result := Src^.gds_quad_high - 15018;
try
Result := Result + EncodeTime((Src^.gds_quad_low div (36000000)),
(Src^.gds_quad_low div (600000)) mod 60,
(Src^.gds_quad_low div (10000)) mod 60,
(Src^.gds_quad_low mod (10000)) div 10);
except
Result := Result + 0;
end;
end;
procedure isc_encode_TDateTime(const Src: TDateTime; const Dst: PISC_QUAD);
var
Hour, Min, Sec, MSec: word;
begin
DecodeTime(Src, Hour, Min, Sec, MSec);
with Dst^ do
begin
gds_quad_high := Trunc(Src) + 15018;
gds_quad_low := Hour * 10000 * 60 * 60 +
Min * 10000 * 60 +
Sec * 10000 +
MSec * 10;
end;
end;

@firebird-automations
Copy link
Collaborator Author

Commented by: André Müller Pereira (andremp)

the UDF

@firebird-automations
Copy link
Collaborator Author

Modified by: André Müller Pereira (andremp)

Attachment: accessUDF.dll [ 12093 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @aafemt

Your UDF contain bug - access to random memory. If it worked before, it was just an accident.

@firebird-automations
Copy link
Collaborator Author

Modified by: Sean Leyne (seanleyne)

status: Open [ 1 ] => Resolved [ 5 ]

resolution: Won't Fix [ 2 ]

@firebird-automations
Copy link
Collaborator Author

Modified by: @pcisar

status: Resolved [ 5 ] => Closed [ 6 ]

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant