zsh-workers
 help / color / mirror / code / Atom feed
From: Felix Rosencrantz <f_rosencrantz@yahoo.com>
To: zsh-workers <zsh-workers@sunsite.auc.dk>
Cc: Julian Seward <jseward@acm.org>
Subject: valgrind: useful memory checker
Date: Mon, 22 Apr 2002 11:20:26 -0700 (PDT)	[thread overview]
Message-ID: <20020422182026.19547.qmail@web10401.mail.yahoo.com> (raw)

There is a new memory debugger available for Linux x86. According to the
web page(http://developer.kde.org/~sewardj/)  it can track such things as:

	- Use of uninitialised memory 
	- Reading/writing memory after it has been free'd 
	- Reading/writing off the end of malloc'd blocks 
	- Reading/writing inappropriate areas on the stack 
	- Memory leaks -- where pointers to malloc'd blocks are lost forever 
	- Passing of uninitialised and/or unaddressable memory to system calls 
	- Mismatched use of malloc/new/new [] vs free/delete/delete [] 

It is used as an aid to debug memory problems with KDE.  This useful
tool is written by Julian Seward.  It's very easy to start using.

I tried using it with Z-shell.  But initially there were some
problems, but Julian was able to fix these.   One of the problems
was that zsh calls malloc() during signal handlers.  Which Julian
pointed out is not a particularly safe thing to do....  (I figure
Bart or others might comment about this.)

Though, the latest version of valgrind in CVS seems to work with
ZSH.

Attached is a completion function for valgrind.  I'm not sure which
directory to place it in, possibly RedHat or Unix, though it is
intended to work with Linux x86.

Also, I ran valgrind on zsh interactively for a little bit, did
some completions and found a couple leaks.  Of course, adding valgrind
to the automated tests would be quite useful.

-FR.
==3725== 80 bytes in 1 blocks are definitely lost in loss record 45 of 136
==3725==    at 0x808C516: zalloc (in /bin/linux/zsh-020416d/bin/zsh)
==3725==    by 0x80A3010: patcompile (in /bin/linux/zsh-020416d/bin/zsh)
==3725==    by 0x413C4011: bin_zstyle (in
/bin/linux/zsh-020416d/lib/zsh/4.1.0-dev-4-020416/zsh/zutil.so)
==3725==    by 0x8052425: execbuiltin (in /bin/linux/zsh-020416d/bin/zsh)
==3725==    by 0x8067E93: execcmd (in /bin/linux/zsh-020416d/bin/zsh)
==3725==    by 0x806484B: execpline2 (in /bin/linux/zsh-020416d/bin/zsh)
==3725==    by 0x8063DDF: execpline (in /bin/linux/zsh-020416d/bin/zsh)
==3725==    by 0x80637D3: execlist (in /bin/linux/zsh-020416d/bin/zsh)
==3725== 
==3725== 132 bytes in 33 blocks are definitely lost in loss record 62 of 136
==3725==    at 0x808C516: zalloc (in /bin/linux/zsh-020416d/bin/zsh)
==3725==    by 0x80B9DE2: zarrdup (in /bin/linux/zsh-020416d/bin/zsh)
==3725==    by 0x411EC6D4: comp_wrapper (in
/bin/linux/zsh-020416d/lib/zsh/4.1.0-dev-4-020416/zsh/complete.so)
==3725==    by 0x806AB53: runshfunc (in /bin/linux/zsh-020416d/bin/zsh)
==3725==    by 0x806A973: doshfunc (in /bin/linux/zsh-020416d/bin/zsh)
==3725==    by 0x806A33C: execshfunc (in /bin/linux/zsh-020416d/bin/zsh)
==3725==    by 0x8067E09: execcmd (in /bin/linux/zsh-020416d/bin/zsh)
==3725==    by 0x806484B: execpline2 (in /bin/linux/zsh-020416d/bin/zsh)
==3725== 

#compdef valgrind 
#Generated by
#   simple2long.xsl
#   args.xsl
#   For details see:
#       http://www.geocities.com/f_rosencrantz/xml_completion.htm

 local context state line
           typeset -A opt_args
	_arguments   \
		'--help[show this message]' \
		'--version[show version]' \
		'(--quiet)-q[run silently; only print error msgs]' \
		'(-q)--quiet[run silently; only print error msgs]' \
		'(--verbose)-v[be more verbose, incl counts of errors]' \
		'(-v)--verbose[be more verbose, incl counts of errors]' \
		'--gdb-attach=-:start GDB when errors detected? [no]:(no yes)' \
		'--demangle=-:automatically demangle C++ names? [yes]:(no yes)' \
		'--num-callers=-:show  callers in stack traces [4]:->number' \
		'--partial-loads-ok=-:too hard to explain here; see manual [yes]:(no yes)' \
		'--leak-check=-:search for memory leaks at exit? [no]:(no yes)' \
		'--leak-resolution=-:amount of bt merging in leak check [low]:(low med high)'
\
		'--show-reachable=-:show reachable blocks in leak check? [no]:(no yes)' \
		'--sloppy-malloc=-:round malloc sizes to next word? [no]:(no yes)' \
		'--trace-children=-:Valgrind-ise child processes? [no]:(no yes)' \
		'--logfile-fd=-:file descriptor for messages [2=stderr]:->number' \
		'--freelist-vol=-:volume of freed blocks queue [1000000]:->number' \
		'--workaround-gcc296-bugs=-:self explanatory [no]:(no yes)' \
		'--suppressions=-:suppress errors described in suppressions file :_files' \
		'--client-perms=-:handle client VG_MAKE_* requests? [no]:(no yes)' \
		"--check-addrVs=-:experimental lighterweight checking? [yes] yes ==
Valgrind's original behaviour:(no yes)" \
		'--sanity-level=-:level of sanity checking to do [1]:->number' \
		'--single-step=-:translate each instr separately? [no]:(no yes)' \
		'--optimise=-:improve intermediate code? [yes]:(no yes)' \
		'--instrument=-:actually do memory checks? [yes]:(no yes)' \
		'--cleanup=-:improve after instrumentation? [yes]:(no yes)' \
		'--trace-syscalls=-:show all system calls? [no]:(no yes)' \
		'--trace-signals=-:show signal handling details? [no]:(no yes)' \
		'--trace-symtab=-:show symbol table details? [no]:(no yes)' \
		'--trace-malloc=-:show client malloc details? [no]:(no yes)' \
		'--trace-sched=-:show thread scheduler details? [no]:(no yes)' \
		'--trace-pthread=-:show pthread event details? [no]:(no yes)' \
		'--stop-after=-:switch to real CPU after executing  basic blocks
[infinity]:->number' \
		"--dump-error=-:show translation for basic block associated with 'th error
context [0=don't show any]:->number" \
		'1: :_command_names -e' \
		'*:: :_normal' \
           && return 0
            
case $state in
  "number");;
esac


__________________________________________________
Do You Yahoo!?
Yahoo! Games - play chess, backgammon, pool and more
http://games.yahoo.com/


             reply	other threads:[~2002-04-22 18:20 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-22 18:20 Felix Rosencrantz [this message]
2002-04-22 18:32 ` Bart Schaefer
2002-04-22 22:10   ` Julian Seward
2002-04-24  7:56 ` Sven Wischnowsky
2002-04-25  5:27   ` Felix Rosencrantz
2002-04-26  6:00     ` Felix Rosencrantz

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=20020422182026.19547.qmail@web10401.mail.yahoo.com \
    --to=f_rosencrantz@yahoo.com \
    --cc=jseward@acm.org \
    --cc=zsh-workers@sunsite.auc.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).