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]

[PATCH] resolver fix


Hi!

This patch fixes resolver segfaults when linked with -lpthread.
The issue is that the new resolver defines
#define _res (*__res_state())
so when pthread.c sets the initial resp pointer to &_res, it sets it to
NULL.
Also, __pthread_initialize_minimal was called from within HAVE_DWARF2_*
defines which is very wrong - if the system does not have DWARF2 eh, then it
looses because pthread_initialize_minimal will be never called.
And last, one minor optimization, like errno_location, __res_state is a good
candidate for __attribute__((const)) IMHO, because it will not change during
lifetime of any thread.

2000-05-13  Jakub Jelinek  <jakub@redhat.com>

	* elf/soinit.c (__libc_global_ctors): Move
	__pthread_initialize_minimal call out of HAVE_DWARF2_* defines.
	* resolv/resolv.h (__res_state): Added __attribute__((const)).
	(_res): If __RES_PTHREAD_INTERNAL is defined, declare it as
	variable, don't define it to __res_state call.

	* internals.h (__RES_PTHREAD_INTERNAL): Define.

--- libc/elf/soinit.c.jj	Sat May 13 21:43:33 2000
+++ libc/elf/soinit.c	Sat May 13 21:45:22 2000
@@ -49,13 +49,14 @@ __libc_global_ctors (void)
 {
   /* Call constructor functions.  */
   run_hooks (__CTOR_LIST__);
-#ifdef HAVE_DWARF2_UNWIND_INFO
-# ifdef HAVE_DWARF2_UNWIND_INFO_STATIC
+
   /* Initialize the thread library at least a bit since the libgcc functions
      are using thread functions if these are available.  */
   if (__pthread_initialize_minimal)
     __pthread_initialize_minimal ();
 
+#ifdef HAVE_DWARF2_UNWIND_INFO
+# ifdef HAVE_DWARF2_UNWIND_INFO_STATIC
   {
     static struct object ob;
     __register_frame_info (__EH_FRAME_BEGIN__, &ob);
--- libc/linuxthreads/internals.h.jj	Mon May  8 14:30:44 2000
+++ libc/linuxthreads/internals.h	Sat May 13 22:01:09 2000
@@ -26,6 +26,7 @@
 #include <sys/types.h>
 #include <bits/libc-tsd.h> /* for _LIBC_TSD_KEY_N */
 
+#define __RES_PTHREAD_INTERNAL
 #include <resolv.h> /* for per-thread resolver context */
 
 
--- libc/resolv/resolv.h.jj	Mon May  8 14:30:46 2000
+++ libc/resolv/resolv.h	Sat May 13 22:13:17 2000
@@ -254,8 +254,12 @@ typedef struct __res_state *res_state;
 
 /* Things involving an internal (static) resolver context. */
 #if defined _REENTRANT || defined _LIBC_REENTRANT
-extern struct __res_state *__res_state(void);
+extern struct __res_state *__res_state(void) __attribute__ ((__const__));
+#if defined __RES_PTHREAD_INTERNAL
+extern struct __res_state _res;
+#else
 #define _res (*__res_state())
+#endif
 #else
 extern struct __res_state _res;
 #endif

	Jakub

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