This is the mail archive of the libc-hacker@sourceware.cygnus.com mailing list for the glibc project.

Note that libc-hacker is a closed list. You may look at the archives of this list, but subscription and posting are not open.


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

Re: linuxthreads broken in glibc 2.2?


>>>>> Mark Kettenis writes:

Mark>    From: Andreas Jaeger <aj@suse.de>
Mark>    Date: 01 Jul 2000 11:47:33 +0200

>>>>>> Andreas Jaeger writes:
[...]
Mark>    The other test programs segfault at the same place.  Any ideas what's
Mark>    broken?

Mark> Yep.  __pthread_initialize_minimal() hasn't been called yet.  It is
Mark> called from the libc constructor functions, but if you look at
Mark> sysdeps/generic/libc-start.c, you'll see that __libc_init_secure() is
Mark> called before __libc_init_first() which calls the constructors.

Mark> I suppose that there is no problem when using the old method of
Mark> getting at the per-thread errno (which is still used on everything <
Mark> i686), but it fails for the stuff that uses the LDT, since the LDT
Mark> hasn't been set up yet.

Mark> I'm entirely not sure how to fix this.  Calling
Mark> __pthread_initialize_minimal from __libc_start_main() #ifndef SHARED
Mark> is probably the easiest solution.

Here's a patch to follow your suggestion - it fixed the problem for
me and I can run threads with static libraries again.

Uli, ok to commit this?

Andreas

2000-07-06  Andreas Jaeger  <aj@suse.de>

	* sysdeps/generic/libc-start.c (__libc_start_main): Initialize
	thread library for static program.s


============================================================
Index: sysdeps/generic/libc-start.c
--- sysdeps/generic/libc-start.c	2000/06/30 01:11:14	1.19
+++ sysdeps/generic/libc-start.c	2000/07/06 09:27:11
@@ -29,6 +29,10 @@
 extern int __libc_multiple_libcs;
 extern void *__libc_stack_end;
 
+#ifndef SHARED
+extern void __pthread_initialize_minimal (void) __attribute__ ((weak));
+#endif
+
 /* Prototype for local function.  */
 extern void __libc_check_standard_fds (void);
 
@@ -62,6 +66,12 @@
   __libc_stack_end = stack_end;
 
 #ifndef SHARED
+  /* Initialize the thread library at least a bit since the libgcc
+     functions are using thread functions if these are available and
+     we need to setup errno.  */
+  if (__pthread_initialize_minimal)
+    __pthread_initialize_minimal ();
+
   /* Some security at this point.  Prevent starting a SUID binary where
      the standard file descriptors are not opened.  We have to do this
      only for statically linked applications since otherwise the dynamic

-- 
 Andreas Jaeger
  SuSE Labs aj@suse.de
   private aj@arthur.inka.de

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