Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Help me track down a tough bug? (probably funcfiletrace, subshells and possibly I/O redirection)
- X-seq: zsh-users 13294
- From: "Rocky Bernstein" <rocky.bernstein@xxxxxxxxx>
- To: "zsh users mailing list" <zsh-users@xxxxxxxxxx>
- Subject: Help me track down a tough bug? (probably funcfiletrace, subshells and possibly I/O redirection)
- Date: Sun, 28 Sep 2008 15:19:37 -0400
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to :subject:mime-version:content-type:content-transfer-encoding :content-disposition; bh=UMzqy1Aq5EHDfKdQy9XQkky3PmAsdWmjPJfUFAk8YAI=; b=UNAZbRgiG6E4j4mpSp0WSRLFxJx4Kc0vvB/OTrYJI5iU100edZnXpGe0y4vOgfbMOe tGkRPGbOP3Wzurpoy55zmA1qBHOLS922ZuVbxLw2nT/LaX1gciApwNsIaj2W0qlw0Seq T+6pKZcFXDqGFG6JklblTZckcXlJcK0A1Tui8=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:mime-version:content-type :content-transfer-encoding:content-disposition; b=UABqZn5eymLo/0qVJP99vUHEN8IRvyXGniw5/0noYavldS4RBJ3q/JSR/3CIF8uSY7 PZkVW00oZwad+Un8VmYd0J2g+t7zvfRDzaz2m5gvnV5vUBmCSPpJnJmEMEA4LrAR7kQt opslmk8m72/7u1K4t2SHwAPhmUEP68iHv1Xxw=
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
There is what looks to me a bug in the recent funcfiletrace that I've
been trying to isolate. I've spent the weekend on this and have made
some progress but have to stop now. Perhaps there's someone out there
who can help further pinpoint this bug.
You'll need the most recent zsh in CVS. If you have zshdb installed
(and chances are you don't) you can see the bug by
running this program under the debugger
#!/usr/local/bin/zsh
# Test debugger handling of subshells
(
x=$(print 5; print 6)
)
Below I'll show output from a sample session using the debugger. I've
put comments to the side (in #) to try to explain what's going on.
$ zshdb -q /tmp/zshdb/testing.sh # run testing.sh
(/tmp/zshdb/testing.sh:3): # file and line number
( x=$(print 5; print 6) ) # What's going to get run next
zshdb<4> s # 's' issues a "step" command
(/tmp/zshdb/testing.sh:4):
x=$(print 5; print 6) # Note we are in a subshell
zshdb<(5)> s # the () indicates this
(/tmp/zshdb/testing.sh:1):
print 5 # In a 2nd subshell, backtick
zshdb<((7))> where # ((..)) indicates this.
->0 in file `/tmp/zshdb/testing.sh' at line 1
##1 /tmp/zshdb/testing.sh called from file `/usr/local/bin/zshdb' at line 106
As suggested in the comments above, you know you've gotten to the
problem point when you see the double parenthesis in the zshdb prompt
which means you are nested inside two subshells. The first is a ()
kind of subshell and the second, a backtick or $() kind of subshell.
What's wrong is that we aren't on line 1 of testing.sh. This
information is coming from funcfiletrace. We can use the debugger to
show this via a "print" command
zshdb<((8))> p ${funcfiletrace[@]}
/usr/local/share/zshdb/command/eval.sh:29
/usr/local/share/zshdb/command/eval.sh:59
/usr/local/share/zshdb/lib/processor.sh:118
/usr/local/share/zshdb/lib/processor.sh:50
/usr/local/share/zshdb/lib/hook.sh:164
/usr/local/share/zshdb/lib/hook.sh:29 /tmp/zshdb/testing.sh:1
/usr/local/bin/zshdb:106
zshdb<((9))>
In the above the /usr/local/bin/zshdb:106 is kind of bogus, so ignore
it. That's just the way zsh currently works.
Alas, zshdb is alas a large and (too) complex program. However my
attempts to start with a small program to show the problem elude me.
So I have started working the other direction and started stripping
down zshdb. You can get a copy of a drastically reduced version of
zshdb at http://bashdb.sf.net/zshdb-0.01bug.tar.gz
If you untar this and run ./configure, zshdb2.sh should get created.
This mini-debugger "debugs" a script in the same directory called
testing.sh. This is a copy of what I showed above. It also has some
debug output in thrown in. Again we run the program and step until we
are two subshells deep.
Here's the same thing using zshdb2.sh
$ ./zshdb2.sh
./zshdb2.sh
---------------
./zshdb2.sh:39 ./zshdb2.sh:34 # functrace output
===============
(./zshdb2.sh:34):
. ./testing.sh
./zshdb2.sh:39 ./zshdb2.sh:34
zshdb<1> s
---------------
./zshdb2.sh:8 ./testing.sh:3 ./zshdb2.sh:34
===============
(./testing.sh:3):
( x=$(print 5; print 6) )
./zshdb2.sh:8 ./testing.sh:3 ./zshdb2.sh:34
zshdb<2> s
---------------
./zshdb2.sh:9 ./testing.sh:4 ./zshdb2.sh:34
===============
(./testing.sh:4):
x=$(print 5; print 6)
./zshdb2.sh:9 ./testing.sh:4 ./zshdb2.sh:34
zshdb<(3)> s
# Note functrace output
disappears. Something up with output?
zshdb<((4))> p ${funcfiletrace[@]}
./command/eval.sh:5 ./command/eval.sh:23 ./lib/processor.sh:67
./lib/processor.sh:16 ./zshdb2.sh:6 ./testing.sh:1 ./zshdb2.sh:34
zshdb<((5))>
Above ./testing.sh:1 should be ./testing.sh:6 and we see 6 in
zshdb.sh:6 the next entry.
Any help in narrowing or fixing this problem is appreciated. One could
try to start with a new program that works sort of like this
stripped-down code. Or one could just try to simplify and remove more
stuff.
Thanks!
Messages sorted by:
Reverse Date,
Date,
Thread,
Author