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

Server crash. Acces violation while using UDF. [CORE1920] #2354

Closed
firebird-automations opened this issue Jun 3, 2008 · 3 comments
Closed

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: b0bik (b0bik)

UDF code (compiled to gonet_udf.dll in Borland Delphi 5):

function UPROSCNIP(aNip: PChar): PChar; cdecl;
var lS: string;
begin
lS := aNip;
lS := StringReplace(lS, '-','', [rfReplaceAll, rfIgnoreCase]);
lS := StringReplace(lS, ' ','', [rfReplaceAll, rfIgnoreCase]);
if UpperCase(copy(lS, 1, 2)) = 'PL' then
lS := copy(lS, 3, length(ls));
Result :=ib_util_malloc(length(lS)+1);
StrPCopy(Result, lS);
end{};

Declaration:

DECLARE EXTERNAL FUNCTION FN_UPROSCNIP
CSTRING(64)
RETURNS CSTRING(64) FREE_IT
ENTRY_POINT 'UPROSCNIP' MODULE_NAME 'gonet_udf'

This UDF is used in TRIGGERS to fill one field from another:

CREATE TRIGGER KONTRAHENT_BI FOR KONTRAHENT ACTIVEBEFORE INSERT POSITION 0
AS
BEGIN
NEW.PROSTYNIP = FN_UPROSCNIP(NEW.NIP);
END

CREATE TRIGGER KONTRAHENT_BU FOR KONTRAHENT ACTIVEBEFORE UPDATE POSITION 0
AS
BEGIN
NEW.PROSTYNIP = FN_UPROSCNIP(NEW.NIP);
END

Field PROSTYNIP and NIP has a VARCHAR(20) type.

Sometimes (but not always) during simple update or insert server crashes with message (firebird.log):

BOGDAN (Server) Fri May 23 10:38:14 2008
The user defined function: FN_UPROSCNIP
referencing entrypoint: UPROSCNIP
in module: gonet_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.

BOGDAN (Server) Fri May 23 10:38:14 2008
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.

BOGDAN (Client) Fri May 23 10:38:14 2008
C:\Program Files\Firebird_15\bin\fbserver.exe: terminated abnormally (4294967295)

BOGDAN (Client) Fri May 23 10:38:15 2008
Guardian starting: C:\Program Files\Firebird_15\bin\fbserver.exe

I also noticed this on FB 1.5.2.

The same situation occurs on two different machines. I can't precisely define situation wchich in 100% causes this problem. UDF works perfectly 90%, but sometimes during update or insert server crashes.

@firebird-automations
Copy link
Collaborator Author

Commented by: Sean Leyne (seanleyne)

This is not a Firebird engine issue, the problem is in your UDF code.

Please post a message to the Support list asking for help.

@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