Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Help me track down a tough bug? (probably funcfiletrace, subshells and possibly I/O redirection)
- X-seq: zsh-workers 25776
- From: "Rocky Bernstein" <rocky.bernstein@xxxxxxxxx>
- To: "Peter Stephenson" <p.w.stephenson@xxxxxxxxxxxx>
- Subject: Re: Help me track down a tough bug? (probably funcfiletrace, subshells and possibly I/O redirection)
- Date: Mon, 29 Sep 2008 20:18:52 -0400
- Cc: "Zsh hackers list" <zsh-workers@xxxxxxxxxx>
- 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:cc:in-reply-to:mime-version:content-type :content-transfer-encoding:content-disposition:references; bh=4CdZPvuwoBU/LxfElm3nmcS/j9AI8Uk/tYLYD3NriAQ=; b=T9JxnwISH+OZNv+2o3mCfUv+Y3RBnbUs0B6Jc/xgRCxJrr+y2dBfsrJWEPS10yGWvr +YTtBsj71fm56K5PqSdfE2itnlhdXteRy9gJ+zQCdw87Vek9D4cmePGsN/36WV5KCamp 4ZZ8BqxDnUii+0j56TsUeQgBy9rCB3pduFssc=
- Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:cc:in-reply-to:mime-version :content-type:content-transfer-encoding:content-disposition :references; b=eZDF4YK383JFQ1XuzINKtxsFxn1aR1uDFtukZjAkm/nqf8LQV1teKYI9sern5Uf/qN zX07FmJ+eKzeFGzlu8lVBe3+nwZD8LR8f5zIltAZNqHGVBSFnjemySZfpPBGy3Uli6lm 9AIAYQ9849cZ9yAhxltkfHyfAWPb51oui2uZk=
- In-reply-to: <20080929224209.1bd8f3f6@pws-pc>
- Mailing-list: contact zsh-workers-help@xxxxxxxxxx; run by ezmlm
- References: <6cd6de210809281219i4bf1ed18mefa45b967fa835a6@xxxxxxxxxxxxxx> <20080928221651.6ee7f671@pws-pc> <6cd6de210809281932u2e04a844l219d1db5a7568a73@xxxxxxxxxxxxxx> <20080929095201.451381d0@news01> <6cd6de210809290411m60cb669bk3817d768adce378a@xxxxxxxxxxxxxx> <200809291125.m8TBPsQM005256@xxxxxxxxxxxxxx> <6cd6de210809290711j12363e1bo159e1739bae7b2fd@xxxxxxxxxxxxxx> <200809291425.m8TEPSoR007204@xxxxxxxxxxxxxx> <20080929224209.1bd8f3f6@pws-pc>
On Mon, Sep 29, 2008 at 5:42 PM, Peter Stephenson
<p.w.stephenson@xxxxxxxxxxxx> wrote:
> On Mon, 29 Sep 2008 15:25:28 +0100
> Peter Stephenson <pws@xxxxxxx> wrote:
>> "Rocky Bernstein" wrote:
>> > ./zshdb2.sh
>> > ./zshdb2.sh:39 ./zshdb2.sh:34 # Debug output in lib/frame.sh
>> >
>> > # Above should be: ./lib/hook.sh:5 ./zshdb2.sh:34
>> > # note: 34+5=39
>>
>> Ah, I see, so this should be fairly obvious once I track back and see
>> what the code referred to is... I'll try and get round to this this
>> evening.
>
> Wasn't so easy, since there was quite a lot of irrelevant stuff to
> strip.
If you started with zshdb-0.01bug, if it is of any consolation, I'd
been stripping stuff out all weekend, well as trying to create simple
test cases. If you started with the git source well, yes, that's quite
large.
> It turns out the problem is handling of functions inside traps.
> These inherit the behaviour of the parent (eval-style, i.e. not
> TRAP...() { ... } ) trap that the line number isn't updated, it's kept
> as that in the line that caused the trap. This causes oddities like
> this, so I think it wants turning off so that the functions called from
> the trap act normally. This seems to accord with the principle of least
> surprise, too.
Works much better. Thanks! (Really, I had been living with messed up
line numbers in debugger code for a while. You get them in xtrace
output as well. )
> That seems to fix the problem, but I'm sure I'll be
> hearing if it doesn't.
You are correct. It's really the next set of problems that I was more
concerned about since this is something users of a debugger see rather
than me or folks who happen to use trap DEBUG. Since you asked for
specific line numbers, posted them. And I think in order to get to the
next part I guess we have to remove this problem first since it is
what is the most glaring part.
So if you have zshdb-0.01bug around keep stepping:
$ ./zshdb2.sh
./zshdb2.sh:7 ./zshdb2.sh:34 # Much better. Thanks!
(./zshdb2.sh:34):
. ./testing.sh
./zshdb2.sh:9 ./zshdb2.sh:34 # Also correct!
zshdb<1> p ${funcfiletrace[@]}
./command/eval.sh:11 ./command/eval.sh:27 ./lib/processor.sh:96
./lib/processor.sh:44 ./zshdb2.sh:9 ./zshdb2.sh:34
# Above is still good! Now watch what happens next
./zshdb2.sh:9 ./zshdb2.sh:34
zshdb<2> s
./zshdb2.sh:7 ./testing.sh:3 ./zshdb2.sh:34 # Correct
(./testing.sh:3):
( x=$(print 5; print 6) )
./zshdb2.sh:9 ./testing.sh:3 ./zshdb2.sh:34 # Correct
zshdb<3> p ${funcfiletrace[@]}
./command/eval.sh:11 ./command/eval.sh:27 ./lib/processor.sh:96
./lib/processor.sh:44 ./zshdb2.sh:9 ./testing.sh:3 ./zshdb2.sh:34
./command/eval.sh:11 ./command/eval.sh:27 ./lib/processor.sh:96
./lib/processor.sh:44 ./zshdb2.sh:9 ./testing.sh:3 ./zshdb2.sh:34
./zshdb2.sh:9 ./testing.sh:3 ./zshdb2.sh:34
# Were did that double set of lines come from?
# Try again..
zshdb<4> s
./zshdb2.sh:7 ./testing.sh:4 ./zshdb2.sh:34 # Correct
(./testing.sh:4):
x=$(print 5; print 6)
./zshdb2.sh:9 ./testing.sh:4 ./zshdb2.sh:34 # Correct
zshdb<(5)> p ${funcfiletrace[@]}
./command/eval.sh:11 ./command/eval.sh:27 ./lib/processor.sh:96
./lib/processor.sh:44 ./zshdb2.sh:9 ./testing.sh:4 ./zshdb2.sh:34
./command/eval.sh:11 ./command/eval.sh:27 ./lib/processor.sh:96
./lib/processor.sh:44 ./zshdb2.sh:9 ./testing.sh:4 ./zshdb2.sh:34
./command/eval.sh:11 ./command/eval.sh:27 ./lib/processor.sh:96
./lib/processor.sh:44 ./zshdb2.sh:9 ./testing.sh:4 ./zshdb2.sh:34
# Now 3 copies
./zshdb2.sh:9 ./testing.sh:4 ./zshdb2.sh:34
zshdb<(6)> ...
And the printing of funcfiletrace masks another problem which I think
is more serious. It's possible this has nothing to do with
funcfiletrace but might be related to the repeating lines above. What
is happing is that instead of duplicate lines, output disappears. The
missing output occurs before "zshdb<((4))>" below.
#
$ ./zshdb2.sh
./zshdb2.sh:7 ./zshdb2.sh:34
(./zshdb2.sh:34):
. ./testing.sh
./zshdb2.sh:9 ./zshdb2.sh:34
zshdb<1> s
./zshdb2.sh:7 ./testing.sh:3 ./zshdb2.sh:34
(./testing.sh:3):
( x=$(print 5; print 6) )
./zshdb2.sh:9 ./testing.sh:3 ./zshdb2.sh:34
zshdb<2> s
./zshdb2.sh:7 ./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
zshdb<((4))> s
zshdb<((5))>
> I suspect sources inside eval-style traps behave
> similarly and ought to be fixed, which could be done with sourcelevel,
> but sufficient unto the day etc. (The tests could also be done by
> pushing a special FS_TRAP type onto funcstack, but that has obvious
> visible consequences. funcstack is a relative latecomer and could have
> been used for also sorts of things we now do other ways.)
>
> Responses avoiding "it should have been done completely differently from
> the start", "it would be nice to have an option to do it completely
> differently" and "other languages do this much better" preferred.
I'm not complaining! Beggar's can't be choosers.
Personally, I think it interesting and useful to know about how other
languages which have encountered the same or similar problems have
solved them. But if this is irksome, I'll not mention in the future.
Thanks for the speedy fixes on these issues.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author