sobota, 7 stycznia 2012

Valgrind - "client switching stacks"

If you ever start to receiving following warning from Valgrind:
Warning: client switching stacks?
Followed by many error messages like "Invalid read/write" containing a note: "Address  is on thread 1's stack" then the cause is very simple. You are just allocating too large variables on stack - in my case I had too large array, as local variable, in one of functions. If you can't or don't want to use heap it is possible to tune valgrind with "--max-stackframe" parameter i.e.
valgrind --max-stackframe=10485760 ./a.out
This will prevent false positive detection  of stack switching up to 10MB.

One additional, much more obvious tip, use "-fno-inline" when building C++ binaries for use with valgrind, otherwise there won't be line numbers in stacktraces for any template functions.

Brak komentarzy:

Prześlij komentarz