firebird2.1-classic compiled without stack protector, so UDF dlopen failed

Bug #363694 reported by Коренберг Марк
2
Affects Status Importance Assigned to Milestone
firebird2.1 (Ubuntu)
Fix Released
Undecided
Popa Adrian Marius

Bug Description

Binary package hint: firebird2.1-classic

firebird-2.1 classic is compiled with -fno-stack-protector,
so any third-party UDF compiled with default gcc options are not loaded by firebird at runtime.
and firebird said (Exmple for TANH function in common rfunc (http://rfunc.sourceforge.net/index.html) library):

-function TANH is not defined
-module name or entrypoint could not be found

When i compile same UDF source with -fno-stack-protector, UDF loads and work perfectly.

How i guess that:

I wrote simple .c file:
int main()
{
    return 0;
}

and run command:
root# gcc qwe.c rfunc.so
/usr/bin/ld: a.out: hidden symbol `__stack_chk_fail_local' in /usr/lib/libc_nonshared.a(stack_chk_fail_local.oS) is referenced by DSO
/usr/bin/ld: final link failed: Nonrepresentable section on output
collect2: ld returned 1 exit status

Because earlier i reported about very BUGGY stak protector i decide to off this feature in UDF makefile (add CFLAGS+=-fno-stack-protector). and YES! now UDF worked !

root@quadsrv:/usr/lib/firebird/2.1/UDF/tmp# lsb_release -rd
Description: Ubuntu 8.10
Release: 8.10

root@quadsrv:/usr/lib/firebird/2.1/UDF/tmp# LANG=C apt-cache policy firebird2.1-classic
firebird2.1-classic:
  Installed: 2.1.0.17798-0.ds2-1
  Candidate: 2.1.0.17798-0.ds2-1
  Version table:
 *** 2.1.0.17798-0.ds2-1 0
        500 http://ru.archive.ubuntu.com intrepid/universe Packages
        100 /var/lib/dpkg/status

description: updated
summary: - firebird 2.1 compiled without stack protector, so UDF open failed
+ firebird 2.1 compiled without stack protector, so UDF dlopen failed
description: updated
Revision history for this message
Popa Adrian Marius (mapopa) wrote : Re: firebird 2.1 compiled without stack protector, so UDF dlopen failed

follow this thread
http://www.nabble.com/firebird-2.1-compiled-without-stack-protector%2C-so-UDF-dlopen-failed-td23430831.html

seems for me that firebird is build with stack protection by default , at least this is on jaunty
i will check on intrepid too

Changed in firebird2.1 (Ubuntu):
assignee: nobody → Mariuz (mapopa)
status: New → In Progress
Revision history for this message
Popa Adrian Marius (mapopa) wrote :

Firebird is compiled with stack protection enabled by default (tested on both 8.10 and 9.04)

objdump -CR /usr/lib/firebird/2.1/bin/fbserver | grep chk
000000000097c7c0 R_X86_64_JUMP_SLOT __stack_chk_fail

Changed in firebird2.1 (Ubuntu):
status: In Progress → Fix Released
Revision history for this message
Коренберг Марк (socketpair) wrote : Re: [Bug 363694] Re: firebird 2.1 compiled without stack protector, so UDF dlopen failed

What is meaning of bug state 'fix released' ?
there is no bug, or bug will be closed on next build ?
please describe, or give me the link.

Revision history for this message
Popa Adrian Marius (mapopa) wrote : Re: firebird 2.1 compiled without stack protector, so UDF dlopen failed

it seems that firebird 2.1 super is already compiled with stack protector on ubuntu 8.10 and ubuntu 9.04
you can check with the above command

i check now the firebird 2.1-classic

Changed in firebird2.1 (Ubuntu):
status: Fix Released → In Progress
Revision history for this message
Popa Adrian Marius (mapopa) wrote :

seems that fb_inet_server is not compiled with stack protection

objdump -CR /usr/lib/firebird/2.1/bin/fb_inet_server

/usr/lib/firebird/2.1/bin/fb_inet_server: file format elf32-i386

DYNAMIC RELOCATION RECORDS
OFFSET TYPE VALUE
08049ff0 R_386_GLOB_DAT __gmon_start__
0804a000 R_386_JUMP_SLOT __gmon_start__
0804a004 R_386_JUMP_SLOT __libc_start_main
0804a008 R_386_JUMP_SLOT server_main
0804a00c R_386_JUMP_SLOT __gxx_personality_v0

Revision history for this message
Popa Adrian Marius (mapopa) wrote :

rfunc.so was compiled on another pc ? if so it's need an recompile

or how is done , could send an example for your udf

Changed in firebird2.1 (Ubuntu):
status: In Progress → Incomplete
Revision history for this message
Popa Adrian Marius (mapopa) wrote :
Changed in firebird2.1 (Ubuntu):
status: Incomplete → Fix Released
Revision history for this message
Popa Adrian Marius (mapopa) wrote :

Library name: /usr/lib/firebird/2.1/UDF/fbudf.so
Entry point: isLeapYear
ISLEAPYEAR(
    Timestamp by reference
)
returns:
    Integer by value

Revision history for this message
Popa Adrian Marius (mapopa) wrote :

and that was tested with firebird2.1-classic

sudo apt-get install firebird2.1-classic
dpkg-reconfigure firebird2.1-classic to enable it
and then from flamerobin i have declared the function and worked without issues as above

if you have an example please come to firebird-support

Revision history for this message
Коренберг Марк (socketpair) wrote : Re: [Bug 363694] Re: firebird 2.1 compiled without stack protector, so UDF dlopen failed

rfunc was compiled on the same PC.
I will post my rfunc.so later (2-3 days) when i get access to that server.

Revision history for this message
Коренберг Марк (socketpair) wrote : Re: firebird 2.1 compiled without stack protector, so UDF dlopen failed
Revision history for this message
Коренберг Марк (socketpair) wrote :
Revision history for this message
Коренберг Марк (socketpair) wrote :

Only one difference between compilations is -fno-stack-protector (with this option everything OK).

root@ubuntu:~/rfunc/rfunc/source# gcc --version
gcc (Ubuntu 4.3.3-5ubuntu4) 4.3.3
Copyright (C) 2008 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Revision history for this message
Коренберг Марк (socketpair) wrote :

The bug appear in:
root@ubuntu:~# dpkg -l | fgrep -i firebird2.1-classic
ii firebird2.1-classic 2.1.1.17910-release.ds1-1ubuntu1 Firebird Classic Server - an RDBMS based on

Changed in firebird2.1 (Ubuntu):
status: Fix Released → New
Revision history for this message
Коренберг Марк (socketpair) wrote :

I think stack-protector specific functions become 'required' in dynamic linker only when certain constructions used in UDF.
If UDF is simple function like 'return sin(x)', this UDF loads perfectly either with stack protector or without.

summary: - firebird 2.1 compiled without stack protector, so UDF dlopen failed
+ firebird2.1-classic compiled without stack protector, so UDF dlopen
+ failed
Revision history for this message
Damyan Ivanov (dmn-debian) wrote :

I can't find -fno-stack-protector in the 2.1.0.17798-0.ds2-1 sources/patches, so it must have something to do with the build environment.

Looked at the build logs too (https://launchpad.net/ubuntu/intrepid/+source/firebird2.1/2.1.0.17798-0.ds2-1), no sign of -fno-stack-protector.

Changed in firebird2.1 (Ubuntu):
status: New → Incomplete
Changed in firebird2.1 (Ubuntu):
status: Incomplete → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.