Re: -CURRENT is broken?

From: Konstantin Belousov <kostikbel_at_gmail.com>
Date: Mon, 5 Mar 2012 22:07:49 +0200
On Mon, Mar 05, 2012 at 08:53:10PM +0100, Lars Engels wrote:
> On Mon, Mar 05, 2012 at 09:51:19PM +0200, Konstantin Belousov wrote:
> > On Mon, Mar 05, 2012 at 08:43:15PM +0100, Lars Engels wrote:
> > > On Mon, Mar 05, 2012 at 09:27:49PM +0200, Konstantin Belousov wrote:
> > > > On Mon, Mar 05, 2012 at 08:16:22PM +0100, Lars Engels wrote:
> > > > > On Mon, Mar 05, 2012 at 09:12:11PM +0200, Konstantin Belousov wrote:
> > > > > > On Mon, Mar 05, 2012 at 10:41:01AM -0800, Jos Backus wrote:
> > > > > > > On Mon, Mar 5, 2012 at 10:10 AM, Lars Engels <lars.engels_at_0x20.net> wrote:
> > > > > > > > On Mon, Mar 05, 2012 at 07:41:32PM +0400, Alex Keda wrote:
> > > > > > > >> On 05.03.2012 19:39, Alex Keda wrote:
> > > > > > > >> > I have 2 machine, i386 and amd64
> > > > > > > >> > world rebuild tonight all work. all applications crash with core dump...
> > > > > > > >> read as "world rebuild tonight not work" =))
> > > > > > > 
> > > > > > > I noticed the same thing. My `make world' dies right after installing
> > > > > > > the new runtime linker. I was able to recover by copying
> > > > > > > ld-elf.so.1.old using /rescue/{chflags,cp}. Oddly enough, when I
> > > > > > > manually build and install the runtime linker, it works. Maybe that's
> > > > > > > a clue as to what's wrong.
> > > > > > 
> > > > > > I just did full buildworld on pristine sources at r232541 and amd64 machine
> > > > > > booted fine.
> > > > > > 
> > > > > > Can somebody put the faulting ld-elf.so.1 somewhere so I can download it ?
> > > > > 
> > > > > http://bsd-geek.de/FreeBSD/ld-elf.so.1
> > > > 
> > > > It works for me :(.
> > > > 
> > > > Since your rtld is not stripped, try to link any binary using this interpreter,
> > > > i.e. supply -Wl,-I,<path to your bad ld-elf.so.1> to cc link command.
> > > > Then run the program, get core dump, load it into gdb and do "bt all".
> > > 
> > > "bt all" gives "No symbol table is loaded.  Use the "file" command."
> > > 
> > > But just "bt" gives:
> > > 
> > > http://bsdpaste.bsdgroup.de/130927
> > Hm, so do you have libmap.conf ?
> > 
> > Yeah, it faults immediately.
> > I suspect I know what is going on.
> > 
> Yes, I have this in libmap.conf:
> libpcre.so.0 libpcre.so.1
> 

The following change fixes ld-elf.so.1 with the present libmap.conf for me.

diff --git a/libexec/rtld-elf/libmap.c b/libexec/rtld-elf/libmap.c
index 773456b..cc4fd2b 100644
--- a/libexec/rtld-elf/libmap.c
+++ b/libexec/rtld-elf/libmap.c
_at__at_ -3,7 +3,6 _at__at_
  */
 
 #include <stdio.h>
-#include <ctype.h>
 #include <string.h>
 #include <stdlib.h>
 #include <sys/queue.h>
_at__at_ -53,6 +52,12 _at__at_ static int	closestrfn	(void * cookie);
 #define	iseol(c)	(((c) == '#') || ((c) == '\0') || \
 			 ((c) == '\n') || ((c) == '\r'))
 
+/*
+ * Do not use ctype.h macros, which rely on the working tls.  It is
+ * too early to have thread-local variables operatable.
+ */
+#define	isspace1(c)	((c) == ' ' || (c) == '\t')
+
 int
 lm_init (char *libmap_override)
 {
_at__at_ -107,7 +112,7 _at__at_ lmc_parse (FILE *fp)
 		t = f = c = NULL;
 
 		/* Skip over leading space */
-		while (isspace(*cp)) cp++;
+		while (isspace1(*cp)) cp++;
 
 		/* Found a comment or EOL */
 		if (iseol(*cp)) continue;
_at__at_ -117,7 +122,7 _at__at_ lmc_parse (FILE *fp)
 			cp++;
 
 			/* Skip leading space */
-			while (isspace(*cp)) cp++;
+			while (isspace1(*cp)) cp++;
 
 			/* Found comment, EOL or end of selector */
 			if  (iseol(*cp) || *cp == ']')
_at__at_ -125,11 +130,11 _at__at_ lmc_parse (FILE *fp)
 
 			c = cp++;
 			/* Skip to end of word */
-			while (!isspace(*cp) && !iseol(*cp) && *cp != ']')
+			while (!isspace1(*cp) && !iseol(*cp) && *cp != ']')
 				cp++;
 
 			/* Skip and zero out trailing space */
-			while (isspace(*cp)) *cp++ = '\0';
+			while (isspace1(*cp)) *cp++ = '\0';
 
 			/* Check if there is a closing brace */
 			if (*cp != ']') continue;
_at__at_ -141,7 +146,7 _at__at_ lmc_parse (FILE *fp)
 			 * There should be nothing except whitespace or comment
 			  from this point to the end of the line.
 			 */
-			while(isspace(*cp)) cp++;
+			while(isspace1(*cp)) cp++;
 			if (!iseol(*cp)) continue;
 
 			strcpy(prog, c);
_at__at_ -151,20 +156,20 _at__at_ lmc_parse (FILE *fp)
 
 		/* Parse the 'from' candidate. */
 		f = cp++;
-		while (!isspace(*cp) && !iseol(*cp)) cp++;
+		while (!isspace1(*cp) && !iseol(*cp)) cp++;
 
 		/* Skip and zero out the trailing whitespace */
-		while (isspace(*cp)) *cp++ = '\0';
+		while (isspace1(*cp)) *cp++ = '\0';
 
 		/* Found a comment or EOL */
 		if (iseol(*cp)) continue;
 
 		/* Parse 'to' mapping */
 		t = cp++;
-		while (!isspace(*cp) && !iseol(*cp)) cp++;
+		while (!isspace1(*cp) && !iseol(*cp)) cp++;
 
 		/* Skip and zero out the trailing whitespace */
-		while (isspace(*cp)) *cp++ = '\0';
+		while (isspace1(*cp)) *cp++ = '\0';
 
 		/* Should be no extra tokens at this point */
 		if (!iseol(*cp)) continue;

Received on Mon Mar 05 2012 - 19:07:59 UTC

This archive was generated by hypermail 2.4.0 : Wed May 19 2021 - 11:40:24 UTC