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

using a Freepascal 64bit UDF causes the engine to exit on client disconnect [CORE3651] #4002

Closed
firebird-automations opened this issue Nov 4, 2011 · 12 comments

Comments

@firebird-automations
Copy link
Collaborator

Submitted by: Frank Schlottmann-Goedde (fsg)

Is related to CORE3649

Attachments:
libtest64.so.bz2

Votes: 2

create a simple freepascal udf:

library test64;
uses
strings;
procedure str_same(instring,outstring:pchar);cdecl;export;
begin
strcopy(outstring,instring); {return instring}
end;

exports
str_same name 'str_same';
begin
end.

declare it to the engine:

DECLARE EXTERNAL FUNCTION STR_SAME
cstring(256), cstring(256)
RETURNS parameter 2
ENTRY_POINT 'str_same'
MODULE_NAME 'test64';

use it:

fsg@fsg-ThinkPad-E520:~/src/fpc/fsg_udf$ isql -user sysdba -password masterke localhost:/opt/ibdata/employee.fdb
Database: localhost:/opt/ibdata/employee.fdb, User: sysdba
SQL> select str_same('test2') from rdb$database;

STR_SAME

test2

SQL> quit;
fsg@fsg-ThinkPad-E520:~/src/fpc/fsg_udf$

strace will report:

root@fsg-ThinkPad-E520:~#⁠ strace -p 5102
Process 5102 attached - interrupt to quit
restart_syscall(<... resuming interrupted call ...>) = 1
poll([{fd=0, events=POLLIN}], 1, -1) = 1 ([{fd=0, revents=POLLIN}])
recvfrom(0, "\0\0\0\37\0\0\0\2", 8192, 0, NULL, NULL) = 8
clone(child_stack=0x7fdb35e1bf90, flags=CLONE_VM|CLONE_FS|CLONE_FILES|CLONE_SIGHAND|CLONE_THREAD|CLONE_SYSVSEM|CLONE_SETTLS|CLONE_PARENT_SETTID|CLONE_CHILD_CLEARTID, parent_tidptr=0x7fdb35e1c9d0, tls=0x7fdb35e1c700, child_tidptr=0x7fdb35e1c9d0) = 5113
futex(0x7fdb37d1ac48, FUTEX_WAKE_PRIVATE, 1) = 1
poll([{fd=0, events=POLLIN}], 1, 60000) = 1 ([{fd=0, revents=POLLIN}])
poll([{fd=0, events=POLLIN}], 1, -1) = 1 ([{fd=0, revents=POLLIN}])
recvfrom(0, "\0\0\0\37\0\0\0\1", 8192, 0, NULL, NULL) = 8
futex(0x7fdb35e1bd80, FUTEX_WAKE_PRIVATE, 1) = 1
futex(0x7fdb37d1abe0, FUTEX_WAKE_PRIVATE, 1) = 1
poll([{fd=0, events=POLLIN}], 1, 60000) = 1 ([{fd=0, revents=POLLIN}])
poll([{fd=0, events=POLLIN}], 1, -1) = 1 ([{fd=0, revents=POLLIN}])
recvfrom(0, "\0\0\0C\0\0\0\3\0\0\0\2\0\0\0\25\0\0\0\0", 8192, 0, NULL, NULL) = 20
poll([{fd=0, events=POLLIN}], 1, 60000PANIC: attached pid 5102 exited with 0
<unfinished ... exit status 0>

@firebird-automations
Copy link
Collaborator Author

Commented by: Robert Gilland (robert.gilland_basx.com.au)

Thanks Frank for raising this one

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

assignee: Alexander Peshkov [ alexpeshkoff ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @kattunga

I think that this bug is causing this other bug: CORE3649

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

Link: This issue is related to CORE3649 [ CORE3649 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: @AlexPeshkoff

I can not reproduce this bug.

I use ubuntu 11.04 with the following key components:
LI-V2.5.2.26411 Firebird 2.5
gcc version 4.5.2 (Ubuntu/Linaro 4.5.2-8ubuntu4)
glibc 2.13
Linux fbs 2.6.38-13-generic #⁠53-Ubuntu SMP Mon Nov 28 19:33:45 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
Free Pascal Compiler version 2.4.0-2ubuntu3 [2011/02/27] for x86_64

And when running isql I have no problems with network server exits:
alex@fbs:~/home/firebird/branches/B2_5_Release/gen/firebird/bin$ ./fb_smp_server &
[1] 18651
alex@fbs:~/home/firebird/branches/B2_5_Release/gen/firebird/bin$ ./isql -z -user sysdba -pas masterkey localhost:employee.fdb
ISQL Version: LI-V2.5.2.26411 Firebird 2.5
Server version:
LI-V2.5.2.26411 Firebird 2.5
LI-V2.5.2.26411 Firebird 2.5/tcp (fbs)/P12
LI-V2.5.2.26411 Firebird 2.5/tcp (fbs)/P12
Database: localhost:employee.fdb, User: sysdba
SQL> select str_same('test2') from rdb$database;

STR_SAME

test2

SQL> quit;
alex@fbs:~/home/firebird/branches/B2_5_Release/gen/firebird/bin$ ./isql -z -user sysdba -pas masterkey localhost:employee.fdb
ISQL Version: LI-V2.5.2.26411 Firebird 2.5
Server version:
LI-V2.5.2.26411 Firebird 2.5
LI-V2.5.2.26411 Firebird 2.5/tcp (fbs)/P12
LI-V2.5.2.26411 Firebird 2.5/tcp (fbs)/P12
Database: localhost:employee.fdb, User: sysdba
SQL>

@firebird-automations
Copy link
Collaborator Author

Commented by: Frank Schlottmann-Goedde (fsg)

Here I have
Ubuntu 11.10
gcc-Version 4.6.1 (Ubuntu/Linaro 4.6.1-9ubuntu3)
glibc 2.13 (Ubuntu EGLIBC 2.13-20ubuntu5)
LI-V2.5.2.26424 Firebird 2.5
Free Pascal Compiler version 2.4.4-2ubuntu1 [2011/09/27] for x86_64
and get the following:

root@fsg-ThinkPad-E520:~#⁠ /opt/fb25cs/bin/fb_smp_server &
[1] 20434
root@fsg-ThinkPad-E520:~#⁠ /opt/fb25cs/bin/isql -z -user sysdba -password masterke localhost:/opt/ibdata/employee.fdb
ISQL Version: LI-V2.5.2.26424 Firebird 2.5
Server version:
LI-V2.5.2.26424 Firebird 2.5
LI-V2.5.2.26424 Firebird 2.5/tcp (fsg-ThinkPad-E520)/P12
LI-V2.5.2.26424 Firebird 2.5/tcp (fsg-ThinkPad-E520)/P12
Database: localhost:/opt/ibdata/employee.fdb, User: sysdba
SQL> select str_same('test') from rdb$database;

STR_SAME

test

SQL> exit;
[1]+ Fertig /opt/fb25cs/bin/fb_smp_server
root@fsg-ThinkPad-E520:~#⁠ /opt/fb25cs/bin/isql -z -user sysdba -password masterke localhost:/opt/ibdata/employee.fdb
ISQL Version: LI-V2.5.2.26424 Firebird 2.5
Statement failed, SQLSTATE = 08006
Unable to complete network request to host "localhost".
-Failed to establish a connection.
Use CONNECT or CREATE DATABASE to specify a database
SQL>

I will try fpc 2.4 next.

@firebird-automations
Copy link
Collaborator Author

Commented by: @AlexPeshkoff

Frank, please try my binary. This time I've tested it on gentoo OS - and once again no problems. But when I try on this box with binary from 3651, server really exits.

If my binary will work for you - I suggest to treat it as pascal, not firebird, problem.

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

Attachment: libtest64.so.bz2 [ 12092 ]

@firebird-automations
Copy link
Collaborator Author

Commented by: Frank Schlottmann-Goedde (fsg)

Your binary works as expected, so this seems to be an issue with Freepascal 2.4.4 and this bug can be considered closed.

@firebird-automations
Copy link
Collaborator Author

Commented by: @AlexPeshkoff

This bug is not reproduced when using older versions of fpc.

@firebird-automations
Copy link
Collaborator Author

Modified by: @AlexPeshkoff

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

2 participants