zsh-workers
 help / color / mirror / code / Atom feed
From: Vincent Lefevre <vincent@vinc17.net>
To: zsh-workers@zsh.org
Subject: Re: completion on brace + 4 characters doesn't work
Date: Mon, 2 May 2011 10:08:39 +0200	[thread overview]
Message-ID: <20110502080839.GG5625@prunille.vinc17.org> (raw)
In-Reply-To: <110429072032.ZM13518@torch.brasslantern.com>

On 2011-04-29 07:20:32 -0700, Bart Schaefer wrote:
> On Apr 29, 10:44am, Vincent Lefevre wrote:
> } > The code there apparently assumes a naive implementation of strcpy()
> } > that goes left-to-right incrementing the source and destination
> } > pointers in lock step.
> } 
> } It also assumes that the length of the string is less than len
> 
> Not really, because if the naive copy is done then the only thing
> that matters is that len >= 0.

Well, you can have a naive strcpy() implementation in the C library,
but still the compiler is allowed to do any optimization, such as
guessing the value of len (or some bounds) from the strcpy() call;
this would not affect the behavior at strcpy(), but may affect the
use of the len variable in some parts of the code.

> } (because the source and the destination may not overlap).  The
> } compiler can use this fact to optimize the code. And as this is
> } not true, the generated code may be incorrect.
> 
> Yes, I was aware of all this, I just didn't think it was worth spelling
> out (it's implicitly not "naive").  Keep in mind that this portion of
> zle_tricky.c was written at least 10 years ago by a college student;
> zsh was rarely if ever built with highly-optimized compilers/libc on
> 64-bit platforms, at the time.
> 
> Which is why I said:
> 
> } > It would not surprise me to
> } > find this assumption made elsewhere in the zsh sources.
> 
> I don't suppose you could run through the entire "make check" test
> suite under valgrind?  Even that won't exercise everything but it'll
> find the ones most likely to bite somebody.

That would be a good idea. There's at least one:

==2490== Invalid read of size 1
==2490==    at 0x430AFE: execcmd (exec.c:3011)
==2490==    by 0x42CAAC: execpline2 (exec.c:1640)
==2490==    by 0x42BC2C: execpline (exec.c:1424)
==2490==    by 0x42B2EA: execlist (exec.c:1207)
==2490==    by 0x431723: execcmd (exec.c:3259)
==2490==    by 0x42CAAC: execpline2 (exec.c:1640)
==2490==    by 0x42BC2C: execpline (exec.c:1424)
==2490==    by 0x42B2EA: execlist (exec.c:1207)
==2490==    by 0x42AD64: execode (exec.c:1028)
==2490==    by 0x4235A5: eval (builtin.c:4908)
==2490==    by 0x423996: bin_eval (builtin.c:5017)
==2490==    by 0x410936: execbuiltin (builtin.c:450)
==2490==  Address 0xc22e213 is not stack'd, malloc'd or (recently) free'd

It occurs in A04redirect.ztst.

-- 
Vincent Lefèvre <vincent@vinc17.net> - Web: <http://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <http://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / Arénaire project (LIP, ENS-Lyon)


  reply	other threads:[~2011-05-02  8:08 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-04-28 11:11 Vincent Lefevre
2011-04-28 15:12 ` Bart Schaefer
2011-04-28 22:27   ` Vincent Lefevre
2011-04-29  0:31     ` Vincent Lefevre
2011-04-29  0:59       ` Vincent Lefevre
2011-04-29  1:34         ` Vincent Lefevre
2011-04-29  3:56           ` Bart Schaefer
2011-04-29  8:44             ` Vincent Lefevre
2011-04-29 11:15               ` Vincent Lefevre
2011-05-04  9:33                 ` Vincent Lefevre
2011-04-29 14:20               ` Bart Schaefer
2011-05-02  8:08                 ` Vincent Lefevre [this message]
2011-05-02  8:34                   ` Vincent Lefevre
2011-05-02 11:54                     ` Peter Stephenson

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=20110502080839.GG5625@prunille.vinc17.org \
    --to=vincent@vinc17.net \
    --cc=zsh-workers@zsh.org \
    /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).