From: Bart Schaefer <schaefer@brasslantern.com>
To: zsh-workers@sunsite.dk
Subject: Re: Crash of 4.2.0-dev-1
Date: Sun, 11 Apr 2004 16:09:38 +0000 [thread overview]
Message-ID: <1040411160938.ZM17940@candle.brasslantern.com> (raw)
In-Reply-To: <slrnc7hv93.g5j.mason@g.primenet.com.au>
On Apr 11, 8:09am, Geoff Wing wrote:
} Subject: Re: Crash of 4.2.0-dev-1
}
} Bart Schaefer <schaefer@brasslantern.com> typed:
} : I presume of 4.2.0 also. Reproduce as follows:
} :
} : (1) Create a file "kshtest" in a directory in fpath. This file should NOT
} : define the function "kshtest"
}
} Any specific kshtest example for us?
Hmm, I thought I'd reproduced this with a very simple example but I guess
there is one more thing necessary for it to happen reliably. Here are
the first two steps again, corrected.
(1) Place the following in a file "kshtest" in a directory in fpath:
print "Running kshtest"
unfunction kshtest
(2) Run zsh -f and execute:
setopt kshautoload
autoload +X -k kshtest
kshtest
} : (3) Observe the [correct] error:
} :
} : zsh: kshtest: function not defined by file
}
} I don't understand why this is the correct error
Because files loaded with kshautoload have to contain the full function
definition, like so:
kshtest() {
print "Running kshtest"
unfunction kshtest
}
And the kshtest file as created in (1) does not do so.
} since you setopt kshautload
That's another critical bit in tripping the bug. After "autoload +X -k"
of the "incorrect" kshtest file, the function kshtest is defined as:
kshtest () {
print "Running kshtest"
unfunction kshtest
kshtest "$@"
}
Whereas zsh expects it to have been defined as:
kshtest () {
kshtest () {
print "Running kshtest"
unfunction kshtest
}
kshtest "$@"
}
The extra layer of function wrapper plus the call with "$@" is added
by "autoload +X".
} Also, I haven't yet understood why it was run twice in my case (but
} I've been sick so maybe my brain isn't working properly yet).
Normally, the function redefines itself and then the new definition is
called. When the file itself does not contain its own function wrapper,
it ends up calling itself -- but only once, because that call re-auto-
loads the file without the +X behavior. When that happens after the
function has been "unfunction"d, something bad results.
(Normally zsh protects itself against functions that unfunction them-
selves, otherwise "compinit" wouldn't work properly. Somehow having
kshautoload set is bypassing those defenses.)
} : (4) Memory is now corrupted. At some point soon, usually but not always
} : during printing of the next prompt, the shell will crash in malloc().
}
} I'm still going. Haven't seen any memory problems yet.
The "unfunction" appears to be necessary.
next prev parent reply other threads:[~2004-04-11 16:09 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-04-11 5:30 Bart Schaefer
2004-04-11 8:09 ` Geoff Wing
2004-04-11 16:09 ` Bart Schaefer [this message]
2004-04-11 22:40 ` Geoff Wing
2004-04-12 1:04 ` Bart Schaefer
2004-04-12 1:34 ` Felix Rosencrantz
2004-04-15 18:13 ` Peter Stephenson
2004-04-16 4:06 ` Bart Schaefer
2004-04-21 15:11 ` PATCH: " Peter Stephenson
2004-04-24 17:10 ` Bart Schaefer
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=1040411160938.ZM17940@candle.brasslantern.com \
--to=schaefer@brasslantern.com \
--cc=zsh-workers@sunsite.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).