zsh-workers
 help / color / mirror / code / Atom feed
From: Peter Stephenson <pws@csr.com>
To: zw <zsh-workers@sunsite.dk>
Subject: Re: result of latest memory leak run
Date: Mon, 19 May 2003 11:09:36 +0100	[thread overview]
Message-ID: <27603.1053338976@csr.com> (raw)
In-Reply-To: "Felix Rosencrantz"'s message of "Fri, 16 May 2003 20:53:24 PDT." <20030517035324.8254.qmail@web10406.mail.yahoo.com>

Felix Rosencrantz wrote:
> I ran the latest cvs version of zsh with valgrind in my environment as
> my main shell for a few days.    I was only able to find one memory
> leak, I believe based on the recent fix for (l=() ; vared l):  
> ==21338== 520 bytes in 3 blocks are definitely lost in loss record 9 of 14
> ==21338==    at 0x401667E0: malloc (vg_clientfuncs.c:103)
> ==21338==    by 0x8086AF5: zalloc (mem.c:490)
> ==21338==    by 0x81008E9: zleread (zle_main.c:790)
> ==21338==    by 0x8101D07: bin_vared (zle_main.c:1149)
> ==21338==    by 0x804B2F5: execbuiltin (builtin.c:440)
> ==21338==    by 0x806193A: execcmd (exec.c:2345)
> ==21338==    by 0x805E24E: execpline2 (exec.c:1228)
> ==21338==    by 0x805D776: execpline (exec.c:1018)

Actually, it's older; any vared of an array will leak the string since
spacesplit() doesn't free it.  I think this may explain some of your
previous leaks, so it's good to chase it down.

The fact there's a comment but it's already inaccurate suggests I was
working here.

I think a test-3 is probably warranted.  There's no point rushing things
now.

Index: Src/Zle/zle_main.c
===================================================================
RCS file: /cvsroot/zsh/zsh/Src/Zle/zle_main.c,v
retrieving revision 1.32
diff -u -r1.32 zle_main.c
--- Src/Zle/zle_main.c	14 May 2003 15:09:15 -0000	1.32
+++ Src/Zle/zle_main.c	19 May 2003 09:59:52 -0000
@@ -1177,9 +1177,10 @@
 
 	/*
 	 * Use spacesplit with fourth argument 1: identify quoted separators,
-	 * unquote but don't split.
+	 * and unquote.  This duplicates the string, so we still need to free.
 	 */
 	a = spacesplit(t, 1, 0, 1);
+	zsfree(t);
 	if (PM_TYPE(pm->flags) == PM_ARRAY)
 	    setaparam(args[0], a);
 	else

-- 
Peter Stephenson <pws@csr.com>                  Software Engineer
CSR Ltd., Science Park, Milton Road,
Cambridge, CB4 0WH, UK                          Tel: +44 (0)1223 692070


**********************************************************************
The information transmitted is intended only for the person or
entity to which it is addressed and may contain confidential 
and/or privileged material. 
Any review, retransmission, dissemination or other use of, or
taking of any action in reliance upon, this information by 
persons or entities other than the intended recipient is 
prohibited.  
If you received this in error, please contact the sender and 
delete the material from any computer.
**********************************************************************


      reply	other threads:[~2003-05-19 10:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-17  3:53 Felix Rosencrantz
2003-05-19 10:09 ` Peter Stephenson [this message]

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=27603.1053338976@csr.com \
    --to=pws@csr.com \
    --cc=zsh-workers@sunsite.dk \
    /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).