glibc-2.3 segfaults solved!

Greg Schafer gschafer at zip.com.au
Sun Oct 6 06:49:31 PDT 2002


On Sun, Oct 06, 2002 at 05:00:28AM -0400, Billy O'Connor wrote:
> gschafer at zip.com.au (Greg Schafer) writes:
> 
> > Hi
> > 
> > Well, sort of :)
> > 
> > It took some effort, but I narrowed down the problem. See here for
> > details:-
> > 
> > http://sources.redhat.com/ml/libc-alpha/2002-10/msg00129.html
> > 
> > Will try some newer binutils and/or gcc and see what comes up. If that
> > comes up blank, then I'm outta my depth and the heavyweights will have
> > to step in..
> > 
> 
> Nice catch.
> 
> A bunch of case conversion macros?  Amazing.  You've seen ls -l do the
> right thing without this patch, and blow up with it?  I'm finishing a
> debug glibc-2.2.5/LFS-4.0 build right now, I'm going to try to trace
> some segfaults with gdb.

Go hard son!

I've attached a patch that amounts to a reversal of the offending commit.
If you have an already built glibc-2.3 in the glibc-build dir, you can
apply this patch to your glibc-2.3, issue "make", and it will rebuild
only what is required (2 or 3 mins) then do a "make install" and you
will be able to see the difference immediately.

I hope the glibc guys can figure it out coz I'm going nowhere fast!

Greg
-------------- next part --------------
diff -uNr glibc-2.3.orig/ctype/ctype-info.c glibc-2.3/ctype/ctype-info.c
--- glibc-2.3.orig/ctype/ctype-info.c	2002-09-06 07:45:14.000000000 +1000
+++ glibc-2.3/ctype/ctype-info.c	2002-10-06 23:29:54.000000000 +1000
@@ -48,18 +48,18 @@
 
 #define b(t,x,o) (((const t *) _nl_C_LC_CTYPE_##x) + o)
 
-const unsigned short int *__ctype_b = b (unsigned short int, class, 128);
-const __uint32_t *__ctype32_b = b (__uint32_t, class32, 0);
-const __int32_t *__ctype_tolower = b (__int32_t, tolower, 128);
-const __int32_t *__ctype_toupper = b (__int32_t, toupper, 128);
-const __uint32_t *__ctype32_tolower = b (__uint32_t, tolower, 128);
-const __uint32_t *__ctype32_toupper = b (__uint32_t, toupper, 128);
+const unsigned short int *__ctype_old_b = b (unsigned short int, class, 128);
+const __uint32_t *__ctype32_old_b = b (__uint32_t, class32, 0);
+const __int32_t *__ctype_old_tolower = b (__int32_t, tolower, 128);
+const __int32_t *__ctype_old_toupper = b (__int32_t, toupper, 128);
+const __uint32_t *__ctype32_old_tolower = b (__uint32_t, tolower, 128);
+const __uint32_t *__ctype32_old_toupper = b (__uint32_t, toupper, 128);
 
-compat_symbol (libc, __ctype_b, __ctype_b, GLIBC_2_0);
-compat_symbol (libc, __ctype_tolower, __ctype_tolower, GLIBC_2_0);
-compat_symbol (libc, __ctype_toupper, __ctype_toupper, GLIBC_2_0);
-compat_symbol (libc, __ctype32_b, __ctype32_b, GLIBC_2_0);
-compat_symbol (libc, __ctype32_tolower, __ctype32_tolower, GLIBC_2_2);
-compat_symbol (libc, __ctype32_toupper, __ctype32_toupper, GLIBC_2_2);
+compat_symbol (libc, __ctype_old_b, __ctype_b, GLIBC_2_0);
+compat_symbol (libc, __ctype_old_tolower, __ctype_tolower, GLIBC_2_0);
+compat_symbol (libc, __ctype_old_toupper, __ctype_toupper, GLIBC_2_0);
+compat_symbol (libc, __ctype32_old_b, __ctype32_b, GLIBC_2_0);
+compat_symbol (libc, __ctype32_old_tolower, __ctype32_tolower, GLIBC_2_2);
+compat_symbol (libc, __ctype32_old_toupper, __ctype32_toupper, GLIBC_2_2);
 
 #endif
diff -uNr glibc-2.3.orig/locale/lc-ctype.c glibc-2.3/locale/lc-ctype.c
--- glibc-2.3.orig/locale/lc-ctype.c	2002-09-19 04:49:19.000000000 +1000
+++ glibc-2.3/locale/lc-ctype.c	2002-10-06 23:29:50.000000000 +1000
@@ -27,8 +27,6 @@
 /* We are called after loading LC_CTYPE data to load it into
    the variables used by the ctype.h macros.  */
 
-
-
 void
 _nl_postload_ctype (void)
 {
@@ -56,37 +54,19 @@
 
 #include <shlib-compat.h>
 #if SHLIB_COMPAT (libc, GLIBC_2_0, GLIBC_2_3)
-  /* We must use the exported names to access these so we are sure to
-     be accessing the main executable's copy if it has COPY relocs.  */
-
-  extern __const unsigned short int *__ctype_b; /* Characteristics.  */
-  extern __const __int32_t *__ctype_tolower; /* Case conversions.  */
-  extern __const __int32_t *__ctype_toupper; /* Case conversions.  */
-
-  extern const uint32_t *__ctype32_b;
-  extern const uint32_t *__ctype32_toupper;
-  extern const uint32_t *__ctype32_tolower;
-
-  /* We need the .symver declarations these macros generate so that
-     our references are explicitly bound to the versioned symbol names
-     rather than the unadorned names that are not exported.  When the
-     linker sees these bound to local symbols (as the unexported names are)
-     then it doesn't generate a proper relocation to the global symbols.
-     We need those relocations so that a versioned definition with a COPY
-     reloc in an executable will override the libc.so definition.  */
-
-compat_symbol (libc, __ctype_b, __ctype_b, GLIBC_2_0);
-compat_symbol (libc, __ctype_tolower, __ctype_tolower, GLIBC_2_0);
-compat_symbol (libc, __ctype_toupper, __ctype_toupper, GLIBC_2_0);
-compat_symbol (libc, __ctype32_b, __ctype32_b, GLIBC_2_0);
-compat_symbol (libc, __ctype32_tolower, __ctype32_tolower, GLIBC_2_2);
-compat_symbol (libc, __ctype32_toupper, __ctype32_toupper, GLIBC_2_2);
-
-  __ctype_b = current (uint16_t, CLASS, 128);
-  __ctype_toupper = current (uint32_t, TOUPPER, 128);
-  __ctype_tolower = current (uint32_t, TOLOWER, 128);
-  __ctype32_b = current (uint32_t, CLASS32, 0);
-  __ctype32_toupper = current (uint32_t, TOUPPER32, 0);
-  __ctype32_tolower = current (uint32_t, TOLOWER32, 0);
+  extern __const unsigned short int *__ctype_old_b; /* Characteristics.  */
+  extern __const __int32_t *__ctype_old_tolower; /* Case conversions.  */
+  extern __const __int32_t *__ctype_old_toupper; /* Case conversions.  */
+
+  extern const uint32_t *__ctype32_old_b;
+  extern const uint32_t *__ctype32_old_toupper;
+  extern const uint32_t *__ctype32_old_tolower;
+
+  __ctype_old_b = current (uint16_t, CLASS, 128);
+  __ctype_old_toupper = current (uint32_t, TOUPPER, 128);
+  __ctype_old_tolower = current (uint32_t, TOLOWER, 128);
+  __ctype32_old_b = current (uint32_t, CLASS32, 0);
+  __ctype32_old_toupper = current (uint32_t, TOUPPER32, 0);
+  __ctype32_old_tolower = current (uint32_t, TOLOWER32, 0);
 #endif
 }


More information about the lfs-dev mailing list