zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <p.w.stephenson@ntlworld.com>
To: "Johan Ström" <johan@stromnet.se>, zsh-workers@zsh.org
Subject: Re: "crash: free invalid next size (fast)" on completion
Date: Thu, 24 Mar 2022 10:47:56 +0000 (GMT)	[thread overview]
Message-ID: <1950010726.626226.1648118876781@mail2.virginmedia.com> (raw)
In-Reply-To: <87c0f1d5-84cb-e459-7009-aff69da3bdb8@stromnet.se>

> On 24 March 2022 at 10:12 Johan Ström <johan@stromnet.se> wrote:
> Launched one now. Quickly noticed this:
> 
> 1. Execute ls
> 2. Use up-arrow, triggers warning:
>   ==2157023== Invalid read of size 32
> ==2157023==    at 0x4B7709D: __wmemcmp_avx2_movbe (in /usr/lib/libc.so.6)
> ==2157023==    by 0x5863FDC: mkundoent (in /usr/lib/zsh/5.8.1/zsh/zle.so)
>...
> ==2157023==  Address 0x5c2de50 is 0 bytes inside a block of size 8 alloc'd
> ==2157023==    at 0x484ACD3: realloc (in 
> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
> ==2157023==    by 0x586404F: setlastline (in /usr/lib/zsh/5.8.1/zsh/zle.so)

From circumstantial evidence, I'm guessing that might go away with the following?
Unless there's some reason lastlinesz would not be as long as the allocation of
lastline, it's hard to see how this could be wrong (famous last words).

pws

diff --git a/Src/Zle/zle_utils.c b/Src/Zle/zle_utils.c
index c85f8450d..526216fa7 100644
--- a/Src/Zle/zle_utils.c
+++ b/Src/Zle/zle_utils.c
@@ -1530,7 +1530,7 @@ mkundoent(void)
     struct change *ch;
 
     UNMETACHECK();
-    if(lastll == zlell && !ZS_memcmp(lastline, zleline, zlell)) {
+    if(lastll == zlell && lastlinesz >= zlell && !ZS_memcmp(lastline, zleline, zlell)) {
 	lastcs = zlecs;
 	return;
     }


  reply	other threads:[~2022-03-24 10:48 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <df2ea61b-d0ea-ba95-98e0-d0fe84b800d0@stromnet.se>
     [not found] ` <CAH+w=7Yn_jyvHiOtpMAmq8rFESM16LgEdzgGx7t0E+c2ctS1fg@mail.gmail.com>
2022-03-24  7:31   ` Johan Ström
2022-03-24  9:58     ` Peter Stephenson
2022-03-24 10:12       ` Johan Ström
2022-03-24 10:47         ` Peter Stephenson [this message]
2022-03-31 17:17           ` Jun. T
2022-03-31 22:07             ` Bart Schaefer

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=1950010726.626226.1648118876781@mail2.virginmedia.com \
    --to=p.w.stephenson@ntlworld.com \
    --cc=johan@stromnet.se \
    --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).