zsh-workers
 help / color / mirror / code / Atom feed
* Mem leak
@ 1997-06-24  8:52 Andrei Tcherepanov
  1997-06-24 10:26 ` Peter Stephenson
  0 siblings, 1 reply; 2+ messages in thread
From: Andrei Tcherepanov @ 1997-06-24  8:52 UTC (permalink / raw)
  To: zsh Workers Mailing list

[-- Attachment #1: Type: text/plain, Size: 156 bytes --]

hi!

I link zsh (3.1.2 + some patches on jobs.c) with purify 
and found 2 memory leaks

attachment is purify's log


-- 
Thanks,
  Andrei ( tandr@ptc.com )

[-- Attachment #2: zsh.plog --]
[-- Type: text/plain, Size: 10737 bytes --]

****  Purify instrumented ./zsh (pid 11256 at Tue Jun 24 10:27:21 1997)
  * Purify 4.0.1 Solaris 2, Copyright (C) 1992-1996 Pure Atria Corp. All rights reserved. 
  * For contact information type: "purify -help"
  * For TTY output, use the option "-windows=no"
  * Command-line: ./zsh 
  * Options settings: -freeze-on-error=yes -cache-dir=/tmp/purify-cache \
    -chain-length=30 -best-effort -show-directory=yes -purify \
    -purify-home=/ptibig5/pure/purify-4.0.1-solaris2 
PureLA: 2 simple licenses, 10 users.  Please remedy.
  * Purify licensed to Parametric Technology Israel
  * Purify checking enabled.

****  Purify instrumented ./zsh (pid 11256)  ****
UMR: Uninitialized memory read:
  * This is occurring while in:
	tparm          [/usr/ccs/lib/libtermcap.a]
	tcoutarg       [/home/tandr/tmp/zsh-3.1.2/Src/Zle/zle_refresh.c:918]
	tc_rightcurs   [/home/tandr/tmp/zsh-3.1.2/Src/Zle/zle_refresh.c:847]
	moveto         [/home/tandr/tmp/zsh-3.1.2/Src/Zle/zle_refresh.c:813]
	refresh        [/home/tandr/tmp/zsh-3.1.2/Src/Zle/zle_refresh.c:269]
	refresh        [/home/tandr/tmp/zsh-3.1.2/Src/Zle/zle_refresh.c:521]
	zleread        [/home/tandr/tmp/zsh-3.1.2/Src/Zle/zle_main.c:451]
	inputline      [/home/tandr/tmp/zsh-3.1.2/Src/input.c:230]
	ingetc         [/home/tandr/tmp/zsh-3.1.2/Src/input.c:186]
	hgetc          [/home/tandr/tmp/zsh-3.1.2/Src/hist.c:119]
	gettok         [/home/tandr/tmp/zsh-3.1.2/Src/lex.c:418]
	yylex          [/home/tandr/tmp/zsh-3.1.2/Src/lex.c:181]
	parse_event    [/home/tandr/tmp/zsh-3.1.2/Src/parse.c:60]
	loop           [/home/tandr/tmp/zsh-3.1.2/Src/init.c:61]
	main           [/home/tandr/tmp/zsh-3.1.2/Src/main.c:81]
	_start         [/opt/SUNWspro/SC4.0/lib/crt1.o]
  * Reading 4 bytes from 0xefffe368 on the stack.
  * Address 0xefffe368 is 40 bytes below frame pointer in function tparm.

****  Purify instrumented ./zsh (pid 11256)  ****
UMR: Uninitialized memory read:
  * This is occurring while in:
	tparm          [/usr/ccs/lib/libtermcap.a]
	tcoutarg       [/home/tandr/tmp/zsh-3.1.2/Src/Zle/zle_refresh.c:918]
	tc_rightcurs   [/home/tandr/tmp/zsh-3.1.2/Src/Zle/zle_refresh.c:847]
	moveto         [/home/tandr/tmp/zsh-3.1.2/Src/Zle/zle_refresh.c:813]
	refresh        [/home/tandr/tmp/zsh-3.1.2/Src/Zle/zle_refresh.c:500]
	refresh        [/home/tandr/tmp/zsh-3.1.2/Src/Zle/zle_refresh.c:521]
	zleread        [/home/tandr/tmp/zsh-3.1.2/Src/Zle/zle_main.c:451]
	inputline      [/home/tandr/tmp/zsh-3.1.2/Src/input.c:230]
	ingetc         [/home/tandr/tmp/zsh-3.1.2/Src/input.c:186]
	hgetc          [/home/tandr/tmp/zsh-3.1.2/Src/hist.c:119]
	gettok         [/home/tandr/tmp/zsh-3.1.2/Src/lex.c:418]
	yylex          [/home/tandr/tmp/zsh-3.1.2/Src/lex.c:181]
	parse_event    [/home/tandr/tmp/zsh-3.1.2/Src/parse.c:60]
	loop           [/home/tandr/tmp/zsh-3.1.2/Src/init.c:61]
	main           [/home/tandr/tmp/zsh-3.1.2/Src/main.c:81]
	_start         [/opt/SUNWspro/SC4.0/lib/crt1.o]
  * Reading 4 bytes from 0xefffe368 on the stack.
  * Address 0xefffe368 is 40 bytes below frame pointer in function tparm.

****  Purify instrumented ./zsh (pid 11256)  ****
SIG: Signal handled:
  * This is occurring while in:
	_p1062static   [/opt/SUNWspro/SC4.0/lib/crtn.o]
	getkey         [/home/tandr/tmp/zsh-3.1.2/Src/Zle/zle_main.c:265]
	getkeybuf      [/home/tandr/tmp/zsh-3.1.2/Src/Zle/zle_keymap.c:1152]
	getkeymapcmd   [/home/tandr/tmp/zsh-3.1.2/Src/Zle/zle_keymap.c:1119]
	getkeycmd      [/home/tandr/tmp/zsh-3.1.2/Src/Zle/zle_keymap.c:1188]
	zleread        [/home/tandr/tmp/zsh-3.1.2/Src/Zle/zle_main.c:422]
	inputline      [/home/tandr/tmp/zsh-3.1.2/Src/input.c:230]
	ingetc         [/home/tandr/tmp/zsh-3.1.2/Src/input.c:186]
	hgetc          [/home/tandr/tmp/zsh-3.1.2/Src/hist.c:119]
	gettok         [/home/tandr/tmp/zsh-3.1.2/Src/lex.c:418]
	yylex          [/home/tandr/tmp/zsh-3.1.2/Src/lex.c:181]
	parse_event    [/home/tandr/tmp/zsh-3.1.2/Src/parse.c:60]
	loop           [/home/tandr/tmp/zsh-3.1.2/Src/init.c:61]
	main           [/home/tandr/tmp/zsh-3.1.2/Src/main.c:81]
	_start         [/opt/SUNWspro/SC4.0/lib/crt1.o]
  * Received signal 2 (SIGINT - Interrupt)
  * Signal mask: (SIGINT) 
  * Pending signals: 

****  Purify instrumented ./zsh (pid 11256)  ****
Current file descriptors in use: 13
FIU: file descriptor 0: <stdin>
FIU: file descriptor 1: <stdout>
FIU: file descriptor 2: <stderr>
FIU: file descriptor 3: "/etc/.name_service_door", O_RDONLY
   * File info: ?r--r--r--  1 root     root             0 Mar 17 15:57
   * This file descriptor was allocated from:
	open           [/usr/lib/libc.so.1]
	_nsc_trydoorcall [/usr/lib/libc.so.1]
	getpwuid_r     [/usr/lib/libc.so.1]
	setupvals      [/home/tandr/tmp/zsh-3.1.2/Src/init.c:492]
	main           [/home/tandr/tmp/zsh-3.1.2/Src/main.c:72]
	_start         [/opt/SUNWspro/SC4.0/lib/crt1.o]
FIU: file descriptor 4: <inherited from parent>
FIU: file descriptor 5: <inherited from parent>
FIU: file descriptor 6: <inherited from parent>
FIU: file descriptor 7: <inherited from parent>
FIU: file descriptor 8: <inherited from parent>
FIU: file descriptor 10: "/home/tandr/.zaliases", O_RDONLY
   * Duplication of file descriptor 9.
   * File info: crw--w----  1 tandr    tty              0 Jun 24 10:27
   * File position: 205547
   * This file descriptor was allocated from:
	fcntl          [/usr/lib/libc.so.1]
	movefd         [/home/tandr/tmp/zsh-3.1.2/Src/utils.c:820]
	source         [/home/tandr/tmp/zsh-3.1.2/Src/init.c:700]
	bin_dot        [/home/tandr/tmp/zsh-3.1.2/Src/builtin.c:2617]
	execbuiltin    [/home/tandr/tmp/zsh-3.1.2/Src/builtin.c:195]
	execcmd        [/home/tandr/tmp/zsh-3.1.2/Src/exec.c:1698]
	execpline2     [/home/tandr/tmp/zsh-3.1.2/Src/exec.c:808]
	execpline      [/home/tandr/tmp/zsh-3.1.2/Src/exec.c:653]
	execlist       [/home/tandr/tmp/zsh-3.1.2/Src/exec.c:533]
	execif         [/home/tandr/tmp/zsh-3.1.2/Src/loop.c:365]
	execcmd        [/home/tandr/tmp/zsh-3.1.2/Src/exec.c:1651]
	execpline2     [/home/tandr/tmp/zsh-3.1.2/Src/exec.c:808]
	execpline      [/home/tandr/tmp/zsh-3.1.2/Src/exec.c:653]
	execlist       [/home/tandr/tmp/zsh-3.1.2/Src/exec.c:533]
	loop           [/home/tandr/tmp/zsh-3.1.2/Src/init.c:72]
	source         [/home/tandr/tmp/zsh-3.1.2/Src/init.c:722]
	sourcehome     [/home/tandr/tmp/zsh-3.1.2/Src/init.c:759]
	run_init_scripts [/home/tandr/tmp/zsh-3.1.2/Src/init.c:652]
	main           [/home/tandr/tmp/zsh-3.1.2/Src/main.c:76]
	_start         [/opt/SUNWspro/SC4.0/lib/crt1.o]
FIU: file descriptor 11: <unknown>
FIU: file descriptor 26: <reserved for Purify internal use>
FIU: file descriptor 27: <reserved for Purify internal use>

****  Purify instrumented ./zsh (pid 11256)  ****
Purify: Searching for all memory leaks...

Memory leaked: 5002 bytes (3.79%); potentially leaked: 0 bytes (0%)

MLK: 3992 bytes leaked in 124 blocks
  * This memory was allocated from:
	malloc         [/home/tandr/tmp/zsh-3.1.2/Src/rtlib.o]
	zalloc         [/home/tandr/tmp/zsh-3.1.2/Src/mem.c:378]
	listmatches    [/home/tandr/tmp/zsh-3.1.2/Src/Zle/zle_tricky.c:3571]
	refresh        [/home/tandr/tmp/zsh-3.1.2/Src/Zle/zle_refresh.c:519]
	zleread        [/home/tandr/tmp/zsh-3.1.2/Src/Zle/zle_main.c:451]
	inputline      [/home/tandr/tmp/zsh-3.1.2/Src/input.c:230]
	ingetc         [/home/tandr/tmp/zsh-3.1.2/Src/input.c:186]
	hgetc          [/home/tandr/tmp/zsh-3.1.2/Src/hist.c:119]
	gettok         [/home/tandr/tmp/zsh-3.1.2/Src/lex.c:418]
	yylex          [/home/tandr/tmp/zsh-3.1.2/Src/lex.c:181]
	parse_event    [/home/tandr/tmp/zsh-3.1.2/Src/parse.c:60]
	loop           [/home/tandr/tmp/zsh-3.1.2/Src/init.c:61]
	main           [/home/tandr/tmp/zsh-3.1.2/Src/main.c:81]
	_start         [/opt/SUNWspro/SC4.0/lib/crt1.o]
  * Block of 58 bytes at 0x2ce910
  * Block of 41 bytes (2 times); last block at 0x2ff1e0
  * Block of 40 bytes (2 times); last block at 0x2ffb68
  * Block of 39 bytes (2 times); last block at 0x300bd0
  * Block of 38 bytes (6 times); last block at 0x3012c0
  * Block of 37 bytes (4 times); last block at 0x2ffe08
  * Block of 36 bytes (14 times); last block at 0x302088
  * Block of 35 bytes (17 times); last block at 0x302400
  * Block of 34 bytes (8 times); last block at 0x300e70
  * Block of 33 bytes (21 times); last block at 0x302698
  * Block of 32 bytes (11 times); last block at 0x3024e0
  * Block of 31 bytes (8 times); last block at 0x302248
  * Block of 30 bytes (5 times); last block at 0x3019a0
  * Block of 29 bytes (10 times); last block at 0x301b58
  * Block of 28 bytes (3 times); last block at 0x3011e8
  * Block of 15 bytes (4 times); last block at 0x2cd698
  * Block of 13 bytes (2 times); last block at 0x2cd3e8
  * Block of 12 bytes (3 times); last block at 0x2cd828
  * Block of 8 bytes at 0x2a6ef8

MLK: 1010 bytes leaked in 2 blocks
  * This memory was allocated from:
	malloc         [/home/tandr/tmp/zsh-3.1.2/Src/rtlib.o]
	zalloc         [/home/tandr/tmp/zsh-3.1.2/Src/mem.c:378]
	metafy         [/home/tandr/tmp/zsh-3.1.2/Src/utils.c:2655]
	createparamtable [/home/tandr/tmp/zsh-3.1.2/Src/params.c:116]
	setupvals      [/home/tandr/tmp/zsh-3.1.2/Src/init.c:520]
	main           [/home/tandr/tmp/zsh-3.1.2/Src/main.c:72]
	_start         [/opt/SUNWspro/SC4.0/lib/crt1.o]
  * Block of 693 bytes at 0x2114f8
  * Block of 317 bytes at 0x217c70

Purify Heap Analysis (combining suppressed and unsuppressed blocks)
                         Blocks      Bytes
              Leaked        126       5002
  Potentially Leaked          0          0
              In-Use       4589     126875
  ----------------------------------------
     Total Allocated       4715     131877

****  Purify instrumented ./zsh (pid 11256)  ****
  * Program exited with status code 0.
  * 3 access errors, 3 total occurrences.
  * 5002 bytes leaked.
  * 0 bytes potentially leaked.
  * Basic memory usage (including Purify overhead):
     1742356 code
      170460 data/bss
     1114112 heap (peak use)
        6856 stack
  * Shared library memory usage (including Purify overhead):
      610562 libnsl.so.1_pure_p3_c0_401_55 (shared code)
       64764 libnsl.so.1_pure_p3_c0_401_55 (private data)
      802467 libc.so.1_pure_p3_c0_401_55 (shared code)
       33636 libc.so.1_pure_p3_c0_401_55 (private data)
        1200 libdl.so.1_pure_p3_c0_401_55 (shared code)
           0 libdl.so.1_pure_p3_c0_401_55 (private data)
        2729 libinternal_stubs.so.1 (shared code)
         208 libinternal_stubs.so.1 (private data)
       14029 libintl.so.1_pure_p3_c0_401_55 (shared code)
        3680 libintl.so.1_pure_p3_c0_401_55 (private data)
       16088 libmp.so.1_pure_p3_c0_401_55 (shared code)
         828 libmp.so.1_pure_p3_c0_401_55 (private data)
       37341 libw.so.1_pure_p3_c0_401_55 (shared code)
        1612 libw.so.1_pure_p3_c0_401_55 (private data)


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

* Re: Mem leak
  1997-06-24  8:52 Mem leak Andrei Tcherepanov
@ 1997-06-24 10:26 ` Peter Stephenson
  0 siblings, 0 replies; 2+ messages in thread
From: Peter Stephenson @ 1997-06-24 10:26 UTC (permalink / raw)
  To: Andrei Tcherepanov, zsh-workers

Andrei Tcherepanov wrote:
> I link zsh (3.1.2 + some patches on jobs.c) with purify 
> and found 2 memory leaks
...
> PureLA: 2 simple licenses, 10 users.  Please remedy.

i think i'll leave this one...

> MLK: 3992 bytes leaked in 124 blocks
>   * This memory was allocated from:
> 	malloc         [/home/tandr/tmp/zsh-3.1.2/Src/rtlib.o]
> 	zalloc         [/home/tandr/tmp/zsh-3.1.2/Src/mem.c:378]
> 	listmatches    [/home/tandr/tmp/zsh-3.1.2/Src/Zle/zle_tricky.c:3571]

This is actually a call to ncalloc(), which could be set to either
heap or permanent allocation.  Looking at the code, I think it's
always supposed to allocate memory from the stack here.

> MLK: 1010 bytes leaked in 2 blocks
>   * This memory was allocated from:
> 	malloc         [/home/tandr/tmp/zsh-3.1.2/Src/rtlib.o]
> 	zalloc         [/home/tandr/tmp/zsh-3.1.2/Src/mem.c:378]
> 	metafy         [/home/tandr/tmp/zsh-3.1.2/Src/utils.c:2655]
> 	createparamtable [/home/tandr/tmp/zsh-3.1.2/Src/params.c:116]

This is where environment variables are assigned to internal
parameters.  It could be the leaky values were of arrays of some sort,
since they're 693 and 317 bytes.  My guess is that they are PATH and
some friend of its: colonarrsetfn() is called in exactly the same
circumstances as any other function for setting a string, but unlike
the normal case doesn't remember the value passed, so should delete
it.  I've confirmed the leak with `repeat 100 PATH=$PATH':  before, I
was repeatedly gaining 6 to 10kb, after the patch, I'm not.  This was
potentially a nasty one, just as well someone found it.

I can't necessarily vouch for the other parameter setting functions,
either.

*** Src/Zle/zle_tricky.c.leak	Sun Jun  1 08:42:50 1997
--- Src/Zle/zle_tricky.c	Tue Jun 24 11:35:11 1997
***************
*** 3567,3574 ****
  		    nicezputs(*ap, shout);
  		    nicezputs(fsuf, shout);
  		    t2 = nfpl + niceztrlen(*ap) + nfsl;
! 		    pb = (char *) ncalloc((prpre ? strlen(prpre) : 0) + 3 +
! 					  strlen(fpre) + strlen(*ap) + strlen(fsuf));
  		    sprintf(pb, "%s%s%s%s",
  			    (prpre && *prpre) ? prpre : "./", fpre, *ap, fsuf);
  		}
--- 3567,3574 ----
  		    nicezputs(*ap, shout);
  		    nicezputs(fsuf, shout);
  		    t2 = nfpl + niceztrlen(*ap) + nfsl;
! 		    pb = (char *) halloc((prpre ? strlen(prpre) : 0) + 3 +
! 					 strlen(fpre) + strlen(*ap) + strlen(fsuf));
  		    sprintf(pb, "%s%s%s%s",
  			    (prpre && *prpre) ? prpre : "./", fpre, *ap, fsuf);
  		}
*** Src/params.c.leak	Tue Jun  3 07:58:29 1997
--- Src/params.c	Tue Jun 24 12:13:44 1997
***************
*** 1350,1355 ****
--- 1350,1356 ----
      *dptr = x ? colonsplit(x, pm->flags & PM_UNIQUE) : mkarray(NULL);
      if (pm->ename)
  	arrfixenv(pm->nam, *dptr);
+     zsfree(x);
  }
  
  /**/

-- 
Peter Stephenson <pws@ifh.de>       Tel: +49 33762 77366
WWW:  http://www.ifh.de/~pws/       Fax: +49 33762 77413
Deutsches Elektronen-Synchrotron --- Institut fuer Hochenergiephysik Zeuthen
DESY-IfH, 15735 Zeuthen, Germany.


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

end of thread, other threads:[~1997-06-24 10:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-06-24  8:52 Mem leak Andrei Tcherepanov
1997-06-24 10:26 ` Peter Stephenson

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