Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Crash when capturing command output in completion



On Thu, 15 Jan 2015 21:20:36 -0800
Bart Schaefer <schaefer@xxxxxxxxxxxxxxxx> wrote:
> On Jan 15,  8:43pm, Bart Schaefer wrote:
> }
> } schaefer<501> echo $(ls)
> } zsh: fatal error: out of memory
> 
> As probably should have been obvious to me, if I back out to before
> workers/34160 (commit c0d01a6fe0c67911650730cf13a2b9a0db16e59b) then
> this error goes away.
> 
> However, it looks to have something to do with factoring lexsave/restore.
> Probably zle_chline isn't getting initialized in all the places that it
> needs to be.

It's not just the rearrangement of saving and restoring, anyway.

The old skipcomm() didn't interact directly with any of the stuff
kludged into the lexer to handle completion, as far as I can see.  It
might be to do with the differences in saving and restoring of state
over the internals of $(...).  If the integration between completion and
the lexer were neat enough, this would be too deep for it to care: it's
just parsing a string recursively.  However, it's never that simple.

Later, completion tries to execute the $(...) to replace the output.
In theory that's not really changed because all it needs is the
string that's been parsed a bit differently...  however, the entry point
to the lexer is also different here.

One thing that needs looking at is whether the history input function
pointers are special over completion.  However, a quick grep suggested
they weren't.

An approach to debugging might be to put back just the old skipcomm(),
which depends less on the rest of the system than the new one, and
nothing else (one replacement of bptr with lexbuf.ptr is needed) and
look for what the resulting differences are.  This appears to
work the way I'd expect (doesn't crash, expands output) but I don't have
time to look further.

(If the worst comes to the worst and this proves intractable, using
a fallback skipcomm() for completion only would be possible.  However, I
suspect this is revealing some interesting difference that should be
fixable.)

pws



Messages sorted by: Reverse Date, Date, Thread, Author