Subject | FireBird 3.0.3 embedded is crashing when using an UDF function which returns a CSTRING |
---|---|
Author | Jelich, Michael |
Post date | 2018-07-20T19:22:39Z |
Hello support team,
We currently use FireBird 2.5.7 with a ‘self-made’ UDF-dll. It contains (beyond others) the following functions:
function StringToPAnsiChar(s: AnsiString): PAnsiChar; {$IFDEF UniCode} overload; {$ENDIF}
begin
Result:= ib_util_malloc(Length(s) + 1);
StrPCopy(Result, s);
end;
{$IFDEF UniCode}
function StringToPAnsiChar(s: string): PAnsiChar; overload;
begin
Result:= StringToPAnsiChar(AnsiString(s));
end;
{$ENDIF}
function Hex_Str(var AValue, ADigits: Integer): PAnsiChar; cdecl;
{
DECLARE EXTERNAL FUNCTION HEX_STR
INTEGER, INTEGER
RETURNS CSTRING(10) FREE_IT
ENTRY_POINT 'HEX_STR' MODULE_NAME 'AIMOS_UDF';
}
begin
Result:= StringToPAnsiChar(IntToHex(AValue, ADigits));
end;
After update to FireBird 3.0.3 “select HEX_STR(1,1) from rdb$database” succeeds only in case FireBird Server is used – in FireBird Embedded the calling process crashes (regardless if it is our software or another tool like ibExpert). The FireBird.log contains the following:
The user defined function: HEX_STR
referencing entrypoint: HEX_STR
in module: AIMOS_UDF
caused the fatal exception: Access violation.
The code attempted to access a virtual
address without privilege to do so.
This exception will cause the Firebird server
to terminate abnormally.
All functions in the UDF which also return a CSTRING fail the same way. All other functions (e.g. returning an integer) still work well, even in embedded mode.
I didn’t find any hints regarding changes or bugs with UDF’s in FB3 Embedded. The current daily branch of FB 3.0.4 has the same behavior. Do you know whether or not the firebird developers are aware of this?
If you are not responsible for this would you mind to let me know or better forward this mail to the responsible developers?
Best regards
Michael Jelich
Senior Software Developer
Andrew Wireless Systems GmbH
Germany - Buchdorf