From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 15842 invoked from network); 22 Apr 2002 18:20:42 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 22 Apr 2002 18:20:42 -0000 Received: (qmail 28200 invoked by alias); 22 Apr 2002 18:20:33 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 17021 Received: (qmail 28181 invoked from network); 22 Apr 2002 18:20:30 -0000 Message-ID: <20020422182026.19547.qmail@web10401.mail.yahoo.com> Date: Mon, 22 Apr 2002 11:20:26 -0700 (PDT) From: Felix Rosencrantz Subject: valgrind: useful memory checker To: zsh-workers Cc: Julian Seward MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii 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/