zsh-workers
 help / color / mirror / code / Atom feed
From: "Bart Schaefer" <schaefer@candle.brasslantern.com>
To: zsh-workers@sunsite.auc.dk
Subject: 3.1.6-bart-8: BUG: bad node type in freenode() [and others]
Date: Sat, 20 Nov 1999 22:58:47 +0000	[thread overview]
Message-ID: <991120225847.ZM16138@candle.brasslantern.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 1850 bytes --]

I've just spent the last hour trying to narrow this down, without much
success.  It appears to have something to do with executing the trap at
function exit that is defined by

	trap "$r ; trap - 0 2 3 15 ZERR ; return 1" 0 2 3 15 ZERR

but there must be something else involved because I can't reproduce it
with a function that has only such a trap.

This is confounded by the fact that using "shift" during a "while getopts"
loop appears to cause some sort of confusion; maybe the two together are
what triggers the bug, or maybe it has something to do with "compctl -T",
which is also used in the attached sample function.

Anyway, to reproduce you must autoload the two attached functions, then:

zagzig<1> ftpupdate-pack
1) create    3) symlink   5) chmod     7) rmdir     9) md5sum    11) send     
2) link      4) rename    6) mkdir     8) unlink    10) edit     12) quit     
ftpupdate command: create zsh-3.0.7.tar.gz
ftpupdate-pack: bad option: -3				<-- GETOPTS ODDITY
ftpupdate command: quit

At this point I've gotten both

BUG: bad node type in freenode()
BUG: attempt to free more than allocated.

and a simple crash with no BUG message at all.  The stack trace below is
from the "bad node type" variant.

(gdb) where
#0  0x4004e811 in __kill ()
#1  0x4004e63f in raise (sig=6) at ../sysdeps/posix/raise.c:27
#2  0x4004f84f in abort () at ../sysdeps/generic/abort.c:83
#3  0x8095fda in ifreestruct (a=0x812e138) at ../../zsh-3.1.6/Src/utils.c:2106
#4  0x8095dd1 in freestructs () at ../../zsh-3.1.6/Src/utils.c:2049
#5  0x8068a99 in loop (toplevel=1, justonce=0)
    at ../../zsh-3.1.6/Src/init.c:145
#6  0x804a4f9 in main (argc=1, argv=0xbffff6e4)
    at ../../zsh-3.1.6/Src/main.c:89

-- 
Bart Schaefer                                 Brass Lantern Enterprises
http://www.well.com/user/barts              http://www.brasslantern.com

[-- Attachment #2: zleread --]
[-- Type: text/plain , Size: 379 bytes --]

#! /usr/local/bin/zsh -f
emulate zsh
setopt localoptions
local input opt ropt n=0
ropt=()
while getopts :AEe opt
do
    case $opt in
    [?]) read $*; return $?;;
    +*) break;;
    *) ropt=($ropt -$opt); ((++n));
    esac
done
if [[ -t 0 ]]
then
    shift $n
    vared -hp "${${(M)1%%\?*}#\?}" input
    print -r $input | read $ropt ${1%%\?*} $*[2,-1]
    return $?
fi
read $*

[-- Attachment #3: Text --]
[-- Type: text/plain , Size: 3942 bytes --]

#!/bin/zsh -f
emulate zsh
setopt localoptions nomultios
local f m s

if (($#)) then
    while getopts :m: f
    do
	case $f in
	m) m=$OPTARG;;
	[?]) echo 1>&2 ${0}: bad option: -$OPTARG; return 1;;
	esac
	shift $((OPTIND-1))
    done
    for f
    do
	case $f:e in
	--) continue;;
	[zZ]|gz|bzip2) ;;
	*) echo 1>&2 gzip $f; gzip $f; f=$f.gz;;
	esac
	s=${${=$(md5sum $f)}[1]}
	uuencode $f /dev/stdout |
	sed "s,^begin [0-9]*... /dev/stdout,create $f ${m:-0644} $s,"
    done
    return 0
fi

f=${TMPPREFIX}-ftpupdate.$$
: >| $f
local c p r l REPLY
l=(create link symlink rename chmod mkdir rmdir unlink md5sum edit send quit)
r="$(compctl -LT) ; /bin/rm -f $f"
trap "$r ; trap - 0 2 3 15 ZERR ; return 1" 0 2 3 15 ZERR
compctl -Tx 'p[1,-1]' -f - 'W[0,*]' -k l ${${ZSH_VERSION##3.0*}:+-tn}
local PS3="ftpupdate command: "
select c in $l
do
    p=
    m=
    REPLY=($=REPLY)
    compctl -Tx 'W[0,*]' -f ${${ZSH_VERSION##3.0*}:+-tn}
    case ${c:=$REPLY[1]} in
      mkdir)
	[[ -n "${p:=$REPLY[2]}" ]] || zleread p"?Enter path: " m
	print -R $c ${p:?'Missing path!'} ${${m:=$REPLY[3]}:-0755} >>$f
	;;
      rmdir|unlink|md5sum)
	[[ -n "${p:=$REPLY[2]}" ]] || zleread p"?Enter path: "
	print -R $c ${p:?'Missing path!'} >>$f
	;;
      create)
	[[ -n "${p:=$REPLY[2]}" ]] || zleread p"?Enter path: " m
	ftpupdate-pack -m ${${m:=$REPLY[3]}:-0644} ${p:?'Missing path!'} >>$f
	;;
      chmod)
	[[ -n "${m:=$REPLY[2]}" ]] || zleread m"?Enter mode: " p
	[[ -n "${p:=$REPLY[3]}" ]] || zleread p"?Enter path: "
	print -R $c ${m:?'Missing mode!'} ${p:?'Missing path!'} >>$f
	;;
      rename|link|symlink)
	[[ -n "${p:=$REPLY[2]}" ]] || zleread p"?Enter source: " m
	[[ -n "${m:=$REPLY[3]}" ]] || zleread m"?Enter destination: "
	print -R $c ${p:?'Missing source!'} ${m:?'Missing destination!'} >>$f
	;;
      edit)
	echo -n "Waiting for editor ..."; emacs $f; echo;;
      send)
	less < $f
	read -q c"?Send to ftpupdate@zsh.org now? [yn] " &&
	    pgp -fs < $f | mail -n ftpupdate@zsh.org && break;;
      quit) break;;
  *) less <<'EOF'
  mkdir <pathname> <mode>
      Create a directory.  Existing files will not be overwritten.
      The mode *must* include the bits 0700.

  rmdir <pathname>
      Remove a directory.

  create <pathname> <mode> <md5sum>
      Create a regular file; any existing non-directory of that name
      is deleted.  The MD5 checksum is checked, and stored in the MD5SUM
      file.  The command must be followed by uuencoded data, sans "begin"
      line, terminated by "end".

  md5sum <pathname>
      Regenerate the MD5SUM entry for a regular file.  This should only
      be used if the MD5SUM entry is missing or corrupted.

  chmod <mode> <pathname>
      Change mode of the specified file to the specified octal value.
      If modifying a directory, the mode *must* include the bits 0700.
      Symbolic links cannot be modified in this manner.

  unlink <pathname>
      Remove a non-directory.

  rename <source-pathname> <destination-pathname>
      Rename/move an existing file.  A non-directory, when renamed,
      can replace an existing non-directory.

  link <source-pathname> <destination-pathname>
      Create a hard link to a non-directory.  Existing files will not
      be overwritten.

  symlink <source-pathname> <destination-pathname> [<md5sum>]
      Create a symbolic link; any existing non-directory of that name is
      deleted.  The MD5 checksum, if given, is stored in the appropriate
      MD5SUM file; this should be the MD5 checksum of the file the link
      points to.
      The <source-pathname> can be any sequence of permitted characters,
      even if it refers to a reserved filename or a filename that the
      user does not have permission to examine or modify.  Note that
      this pathname is interpreted relative to the directory containing
      the symbolic link.

EOF
    ;;
    esac
    compctl -Tx 'p[1,-1]' -f - 'W[0,*]' -k l ${${ZSH_VERSION##3.0*}:+-tn}
done
eval "$r"

             reply	other threads:[~1999-11-20 22:59 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-11-20 22:58 Bart Schaefer [this message]
1999-11-22 11:44 Sven Wischnowsky

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=991120225847.ZM16138@candle.brasslantern.com \
    --to=schaefer@candle.brasslantern.com \
    --cc=zsh-workers@sunsite.auc.dk \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).