zsh-workers
 help / color / mirror / code / Atom feed
* valgrind: useful memory checker
@ 2002-04-22 18:20 Felix Rosencrantz
  2002-04-22 18:32 ` Bart Schaefer
  2002-04-24  7:56 ` Sven Wischnowsky
  0 siblings, 2 replies; 6+ messages in thread
From: Felix Rosencrantz @ 2002-04-22 18:20 UTC (permalink / raw)
  To: zsh-workers; +Cc: Julian Seward

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/


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

end of thread, other threads:[~2002-04-26  6:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-04-22 18:20 valgrind: useful memory checker Felix Rosencrantz
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

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