zsh-workers
 help / color / mirror / code / Atom feed
* Re: zsh malloc bug
@ 2004-06-16 19:16 Dave Yost
  2004-07-26 13:05 ` Peter Stephenson
  0 siblings, 1 reply; 9+ messages in thread
From: Dave Yost @ 2004-06-16 19:16 UTC (permalink / raw)
  To: Peter Stephenson; +Cc: zsh-workers

A real example follows.

1283 Z% touch ,x
1284 Z% echo '  
import blah.*;
' | ./prepend ,x      
,x.TMP-prepend-21041
zsh: done       echo ' import '$package'.*; ' | 
zsh: bus error  ./prepend ,x
1285 Z% 

======= prepend
#!/bin/zsh

commandName=${0##*/}

usage() {
	if [[ $1 != '' ]] ; then echo 1>&2 "\n$1" ; fi
	echo 1>&2 "
Usage: $commandName [ -t ] file ...

Prepends stdin to each of the given files.
Reads stdin only once.

The -t option preserves each file's modify time.
"
	exit 2
}

zparseopts -D -K - -help=argHelp v=argVerbose t=argPreserveMtime

if [[ $#argHelp != 0 ]] ; then
	usage
fi

case $1 in
-*) usage "Unknown option: $1"
	;;
esac

#-----------------------------------------

sourceTemp=/tmp/$commandName.$$
cat > $sourceTemp
# I would have preferred this, but it discards trailing newlines:
# source=`cat`

TRAPINT() {
	echo 1>&2 "$commandName aborting: interrupted at file $file"
	rm -f $tmp
	exit 2
}

TRAPEXIT() {
	rm -f $sourceTemp
}

for file in $*
do
	if [[ -d $file ]] ; then
		echo 1>&2 "$commandName: skipping directory $file"
	else
		fileDir=${0%/*}
		fileName=${0##*/}
		tmp=$file.TMP-$commandName-$$
		echo $tmp
		cat $sourceTemp >  $tmp \
		&& cat $file	>> $tmp
		if [[ $? != 0 ]] ; then
			echo 1>&2 "$commandName aborting: trouble at file $file"
			rm -f $tmp
			exit 2
		else
			if [[ $#argPreserveMtime != 0 ]] ; then
				cpt -N $file $tmp
			fi
			mv -f $tmp $file
			if [[ $? != 0 ]] ; then
				echo 1>&2 "$commandName aborting: trouble at file $file"
				rm -f $tmp
				exit 2
			fi
			if [[ $#argVerbose != 0 ]] ; then
				echo $file
			fi
		fi
	fi
done


^ permalink raw reply	[flat|nested] 9+ messages in thread
* zsh malloc bug
@ 2004-06-01 18:01 Dave Yost
  2004-06-02  9:32 ` Peter Stephenson
  0 siblings, 1 reply; 9+ messages in thread
From: Dave Yost @ 2004-06-01 18:01 UTC (permalink / raw)
  To: zsh-workers

Hi.

Z% echo $ZSH_VERSION 
4.1.1
Z% uname -a 
Darwin ip2 7.4.0 Darwin Kernel Version 7.4.0: Wed May 12 16:58:24 PDT 2004; root:xnu/xnu-517.7.7.obj~7/RELEASE_PPC  Power Macintosh powerpc

I ran the script below and 1 second later hit ^C, eliciting this output:

Z% ./bug
^Cint
*** malloc[21559]: Deallocation of a pointer not malloced: 0x10f3c0; This could be a double free(), or free() called with the middle of an allocated block; Try setting environment variable MallocHelp to see tools to help debug
Z% 

Here's the script

==============
#!/bin/zsh

TRAPEXIT() {
	echo exit
}

TRAPINT() {
	echo int
	exit
}

sleep 5
# Now type control-c

# or wait til here for a bus error
while true
do
	sleep 1
done
==============

I have a slightly more complicated script that elicits two malloc debug printouts.  I'll send it to whoever fixes this.

See also: my email with the subject "zsh needs try-finally".

Dave


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2004-07-28  3:14 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-06-16 19:16 zsh malloc bug Dave Yost
2004-07-26 13:05 ` Peter Stephenson
2004-07-26 16:48   ` Bart Schaefer
2004-07-26 16:57     ` Peter Stephenson
  -- strict thread matches above, loose matches on Subject: below --
2004-06-01 18:01 Dave Yost
2004-06-02  9:32 ` Peter Stephenson
2004-06-02 18:21   ` Dave Yost
2004-06-08 13:20     ` Peter Stephenson
2004-06-16 19:13       ` Dave Yost

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).