This is the mail archive of the libc-alpha@sources.redhat.com mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

dl_osversion not initialized


While compiling glibc CVS as of 2005-03-22 on Linux/x86 (SuSE 9.0 but
gcc-3.4, no TLS), this time with --without-__thread, I got this error:

# ../glibc-20050322/configure --enable-all-warnings --prefix=/usr --with-headers=/usr/include --enable-add-ons=linuxthreads --without-__thread
# make
# make check
...
gcc -nostdlib -nostartfiles -o /packages/glibc-20050322-build/elf/tst-tls1  -Wl,-dynamic-linker=/lib/ld-linux.so.2   -Wl,-z,combreloc  /packages/glibc-20050322-build/csu/crt1.o /packages/glibc-20050322-build/csu/crti.o `gcc --print-file-name=crtbegin.o` /packages/glibc-20050322-build/elf/tst-tls1.o  -Wl,-rpath-link=/packages/glibc-20050322-build:/packages/glibc-20050322-build/math:/packages/glibc-20050322-build/elf:/packages/glibc-20050322-build/dlfcn:/packages/glibc-20050322-build/nss:/packages/glibc-20050322-build/nis:/packages/glibc-20050322-build/rt:/packages/glibc-20050322-build/resolv:/packages/glibc-20050322-build/crypt:/packages/glibc-20050322-build/linuxthreads /packages/glibc-20050322-build/libc.so.6 /packages/glibc-20050322-build/libc_nonshared.a -lgcc -lgcc_eh  `gcc --print-file-name=crtend.o` /packages/glibc-20050322-build/csu/crtn.o
GCONV_PATH=/packages/glibc-20050322-build/iconvdata LC_ALL=C   /packages/glibc-20050322-build/elf/ld-linux.so.2 --library-path /packages/glibc-20050322-build:/packages/glibc-20050322-build/math:/packages/glibc-20050322-build/elf:/packages/glibc-20050322-build/dlfcn:/packages/glibc-20050322-build/nss:/packages/glibc-20050322-build/nis:/packages/glibc-20050322-build/rt:/packages/glibc-20050322-build/resolv:/packages/glibc-20050322-build/crypt:/packages/glibc-20050322-build/linuxthreads /packages/glibc-20050322-build/elf/tst-tls1  > /packages/glibc-20050322-build/elf/tst-tls1.out
cannot set up thread-local storage: kernel too old for thread-local storage support

make[2]: *** [/packages/glibc-20050322-build/elf/tst-tls1.out] Fehler 127
make[2]: Leaving directory `/packages/glibc-20050322/elf'
make[1]: *** [elf/tests] Fehler 2
make[1]: Leaving directory `/packages/glibc-20050322'
make: *** [check] Fehler 2

I'm running Linux kernel 2.4.21, which was supported by glibc a year ago.
__LINUX_KERNEL_VERSION is not defined in config.h, therefore it gets defined
to 0 in sysdeps/unix/sysv/linux/kernel-features.h.

Stack trace:
#0  0x80014f88 in _exit ()
#1  0x80000e82 in init_tls () at rtld.c:748
#2  0x8000328f in dl_main (phdr=0x8048034, phnum=8, user_entry=0xbfffe7d0) at rtld.c:1769
#3  0x8001233e in _dl_sysdep_start (start_argptr=0x55, dl_main=0x80001d20 <dl_main>) at dl-sysdep.c:237
#4  0x80001b00 in _dl_start (arg=0xbfffea30) at rtld.c:304
#5  0x80000a77 in _start () at rtld.c:585

The test that goes wrong is elf/rtld.c:746:
    const char *lossage = TLS_INIT_TP (tcbp, USE___THREAD);

The problem is that in linuxthreads/sysdeps/i386/tls.h:230
    GLRO(dl_osversion) < 131939
evaluates to 1 because dl_osversion still has the value 0.

There are two places where dl_osversion is initialized:
- in sysdeps/unix/sysv/linux/dl-osinfo.h:DL_SYSDEP_OSCHECK
  but this code is not executed when __LINUX_KERNEL_VERSION is 0.
- in sysdeps/unix/sysv/linux/dl-librecon.h:_dl_osversion_init
  when the environment variables LD_ASSUME_KERNEL is present.

This patch fixes it for me: Assign the dl_osversion variable also when
__LINUX_KERNEL_VERSION is 0. (You can reindent the DL_SYSDEP_OSCHECK
macro afterwards. I didn't do this for clarity.)

Another possible fix would be to replace the
   GLRO(dl_osversion) < 131939
test with an unconditional call of the modify_ldt system call, and see
whether it return with %eax = -ENOSYS. (But this assumes that modify_ldt
worked correctly in all kernels < 2.3.63 in which it is present. I don't
know whether this is true.)


2005-03-27  Bruno Haible  <bruno@clisp.org>

	* sysdeps/unix/sysv/linux/dl-osinfo.h (DL_SYSDEP_OSCHECK): Initialize
	dl_osversion also when __LINUX_KERNEL_VERSION is 0.
	Needed for linuxthreads on i386.

*** glibc-20050322/sysdeps/unix/sysv/linux/dl-osinfo.h.bak	Mon Feb 14 22:48:06 2005
--- glibc-20050322/sysdeps/unix/sysv/linux/dl-osinfo.h	Sun Mar 27 20:45:26 2005
***************
*** 45,51 ****
      /* Test whether the kernel is new enough.  This test is only	      \
         performed if the library is not compiled to run on all		      \
         kernels.  */							      \
-     if (__LINUX_KERNEL_VERSION > 0)					      \
        {									      \
  	char bufmem[64];						      \
  	char *buf = bufmem;						      \
--- 45,50 ----
***************
*** 100,108 ****
  	  version <<= 8 * (3 - parts);					      \
  									      \
  	/* Now we can test with the required version.  */		      \
! 	if (version < __LINUX_KERNEL_VERSION)				      \
! 	  /* Not sufficent.  */						      \
! 	  FATAL ("FATAL: kernel too old\n");				      \
  									      \
  	GLRO(dl_osversion) = version;					      \
        }									      \
--- 99,108 ----
  	  version <<= 8 * (3 - parts);					      \
  									      \
  	/* Now we can test with the required version.  */		      \
! 	if (__LINUX_KERNEL_VERSION > 0)					      \
! 	  if (version < __LINUX_KERNEL_VERSION)				      \
! 	    /* Not sufficent.  */					      \
! 	    FATAL ("FATAL: kernel too old\n");				      \
  									      \
  	GLRO(dl_osversion) = version;					      \
        }									      \


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]