[gnu.bash.bug] bash 1.02 core dumps on control-D

accwai@WATMATH.WATERLOO.EDU (Andy Wai) (07/10/89)

  Script started on Sun Jul  9 21:45:32 1989
  watmsg[1]% /usr/local/bin/bash
  watmsg[1]$ ^D
  Segmentation fault    /usr/local/bin/bash (core dumped)
  watmsg[2]% exit

  script done on Sun Jul  9 21:45:55 1989

The machine is a Vax running 4.3 BSD.  This seems to happen regardless of
the values of variables and environments.

One more comment:  the Makefile for version 1.02 is much less portable
than the previous one.  For example, some versions of make don't understand
the following:

  %.o : %.c
  ^^^^^^^^^
	  $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@

It also assumes the existence of variables like MAKE and RM which is
not defined in some versions of make.

Thanks.

Andy Wai

chet@kiwi.CWRU.EDU (Chet Ramey) (07/10/89)

In article <8907100230.AA22676@watmath.waterloo.edu> accwai@WATMATH.WATERLOO.EDU (Andy Wai) writes:
>
>  Script started on Sun Jul  9 21:45:32 1989
>  watmsg[1]% /usr/local/bin/bash
>  watmsg[1]$ ^D
>  Segmentation fault    /usr/local/bin/bash (core dumped)
>  watmsg[2]% exit
>

Brian took out the checks for current_readline_line[0] == EOF, and tries to
dereference it (parse.y: yy_readline_get).  Patch below.  Once again, this
may not be the Officially Blessed patch (there has to be a better way to do
this, but this works). 

>  %.o : %.c
>  ^^^^^^^^^
>	  $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
>
>It also assumes the existence of variables like MAKE and RM which is
>not defined in some versions of make.
>

There is no excuse for not using Gnu Make, which has all of these features.

The rule in question is basically equivalent to:

	.c.o:
		$(CC) -c $(CFLAGS) $(CPPFLAGS) $*.c


*** bash-1.02/parse.y	Sat Jul  1 21:42:28 1989
--- src-1.02/parse.y	Fri Jul  7 14:31:03 1989
***************
*** 431,438
  
        current_readline_line_index = 0;
!       current_readline_line =
! 	(char *)xrealloc (current_readline_line,
! 			  2 + strlen (current_readline_line));
!       strcat (current_readline_line, "\n");
      }
  

--- 431,447 -----
  
        current_readline_line_index = 0;
!       if ((long)current_readline_line != (long)EOF) {
!         current_readline_line =
! 	  (char *)xrealloc (current_readline_line,
! 			    2 + strlen (current_readline_line));
!         strcat (current_readline_line, "\n");
!       }
!     }
! 
!   if ((long) current_readline_line == (long) EOF) 
!     {
!       current_readline_line = (char *) NULL;
!       current_readline_line_index = 0;
!       return (EOF);
      }
  
Chet Ramey			"We are preparing to think about contemplating 
Network Services Group, CWRU	 preliminary work on plans to develop a
chet@cwjcc.INS.CWRU.Edu		 schedule for producing the 10th Edition of 
				 the Unix Programmers Manual." -- Andrew Hume