Bug#591544: libc6: dlopen() does not return when static compilation is used
Package: libc6
Version: 2.11.2-2
Severity: important
The jpilot package ./configure script generate a test program that does
not finish.
A short version of the problematic source code is:
#include <dlfcn.h>
int main ()
{
void *self = dlopen (0, RTLD_GLOBAL | RTLD_LAZY);
return 0;
}
And is compiled using:
$ gcc -o conftest -g -Wall -DHAVE_DLFCN_H -Wl,--export-dynamic -static conftest.c -ldl
conftest.c: In function ‘main’:
conftest.c:5: warning: unused variable ‘self’
/usr/bin/ld: /tmp/ccToBZZa.o: in function main:conftest.c:5: warning: Using `dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
The warning may be an indication that something strange is happening.
Then the execution:
$ ./conftest
But never returns and the ./configure never finishes.
[...]
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking for shl_load... no
checking for shl_load in -ldld... no
checking for dlopen... no
checking for dlopen in -ldl... yes
checking whether a program can dlopen itself... yes
checking whether a statically linked program can dlopen itself...
And the execution is now blocked forever.
I have the problem when using testing/squeeze.
I can't reproduce it by running ./configure on unstable/sid.
In fact I can't recompile the sample code on sid using the same command.
In sid I have:
$ gcc -o conftest -g -Wall -DHAVE_DLFCN_H -Wl,--export-dynamic -static conftest.c -ldl
conftest.c: In function ‘main’:
conftest.c:5: warning: unused variable ‘self’
/tmp/ccQplQtT.o: In function `main':
/home/rousseau/conftest.c:5: warning: Using 'dlopen' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: dynamic STT_GNU_IFUNC symbol `strcmp' with pointer equality in `/usr/lib/gcc/x86_64-linux-gnu/4.4.5/../../../../lib/libc.a(strcmp.o)' can not be used when making an executable; recompile with -fPIE and relink with -pie
collect2: ld returned 1 exit status
I can do additionnal tests if needed.
Bye
-- System Information:
Debian Release: squeeze/sid
APT prefers testing
APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable')
Architecture: amd64 (x86_64)
Kernel: Linux 2.6.32-5-amd64 (SMP w/4 CPU cores)
Locale: LANG=fr_FR.UTF-8, LC_CTYPE=fr_FR.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash
Versions of packages libc6 depends on:
ii libc-bin 2.11.2-2 Embedded GNU C Library: Binaries
ii libgcc1 1:4.4.4-7 GCC support library
libc6 recommends no packages.
Versions of packages libc6 suggests:
ii debconf [debconf-2.0] 1.5.33 Debian configuration management sy
pn glibc-doc <none> (no description available)
ii locales 2.11.2-2 Embedded GNU C Library: National L
-- debconf information:
* glibc/upgrade: true
glibc/disable-screensaver:
glibc/restart-failed:
* glibc/restart-services: gdm ssh exim4 cups cron atd
Reply to: