Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 4 Jul 1999 04:10:03 -0700 (PDT)
From:      Juergen Lock <nox@jelal.kn-bremen.de>
To:        freebsd-bugs@FreeBSD.org
Subject:   Re: bin/10064: /bin/sh called from make dumps core
Message-ID:  <199907041110.EAA69488@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help
The following reply was made to PR bin/10064; it has been noted by GNATS.

From: Juergen Lock <nox@jelal.kn-bremen.de>
To: Sheldon Hearn <sheldonh@uunet.co.za>
Cc: Juergen Lock <nox@jelal.kn-bremen.de>,
	freebsd-gnats-submit@freebsd.org
Subject: Re: bin/10064: /bin/sh called from make dumps core
Date: Sun, 4 Jul 1999 12:44:15 +0200

 On Wed, Jun 23, 1999 at 04:52:10PM +0200, Sheldon Hearn wrote:
 > 
 > 
 > On Tue, 22 Jun 1999 23:12:11 +0200, Juergen Lock wrote:
 > 
 > > Umm, i fixed this the redmond way, just looked at how it crashed
 > > and patched around the problem without actually trying to understand
 > > the code...
 > 
 > Hi Juergen,
 > 
 > Could you do me a huge favour? I've just gotten feedback from someone
 > who suspects that your problem was fixed in rev 1.26 of
 > src/bin/sh/expand.c ...
 > 
 > Could you back your change out of your local source, get the expand.c
 > fix and see if the problem still exists?
 
 OK after several nightly runs of my i586-cygwin32 crossgcc build
 i finally go it to the point where it crashed.  (I had to use a
 2.1-stable system, with the right kernel, to get it to pass the right
 args to sh that make it die...)  then i built the 3.2-stable sh on
 2.1-stable cause the expand.c diff didn't apply to the 2.1-stable sh.
 well, the 3.2-stable sh didn't die (and the expand.c diff isn't yet
 MFC'd)!  at least not at the same place where the 2.1-stable one died,
 didn't wait for the whole build to finish...  A 2.2.5R sh also died
 I remembered, maybe the expand.c diff applies there.  Well it did
 (more or less, had to apply it by hand), but it didn't fix the crash!
 Hmm so let's find out which patch makes it dissapear.  After building
 several sh:s from the RELENG_2_2 branch i found out the 2.2.7R sh
 dies and the 2.2.8R sh doesn't, and the crucial patch is in parser.c
 (0parser228 below).  undoing that patch in the 3.2-stable sh as well
 as in the -current sh cause both to crash, and that patch doesn't
 look like it could fix a stack bug, only mask it by using the stack
 differently, right?  Anyway here comes the whole shebang, reduced to
 only the touched files:  (unshar in an empty dir, set CVSROOT then
 run `crash'.)
 
  HTH,
 	Juergen
 
 # This is a shell archive.  Save it in a file, remove anything before
 # this line, and then unpack it by entering "sh file".  Note, it may
 # create directories; files and directories will be owned by you and
 # have default permissions.
 #
 # This archive contains:
 #
 #	crash
 #	kill11.c
 #	0parser228
 #	work
 #	work/gnu-win32
 #	work/gnu-win32/src
 #	work/gnu-win32/src/CROSS
 #	work/gnu-win32/src/CROSS/i586-cygwin32
 #	work/gnu-win32/src/CROSS/i586-cygwin32/libstdc++
 #	work/gnu-win32/src/CROSS/i586-cygwin32/newlib
 #	work/gnu-win32/src/CROSS/i586-cygwin32/newlib/Makefile
 #	work/gnu-win32/src/CROSS/binutils
 #	work/gnu-win32/src/CROSS/binutils/ar
 #	work/gnu-win32/src/CROSS/gas
 #	work/gnu-win32/src/CROSS/gas/as-new
 #	work/gnu-win32/src/CROSS/gcc
 #	work/gnu-win32/src/CROSS/gcc/xgcc
 #	work/gnu-win32/src/libstdc++
 #
 echo x - crash
 sed 's/^X//' >crash << 'END-of-crash'
 X#! /bin/sh
 Xcc -o kill11 kill11.c
 X# set CVSROOT; also try co -rRELENG_3
 Xcvs co src/bin/sh src/usr.bin/printf
 Xpatch src/bin/sh/parser.c <0parser228 
 X(cd src/bin/sh/; make)
 Xecho hit return, or attach gdb then hit return
 X(cd work/gnu-win32/src/CROSS/; ../../../../kill11 ../../../../src/bin/sh/sh )
 X# examine the core in work/gnu-win32/src/CROSS
 END-of-crash
 echo x - kill11.c
 sed 's/^X//' >kill11.c << 'END-of-kill11.c'
 X#include <stdio.h>
 X
 Xint main(int argc, char **argv) {
 X	char *sh = argc == 2 ? argv[1] : "/bin/sh";
 X	return execl (sh, sh, "-c", "read x; dir=`echo configure-target-libstdc++ | sed -e 's/configure-target-//'`;  if [ ! -d i586-cygwin32 ]; then  true;  elif [ -f i586-cygwin32/${dir}/Makefile ] ; then  true;  elif echo \" libiberty newlib libio librx libstdc++ libg++ examples winsup    \" | grep \" ${dir} \" >/dev/null 2>&1; then  if [ -d ../${dir} ]; then  [ -d i586-cygwin32/${dir} ] || mkdir i586-cygwin32/${dir}; r=`pwd`; export r;  s=`cd ..; pwd`; export s;   AR=\"` if [ -f $r/binutils/ar ] ; then echo  $r/binutils/ar ; else if [ \"i386-unknown-freebsd2.1.7\" = \"i586-pc-cygwin32\" ] ; then echo ar; else t='-e s,^,i586-cygwin32-, '; echo ar | sed -e 's/x/x/' $t ; fi; fi`\"; export AR;  AS=\"` if [ -f $r/gas/as-new ] ; then echo $r/gas/as-new ; else if [ \"i386-unknown-freebsd2.1.7\" = \"i586-pc-cygwin32\" ] ; then echo as; else t='-e s,^,i586-cygwin32-, '; echo as | sed -e 's/x/x/' $t ; fi; fi`\"; export AS;  CC=\"` if [ -f $r/gcc/xgcc ] ; then if [ -f $r/i586-cygwin32/newli!
 b/Makefile ] ; then case \"i586-pc-cygwin32\" in i[3456]86-*-cygwin*) echo $r/gcc/xgcc -B$r/gcc/ -B$r/i586-cygwin32/newlib/ -L$r/i586-cygwin32/winsup -idirafter $r/i586-cygwin32/newlib/targ-include -idirafter $s/winsup/include -idirafter $s/newlib/libc/include -idirafter $s/newlib/libc/sys/cygwin -idirafter  $s/newlib/libc/sys/cygwin32 -nostdinc; ;; *) echo $r/gcc/xgcc -B$r/gcc/ -idirafter $r/i586-cygwin32/newlib/targ-include -idirafter $s/newlib/libc/include -nostdinc; ;; esac else echo $r/gcc/xgcc -B$r/g cc/; fi; else if [ \"i386-unknown-freebsd2.1.7\"= \"i586-pc-cygwin32\" ] ; then echo gcc; else t='-e s,^,i586-cygwin32-, '; echo gcc | sed -e 's/x/x/' $t; fi; fi`\"; export CC;  CFLAGS=\"-g -O2\"; export CFLAGS;  CXX=\"` if [ -f $r/gcc/xgcc ] ; then if [ -f $r/i586-cygwin32/newlib/Makefile ] ; then case \"i586-pc-cygwin32\" in i[3456]86-*-cygwin*) echo $r/gcc/xgcc  -B$r/gcc/ -B$r/i586-cygwin32/newlib/ -L$r/i586-cygwin32/winsup -idirafter  $r/i586-cygwin32/newlib/targ-include !
 -idirafter $s/winsup/include -idirafter $s/newlib/libc/include -idirafter $s/newlib/libc/sys/cygwin -idirafter  $s/newlib/libc/sys/cygwin32 -nostdinc; ;; *) echo $r/gcc/xgcc -B$r/gcc/ -idirafter $r/i586-cygwin32/newlib/targ-include -idirafter $s/newlib/libc/include -nostdinc; ;; esac else echo $r/gcc/xgcc -B$r/gcc/; fi; else if [ \"i386-unknown-freebsd2.1.7\" = \"i586-pc-cygwin32\" ] ; then echo c++; else t='-e s,^,i586-cygwin32-, '; echo c++ | sed -e 's/x/x/' $t; fi; fi`\"; export CXX;  CXXFLAGS=\"-g -O2\ "; export CXXFLAGS;  DLLTOOL=\"` if [ -f $r/binutils/dlltool ] ; then echo $r/binutils/dlltool ; else if [ \"i386-unknown-freebsd2.1.7\" = \"i586-pc-cygwin32\" ] ; then echo dlltool; else t='-e s,^,i586-cygwin32-, '; echo dlltool | sed -e 's/x/x/' $t ; fi; fi`\"; export DLLTOOL;  LD=\"` if [ -f $r/ld/ld-new ] ; then echo $r/ld/ld-new ; else if [ \"i386-unknown-freebsd2.1.7\" = \"i586-pc-cygwin32\" ] ; then echo ld; else t='-e s,^,i586-cygwin32-, '; echo ld | sed -e 's/x/x/' $!
 t ; fi; fi`\"; export LD;  LDFLAGS=\"\"; export LDFLAGS;  NM=\"` if [ -f $r/binutils/nm-new ] ; then echo $r/binutils/nm-new ; else if [ \"i386-unknown-freebsd2.1.7\" = \"i586-pc-cygwin32\" ] ; then echo nm; else t='-e s,^,i586-cygwin32-, '; echo nm | sed -e 's/x/x/' $t ; fi; fi`\"; export NM;  RANLIB=\"` if [ -f $r/binutils/ranlib ] ; then echo $r/binutils/ranlib ; else if [ \"i386-unknown-freebsd2.1.7\" = \"i586-pc-cygwin32\" ] ; then echo ranlib; else t='-e s,^,i586-cygwin32-, '; echo ranlib | sed -e 's /x/x/' $t ; fi; fi`\"; export RANLIB;  WINDRES=\"` if [ -f $r/binutils/windres ] ; then echo $r/binutils/windres ; else if [ \"i386-unknown-freebsd2.1.7\" = \"i586-pc-cygwin32\" ] ; then echo windres; else t='-e s,^,i586-cygwin32-, '; echo windres | sed -e 's/x/x/' $t ; fi; fi`\"; export WINDRES;  echo Configuring in i586-cygwin32/${dir};  cd i586-cygwin32/${dir};  case .. in  /*)  topdir=.. ;;  *)  case \"i586-cygwin32\" in  .) topdir=\"../..\" ;;  *) topdir=\"../../..\" ;; !
  esac ;;  esac;  if [ \"..\" = \".\" ] ; then  if [ \"i586-cygwin32\" != \".\" ] ; then  if /bin/sh $s/symlink-tree  ${topdir}/${dir} \"no-such-file\" ; then  if [ -f Makefile ]; then  if gmake distclean; then  true;  else  exit 1;  fi;  else  true;  fi;  else  exit 1;  fi;  else  true;  fi;  srcdiroption=\"--srcdir=.\";  libsrcdir=\".\";  else  srcdiroption=\"--srcdir=${topdir}/${dir}\";  libsrcdir=\"$s/${dir}\";  fi;  if [ -f ${libsrcdir}/configure ] ; then  /bin/sh ${libsrcdir}/configure  --host=i586-cy gwin32  --build=i386-unknown-freebsd2.1.7 --with-newlib --enable-multilib  --with-cross-host=i386-unknown-freebsd2.1.7     --prefix=/usr/local/gnu-win32 ${srcdiroption}  --with-target-subdir=\"i586-cygwin32\";  else  /bin/sh $s/configure  --host=i586-cygwin32 --build=i386-unknown-freebsd2.1.7 --with-newlib --enable-multilib --with-cross-host=i386-unknown-freebsd2.1.7     --prefix=/usr/local/gnu-win32 ${srcdiroption}  --with-target-subdir=\"i586-cygwin32\";  fi;  else  true;  !
 fi;  else  true;  fi", (char *)NULL);
 X}
 END-of-kill11.c
 echo x - 0parser228
 sed 's/^X//' >0parser228 << 'END-of-0parser228'
 XIndex: parser.c
 X===================================================================
 XRCS file: /home/cvs/cvs/src/bin/sh/parser.c,v
 Xretrieving revision 1.16.2.2
 Xdiff -u -r1.16.2.2 parser.c
 X--- parser.c	1998/11/03 15:57:36	1.16.2.2
 X+++ parser.c	1999/07/03 13:26:28
 X@@ -942,36 +940,27 @@
 X 						USTPUTC('\\', out);
 X 					if (SQSYNTAX[c] == CCTL)
 X 						USTPUTC(CTLESC, out);
 X-					else if (eofmark == NULL)
 X-						USTPUTC(CTLQUOTEMARK, out);
 X 					USTPUTC(c, out);
 X 					quotef++;
 X 				}
 X 				break;
 X 			case CSQUOTE:
 X-				if (eofmark == NULL)
 X-					USTPUTC(CTLQUOTEMARK, out);
 X 				syntax = SQSYNTAX;
 X 				break;
 X 			case CDQUOTE:
 X-				if (eofmark == NULL)
 X-					USTPUTC(CTLQUOTEMARK, out);
 X 				syntax = DQSYNTAX;
 X 				dblquote = 1;
 X 				break;
 X 			case CENDQUOTE:
 X-				if (eofmark != NULL && arinest == 0 &&
 X-				    varnest == 0) {
 X+				if (eofmark) {
 X 					USTPUTC(c, out);
 X 				} else {
 X-					if (arinest) {
 X+					if (arinest)
 X 						syntax = ARISYNTAX;
 X-						dblquote = 0;
 X-					} else if (eofmark == NULL) {
 X+					else
 X 						syntax = BASESYNTAX;
 X-						dblquote = 0;
 X-					}
 X 					quotef++;
 X+					dblquote = 0;
 X 				}
 X 				break;
 X 			case CVAR:	/* '$' */
 X@@ -998,10 +987,6 @@
 X 						if (--arinest == 0) {
 X 							USTPUTC(CTLENDARI, out);
 X 							syntax = prevsyntax;
 X-							if (syntax == DQSYNTAX)
 X-								dblquote = 1;
 X-							else
 X-								dblquote = 0;
 X 						} else
 X 							USTPUTC(')', out);
 X 					} else {
 X@@ -1414,10 +1399,6 @@
 X 		prevsyntax = syntax;
 X 		syntax = ARISYNTAX;
 X 		USTPUTC(CTLARI, out);
 X-		if (dblquote)
 X-			USTPUTC('"',out);
 X-		else
 X-			USTPUTC(' ',out);
 X 	} else {
 X 		/*
 X 		 * we collapse embedded arithmetic expansion to
 X@@ -1453,8 +1434,6 @@
 X 
 X 	p = text;
 X 	while ((c = *p++) != '\0') {
 X-		if ( c == CTLQUOTEMARK)
 X-			continue;
 X 		if (c == CTLESC)
 X 			p++;
 X 		else if (BASESYNTAX[c] == CCTL)
 END-of-0parser228
 echo c - work
 mkdir -p work > /dev/null 2>&1
 echo c - work/gnu-win32
 mkdir -p work/gnu-win32 > /dev/null 2>&1
 echo c - work/gnu-win32/src
 mkdir -p work/gnu-win32/src > /dev/null 2>&1
 echo c - work/gnu-win32/src/CROSS
 mkdir -p work/gnu-win32/src/CROSS > /dev/null 2>&1
 echo c - work/gnu-win32/src/CROSS/i586-cygwin32
 mkdir -p work/gnu-win32/src/CROSS/i586-cygwin32 > /dev/null 2>&1
 echo c - work/gnu-win32/src/CROSS/i586-cygwin32/libstdc++
 mkdir -p work/gnu-win32/src/CROSS/i586-cygwin32/libstdc++ > /dev/null 2>&1
 echo c - work/gnu-win32/src/CROSS/i586-cygwin32/newlib
 mkdir -p work/gnu-win32/src/CROSS/i586-cygwin32/newlib > /dev/null 2>&1
 echo x - work/gnu-win32/src/CROSS/i586-cygwin32/newlib/Makefile
 sed 's/^X//' >work/gnu-win32/src/CROSS/i586-cygwin32/newlib/Makefile << 'END-of-work/gnu-win32/src/CROSS/i586-cygwin32/newlib/Makefile'
 END-of-work/gnu-win32/src/CROSS/i586-cygwin32/newlib/Makefile
 echo c - work/gnu-win32/src/CROSS/binutils
 mkdir -p work/gnu-win32/src/CROSS/binutils > /dev/null 2>&1
 echo x - work/gnu-win32/src/CROSS/binutils/ar
 sed 's/^X//' >work/gnu-win32/src/CROSS/binutils/ar << 'END-of-work/gnu-win32/src/CROSS/binutils/ar'
 END-of-work/gnu-win32/src/CROSS/binutils/ar
 echo c - work/gnu-win32/src/CROSS/gas
 mkdir -p work/gnu-win32/src/CROSS/gas > /dev/null 2>&1
 echo x - work/gnu-win32/src/CROSS/gas/as-new
 sed 's/^X//' >work/gnu-win32/src/CROSS/gas/as-new << 'END-of-work/gnu-win32/src/CROSS/gas/as-new'
 END-of-work/gnu-win32/src/CROSS/gas/as-new
 echo c - work/gnu-win32/src/CROSS/gcc
 mkdir -p work/gnu-win32/src/CROSS/gcc > /dev/null 2>&1
 echo x - work/gnu-win32/src/CROSS/gcc/xgcc
 sed 's/^X//' >work/gnu-win32/src/CROSS/gcc/xgcc << 'END-of-work/gnu-win32/src/CROSS/gcc/xgcc'
 END-of-work/gnu-win32/src/CROSS/gcc/xgcc
 echo c - work/gnu-win32/src/libstdc++
 mkdir -p work/gnu-win32/src/libstdc++ > /dev/null 2>&1
 exit
 
 -- 
 Juergen Lock <nox.foo@jelal.kn-bremen.de>
 (remove dot foo from address to reply)
 


To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-bugs" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199907041110.EAA69488>