🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

3 total messages Started by Jean-Daniel Fekete Tue, 04 Jul 1989 18:12
Bug in bash 1.01
#208
Author: Jean-Daniel Fekete
Date: Tue, 04 Jul 1989 18:12
39 lines
986 bytes
The following make bash barf in free.

function zap()
{
  if [ $# -gt 0 ]
  then
    for proc
    do
      for pid in $( ps -ax | grep $proc | grep -v grep | awk '{print $1}' )
      do
        kill -KILL $pid &> /dev/null
      done
    done
    unset proc
  else
    echo "usage: zap <cmd> ..."
  fi
}

function hup()
{
  if [ $# -gt 0 ]
  then
    for proc
    do
      for pid in $( ps -ax | grep $1 | grep -v grep | awk '{print $1}' )
      do
        kill -HUP $pid &> /dev/null
      done
    done
    unset proc
  else
    echo "usage: hup <cmd> ..."
  fi
}


unset zap hup
Re: Bug in bash 1.01
#212
Author: Chet Ramey
Date: Wed, 05 Jul 1989 18:42
54 lines
2488 bytes
In article <8907041812.AA01639@ccvi.ccv.fr> jdf@ccvi.ccv.fr (Jean-Daniel Fekete) writes:

>The following make bash barf in free.

>function zap()
>{
	...
>        kill -KILL $pid &> /dev/null
	...
>}

>unset zap


It's the redirections that are doing it.  It's dispose_redirects() that is
calling free() twice with the same redirection record (actually a portion
of the same redirection record -- the filename).

The problem is that when the command was copied (when the function was
bound), the case of r_err_and_out was left out of the case statement in
copy_cmd.c: copy_redirect(), so the filename part of the redirection struct
never got copied, and was shared by both the command struct built by
yyparse() and the command struct that is part of the function definition
(whew :-).  When the function definition was read and parsed, and the
function installed, the command tree built in yyparse() was freed, and
along with it the redirection info.  Then, in unset_builtin, the copy of
the command tree associated with the function struct was freed.  The
redirection info never was copied, so it was freed twice. 

The fix is amazingly simple.  Once again, it is not the Officially Blessed
fix; Brian might decide to do something different.  However, it works.

*** bash-1.01/copy_cmd.c	Fri Jun 23 00:47:13 1989
--- src-1.01/copy_cmd.c	Wed Jul  5 13:36:12 1989
***************
*** 96,99
    case r_input_direction:
    case r_inputa_direction:
      new_redirect->redirectee.filename =
        copy_word (redirect->redirectee.filename);

--- 96,100 -----
    case r_input_direction:
    case r_inputa_direction:
+   case r_err_and_out:
      new_redirect->redirectee.filename =
        copy_word (redirect->redirectee.filename);



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
Bug in bash 1.01
#213
Author: Brian Fox
Date: Wed, 05 Jul 1989 19:21
50 lines
1437 bytes
   Date: Tue, 4 Jul 89 20:12:03 +0200
   From: jdf@ccvi.ccv.fr (Jean-Daniel Fekete)


   The following make bash barf in free.

   function zap()
   {
     if [ $# -gt 0 ]
     then
       for proc
       do
	 for pid in $( ps -ax | grep $proc | grep -v grep | awk '{print $1}' )
	 do
	   kill -KILL $pid &> /dev/null
	 done
       done
       unset proc
     else
       echo "usage: zap <cmd> ..."
     fi
   }

   function hup()
   {
     if [ $# -gt 0 ]
     then
       for proc
       do
	 for pid in $( ps -ax | grep $1 | grep -v grep | awk '{print $1}' )
	 do
	   kill -HUP $pid &> /dev/null
	 done
       done
       unset proc
     else
       echo "usage: hup <cmd> ..."
     fi
   }


   unset zap hup
Thanks.

I have already fixed this bug.  The function copy_redirection (), in the
file copy_cmd.c did not copy the filename part of an `err_and_out'
redirection.  Just add it to the list in the case statement.

Brian
Thread Navigation

This is a paginated view of messages in the thread with full content displayed inline.

Messages are displayed in chronological order, with the original post highlighted in green.

Use pagination controls to navigate through all messages in large threads.

Back to All Threads