zsh-workers
 help / color / mirror / code / Atom feed
* Re: Wordcode functions with empty bodies
@ 2000-06-14 14:36 Sven Wischnowsky
  0 siblings, 0 replies; 12+ messages in thread
From: Sven Wischnowsky @ 2000-06-14 14:36 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> On Jun 14,  8:14am, Sven Wischnowsky wrote:
> } Subject: Re: Wordcode functions with empty bodies
> }
> } I had a little debugging session yesterday evening... I could
> } reproduce the segv with the `prompt' thing (although I had to invoke
> } `prompt bart' a second time with some other command before it to make
> } it go kaboom).
> } 
> } I could not, however, see any problems with bld_eprog(). In which way
> } do you think it produces garbled eprogs? (I mean, what do those eprogs 
> } look like?)
> 
> They have a `len' of 4 and a `strs' that points to four bytes of garbage.
> The crashes appear to happen after dupeprog() copies `strs' -- the new
> copy often ends up pointing to a different four bytes of garbage.

I almost thought that you meant this... that's ok, even if it looks
weird. `len' is the total length of the memory block used for
patterns, the word code and the string table. `prog' and `strs' point
into that memory at the rightpositions, `strs' after the word
code. Since there are no strings it points to the memory *after* the
word code... but it will never be used.


Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: Wordcode functions with empty bodies
@ 2000-06-15  8:12 Sven Wischnowsky
  0 siblings, 0 replies; 12+ messages in thread
From: Sven Wischnowsky @ 2000-06-15  8:12 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> ...
> 
> This has fixed the "prompt bart" crash, though I still don't quite follow
> why putting a `:' command in the function body (instead of using an empty
> function) prevented the crash before.

Purely accidental. It freed the eprog, then allocated some more memory 
(sometimes for another eprog(!)) and later copied the freed eprog. If
the thing allocated into the freed eprog was something looking
(almost) like a valid eprog, it worked. With something in the body of
the function this (sometimes) happened, sometimes not. While debugging 
this, I had cases where it allocated something sensible into the freed 
eprog, sometimes not, both with and without something in the function
body.


Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: Wordcode functions with empty bodies
@ 2000-06-14 14:28 Sven Wischnowsky
  2000-06-14 15:08 ` Peter Stephenson
  0 siblings, 1 reply; 12+ messages in thread
From: Sven Wischnowsky @ 2000-06-14 14:28 UTC (permalink / raw)
  To: zsh-workers


Peter Stephenson wrote:

> > If you can
> > find a particular chunk of code which seems to be doing something wrong
> > (shorter than the complete traps test) I'll have a look at it sometime.
> 
> While I'm waiting, there's something obviously wrong with the way exit
> tests are unset, but this looks too simple to be the source of everyone's
> problems --- which generically stem from the fact that traps can take two
> forms which are stored in the same place but manipulated in different ways.

No need to wait...

Try this: start with -f, autoload promptinit and call it. Then install 
break points at settrap(), freeeprog() and endtrapscope(). For even
more fun, do `display sigfuncs[28]' (SIGWINCH). Now type `prompt bart'.

It first hits some rather uninteresting break points, then settrap()
which installs the handler for SIGWINCH (from setfunction() in
parameter.c). Fine. Continue, it hits endtrapscode() and from there
frees the eprog in sigfuncs[28]. BUT it doesn't reset sigfuncs[28].
Continue again until you get to the shell prompt. Type `echo <RET>'
(this makes the memory for the eprog be freed) and look at
*sigfuncs[28]: garbage.

If you want to get the full picture: set a break point at
signals.c:675 and continue till there. It is now trying to dupeprog()
the thing in sigfuncs[28] -- kaboom.

So, where do we need to put the `sigfuncs[sig] = NULL'?


Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 12+ messages in thread
* Re: Wordcode functions with empty bodies
@ 2000-06-14  6:14 Sven Wischnowsky
  2000-06-14 12:20 ` Peter Stephenson
  2000-06-14 14:23 ` Bart Schaefer
  0 siblings, 2 replies; 12+ messages in thread
From: Sven Wischnowsky @ 2000-06-14  6:14 UTC (permalink / raw)
  To: zsh-workers


Bart Schaefer wrote:

> This is mostly aimed at Sven ... just a reminder that the bug discussed in
> 11837-11841 and 11854-11859 appears to have something to do with wordcode
> compiled from a function whose body is the single token NULLTOK.

I had a little debugging session yesterday evening... I could
reproduce the segv with the `prompt' thing (although I had to invoke
`prompt bart' a second time with some other command before it to make
it go kaboom).

I could not, however, see any problems with bld_eprog(). In which way
do you think it produces garbled eprogs? (I mean, what do those eprogs 
look like?)

Placing some breakpoints in signals.c, I noticed a) that I think the
memory handling there seems to be wrong and b) that I don't understand 
the control flow (again), so I don't dare to fiddle with it.

About a): the freeeprogs() don't seem to get called. See also Felix'
last memory leak message (11766), describing a memory leak there. So I 
think the eprog copied at line 675 somehow survives too long, is freed 
elsewhere (does signals.c really keep the original?) and later
accessed. Or something. (In my reply to 11766 in 11796 I meant to say
that maybe Peter should have a look at it, him probably being the only 
one who really understands what goes on in signals.c or what should go 
on...)


Ok. If you could give me an easy example of how to make bld_eprog()
give garbled results, I'd be thankful. Just doing `functions[foo]=""'
at least gives me sensible results.

Bye
 Sven


--
Sven Wischnowsky                         wischnow@informatik.hu-berlin.de


^ permalink raw reply	[flat|nested] 12+ messages in thread
* Wordcode functions with empty bodies
@ 2000-06-13 16:31 Bart Schaefer
  0 siblings, 0 replies; 12+ messages in thread
From: Bart Schaefer @ 2000-06-13 16:31 UTC (permalink / raw)
  To: zsh-workers

This is mostly aimed at Sven ... just a reminder that the bug discussed in
11837-11841 and 11854-11859 appears to have something to do with wordcode
compiled from a function whose body is the single token NULLTOK.

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

Zsh: http://www.zsh.org | PHPerl Project: http://phperl.sourceforge.net   


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

end of thread, other threads:[~2000-06-15  8:13 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-06-14 14:36 Wordcode functions with empty bodies Sven Wischnowsky
  -- strict thread matches above, loose matches on Subject: below --
2000-06-15  8:12 Sven Wischnowsky
2000-06-14 14:28 Sven Wischnowsky
2000-06-14 15:08 ` Peter Stephenson
2000-06-14 15:17   ` Peter Stephenson
2000-06-14 16:17   ` Bart Schaefer
2000-06-14 21:55     ` Peter Stephenson
2000-06-14  6:14 Sven Wischnowsky
2000-06-14 12:20 ` Peter Stephenson
2000-06-14 14:03   ` Peter Stephenson
2000-06-14 14:23 ` Bart Schaefer
2000-06-13 16:31 Bart Schaefer

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