SlideShare ist ein Scribd-Unternehmen logo
1 von 45
Downloaden Sie, um offline zu lesen
Valgrind overview:
Runtime memory checker and a bit more...
What can we do with it?
Sergei Trofimovich – slyfox@gentoo.org
MLUG
Mar 30, 2013
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
The problem
When do we start thinking of weird bug in a program?
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
The problem
When do we start thinking of weird bug in a program?
the output is a random garbage
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
The problem
When do we start thinking of weird bug in a program?
the output is a random garbage
random SIGSEGVs
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
The problem
When do we start thinking of weird bug in a program?
the output is a random garbage
random SIGSEGVs
abort() messages showing ”double free()” corruption
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Introduction
Meet the valgrind:
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Introduction
Meet the valgrind:
a commandline tool
$ valgrind program [args...]
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Introduction
Meet the valgrind:
a commandline tool
$ valgrind program [args...]
to search bugs in binary applications
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Introduction
Meet the valgrind:
a commandline tool
$ valgrind program [args...]
to search bugs in binary applications
which contain C/C++ code
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Introduction
Meet the valgrind:
a commandline tool
$ valgrind program [args...]
to search bugs in binary applications
which contain C/C++ code
not scripts or bytecode
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Introduction
Meet the valgrind:
a commandline tool
$ valgrind program [args...]
to search bugs in binary applications
which contain C/C++ code
not scripts or bytecode
Author: Julian Seward
compiler writer
bzip2
works on current Mozilla’s JavaScript engines
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
First example: no errors
simple.c
1 int main() {
2 return 0;
3 }
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
First example: no errors
run-simple.sh
make simple CFLAGS=-g
valgrind ./simple # to stderr
valgrind --log-file=simple.vglog ./simple # to log
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
First example: no errors
simple.vglog
==14290== Memcheck, a memory error detector
==14290== Copyright (C) 2002-2012, and GNU GPL’d, by Julian Seward et al.
==14290== Using Valgrind-3.9.0.SVN and LibVEX; rerun with -h for copyright info
==14290== Command: ./simple
==14290== Parent PID: 14287
==14290==
==14290==
==14290== HEAP SUMMARY:
==14290== in use at exit: 0 bytes in 0 blocks
==14290== total heap usage: 0 allocs, 0 frees, 0 bytes allocated
==14290==
==14290== All heap blocks were freed -- no leaks are possible
==14290==
==14290== For counts of detected and suppressed errors, rerun with: -v
==14290== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2)
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Simple leak
01-leaky.c
1 #include <stdlib.h> /* malloc(), free() */
2 void * leaky() {
3 return malloc (42);
4 }
5 int main() {
6 free ((leaky(), leaky()));
7 return 0;
8 }
9
10 // check as: valgrind --show-reachable=yes 
11 // --leak-check=full 
12 // --track-origins=yes 
13 // --quiet
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Simple leak
01-leaky.vglog
==14293== 42 bytes in 1 blocks are definitely lost in loss record 1 of 1
==14293== at 0x4C2C1DB: malloc (vg_replace_malloc.c:270)
==14293== by 0x4005C9: leaky (01-leaky.c:3)
==14293== by 0x4005D9: main (01-leaky.c:6)
==14293==
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Use of uninitialized memory
02-uninit.c
1 int use_uninit (char * uninit) {
2 if (*uninit > 42) /* oh, what will happen ? */
3 return 24;
4 else
5 return 42;
6 }
7 int foo (void) {
8 char garbage;
9 use_uninit (&garbage);
10 }
11 int main() {
12 return foo ();
13 }
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Use of uninitialized memory
02-uninit.vglog
==14297== Conditional jump or move depends on uninitialised value(s)
==14297== at 0x40052D: use_uninit (02-uninit.c:2)
==14297== by 0x400550: foo (02-uninit.c:9)
==14297== by 0x40055B: main (02-uninit.c:12)
==14297== Uninitialised value was created by a stack allocation
==14297== at 0x40053D: foo (02-uninit.c:7)
==14297==
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Out of bounds access
03-oob.c
1 #include <stdlib.h> /* malloc(), free() */
2
3 int main() {
4 char * p = (char *) malloc (32);
5 *(p + 32 + 129) = ’0’; /* whoops */
6 free (p);
7 return 0;
8 }
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Out of bounds access
03-oob.vglog
==14302== Invalid write of size 1
==14302== at 0x4005DC: main (03-oob.c:5)
==14302== Address 0x51d80e1 is not stack’d, malloc’d or (recently) free’d
==14302==
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Helping valgrind
Sometimes compiler optimizations make the final code a complete
mess. Here is some tips to make valgrind logs more readable:
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Helping valgrind
Sometimes compiler optimizations make the final code a complete
mess. Here is some tips to make valgrind logs more readable:
build your programs/libraries with -g compiler options to emit
DWARF debugging symbols (./configure CFLAGS=-g
CXXFLAGS=-g)
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Helping valgrind
Sometimes compiler optimizations make the final code a complete
mess. Here is some tips to make valgrind logs more readable:
build your programs/libraries with -g compiler options to emit
DWARF debugging symbols (./configure CFLAGS=-g
CXXFLAGS=-g)
or install debugging symbols for them (if exist)
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Helping valgrind
Sometimes compiler optimizations make the final code a complete
mess. Here is some tips to make valgrind logs more readable:
build your programs/libraries with -g compiler options to emit
DWARF debugging symbols (./configure CFLAGS=-g
CXXFLAGS=-g)
or install debugging symbols for them (if exist)
do not overoptimize things:
-O2 optimization reorders and inlines too much code
-O1 is usually good-enough
-O0 is likely too slow
-Og (gcc-4.8 feature) sounds promising
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Helping valgrind
Sometimes compiler optimizations make the final code a complete
mess. Here is some tips to make valgrind logs more readable:
build your programs/libraries with -g compiler options to emit
DWARF debugging symbols (./configure CFLAGS=-g
CXXFLAGS=-g)
or install debugging symbols for them (if exist)
do not overoptimize things:
-O2 optimization reorders and inlines too much code
-O1 is usually good-enough
-O0 is likely too slow
-Og (gcc-4.8 feature) sounds promising
-fno-builtin is your friend as valgrind can detect more bugs in
mem*() and str*() functions.
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Helping valgrind: user’s assistance
You can guide valgrind through the source code and tell him the
facts about the program he does not know.
There is a mechanism for it: /usr/include/valgrind/*.h
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Helping valgrind: an example
04-helpy-uninit.c
1 static char tb[32];
2 char * get_temp_buffer () {
3 return tb;
4 }
5 void free_temp_buffer (char * b) { /* superoptimization! */ }
6 int user1 (char * b) {
7 memset (b, 32, ’A’);
8 return b[7]; /* a lot of hard work on ’b’ */
9 }
10 int user2 (char * b) {
11 /* we forgot this: memset (b, 32, ’B’); */
12 return b[7]; /* a lot of hard work on ’b’ */
13 }
14 int main() {
15 char * b; int r1, r2;
16
17 b = get_temp_buffer(); r1 = user1 (b); free_temp_buffer (b);
18 b = get_temp_buffer(); r2 = user2 (b); free_temp_buffer (b);
19 return r1 + r2;
20 }
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Helping valgrind: an example
04-helpy-uninit.vglog
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Helping valgrind: an example
04-helpy-uninit-2.c
1 #include <valgrind/memcheck.h>
2 static char tb[32];
3 char * get_temp_buffer () {
4 VALGRIND_MAKE_MEM_UNDEFINED(tb, 32);
5 return tb;
6 }
7 void free_temp_buffer (char * b) { /* superoptimization! */ }
8 int user1 (char * b) {
9 memset (b, 32, ’A’);
10 return b[7]; /* a lot of hard work on ’b’ */
11 }
12 int user2 (char * b) {
13 /* we forgot this: memset (b, 32, ’B’); */
14 return b[7]; /* a lot of hard work on ’b’ */
15 }
16 int main() {
17 char * b; int r1, r2;
18
19 b = get_temp_buffer(); r1 = user1 (b); free_temp_buffer (b);
20 b = get_temp_buffer(); r2 = user2 (b); free_temp_buffer (b);
21 return r1 + r2;
22 }
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Helping valgrind: an example
04-helpy-uninit-2.vglog
==14306== Syscall param exit_group(status) contains uninitialised byte(s)
==14306== at 0x4EEAA79: _Exit (_exit.c:32)
==14306== by 0x4E6BC6F: __run_exit_handlers (exit.c:92)
==14306== by 0x4E6BC94: exit (exit.c:99)
==14306== by 0x4E5576B: (below main) (libc-start.c:257)
==14306== Uninitialised value was created by a client request
==14306== at 0x4007F4: get_temp_buffer (04-helpy-uninit-2.c:4)
==14306== by 0x400894: main (04-helpy-uninit-2.c:20)
==14306==
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
More APIs to plug into your code
valgrind-APIs.h
1 /* valgrind/memcheck.h */
2 VALGRIND_MAKE_MEM_NOACCESS(_qzz_addr,_qzz_len)
3 VALGRIND_MAKE_MEM_UNDEFINED(_qzz_addr,_qzz_len)
4 VALGRIND_MAKE_MEM_DEFINED(_qzz_addr,_qzz_len)
5 VALGRIND_CREATE_BLOCK(_qzz_addr,_qzz_len, _qzz_desc)
6 VALGRIND_CHECK_MEM_IS_ADDRESSABLE(_qzz_addr,_qzz_len)
7 VALGRIND_CHECK_MEM_IS_DEFINED(_qzz_addr,_qzz_len)
8 VALGRIND_CHECK_VALUE_IS_DEFINED(__lvalue)
9 VALGRIND_COUNT_LEAKS(leaked, dubious, reachable, suppressed)
10 /* valgrind/valgrind.h */
11 RUNNING_ON_VALGRIND
12 VALGRIND_DISCARD_TRANSLATIONS(_qzz_addr,_qzz_len)
13 VALGRIND_NON_SIMD_CALL0(_qyy_fn)
14 VALGRIND_NON_SIMD_CALL1(_qyy_fn, _qyy_arg1)
15 ...
16 VALGRIND_MALLOCLIKE_BLOCK(addr, sizeB, rzB, is_zeroed)
17 VALGRIND_FREELIKE_BLOCK(addr, rzB)
18 VALGRIND_CREATE_MEMPOOL(pool, rzB, is_zeroed)
19 VALGRIND_DESTROY_MEMPOOL(pool)
20 VALGRIND_MEMPOOL_ALLOC(pool, addr, size)
21 VALGRIND_MEMPOOL_FREE(pool, addr)
22 ...
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Bugs in the wild
Recently found bugs:
cvsps: invalid handling of external modules
btrfs-progs: invalid checksums for built data
cvs: massive memory leak on long sessions
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Magic!
What a great tool!
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Or not?
Well... there is something I
have hidden from you.
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Generic instrumentation framework
How does valgrind work internally?
userspace JIT compiler with full CPU emulation (just like
qemu in binary translation mode)
uses VEX library to decoding guest code CPU instructions and
assembling host code
uses coregrind library to emulate operating system syscalls
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Portability
As valgrind goes down to syscall instructions it needs to know the
syscall ABI, signal ABI, etc. of host and guest (emulated) OSes.
Thus valgrind:
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Portability
As valgrind goes down to syscall instructions it needs to know the
syscall ABI, signal ABI, etc. of host and guest (emulated) OSes.
Thus valgrind:
won’t work on windows in it’s current form as there is no
documented syscall ABI.
But!
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Portability
As valgrind goes down to syscall instructions it needs to know the
syscall ABI, signal ABI, etc. of host and guest (emulated) OSes.
Thus valgrind:
won’t work on windows in it’s current form as there is no
documented syscall ABI.
But! There is some gross hacks to run wine under valgrind to
unstrument PE files. Scary :]
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Portability
As valgrind goes down to syscall instructions it needs to know the
syscall ABI, signal ABI, etc. of host and guest (emulated) OSes.
Thus valgrind:
won’t work on windows in it’s current form as there is no
documented syscall ABI.
But! There is some gross hacks to run wine under valgrind to
unstrument PE files. Scary :]
works poorly on rare OSen (like various BSDs), but it’s a
matter of adding some syscall effect definition (some lines of
code to valgrind/coregrind/m syswrap/*). Worth looking at
valgrind-freebsd.
ported to relatively popular CPU architectures:
IA-32 (i386)
AMD64
ARM
PPC (PPC64)
S390X
MIPS
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Other tools
By default valgrind runs the memcheck tool (valgrind
–tool=memcheck).
VEX + coregrind is quite generic framework for runtimes
exploration. Other tools shipped with valgrind are:
none - does nothing (useful to measure emulation overlead)
memcheck - default tool to check for common memory errors
helgrind - data race detection tool for multithreaded apps
using POSIX threads for synchronization
drd - another data race detector
cachegrind - l2 cache hit/miss profiler
callgrind - function call and instruction cost profiler
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Other tools: callgrind
An example callgraph of
valgrind —-tool=callgrind ls
is...
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Thank you!
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
Any questions?
Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more

Weitere ähnliche Inhalte

Was ist angesagt?

100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects 100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects Andrey Karpov
 
Heading for a Record: Chromium, the 5th Check
Heading for a Record: Chromium, the 5th CheckHeading for a Record: Chromium, the 5th Check
Heading for a Record: Chromium, the 5th CheckPVS-Studio
 
PVS-Studio for Linux (CoreHard presentation)
PVS-Studio for Linux (CoreHard presentation)PVS-Studio for Linux (CoreHard presentation)
PVS-Studio for Linux (CoreHard presentation)Andrey Karpov
 
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against itEvgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against itSergey Platonov
 
Дмитрий Демчук. Кроссплатформенный краш-репорт
Дмитрий Демчук. Кроссплатформенный краш-репортДмитрий Демчук. Кроссплатформенный краш-репорт
Дмитрий Демчук. Кроссплатформенный краш-репортSergey Platonov
 
"Why is there no artificial intelligence yet?" Or, analysis of CNTK tool kit ...
"Why is there no artificial intelligence yet?" Or, analysis of CNTK tool kit ..."Why is there no artificial intelligence yet?" Or, analysis of CNTK tool kit ...
"Why is there no artificial intelligence yet?" Or, analysis of CNTK tool kit ...PVS-Studio
 
Checking Intel IPP Samples for Windows - Continuation
Checking Intel IPP Samples for Windows - ContinuationChecking Intel IPP Samples for Windows - Continuation
Checking Intel IPP Samples for Windows - ContinuationPVS-Studio
 
A Check of the Open-Source Project WinSCP Developed in Embarcadero C++ Builder
A Check of the Open-Source Project WinSCP Developed in Embarcadero C++ BuilderA Check of the Open-Source Project WinSCP Developed in Embarcadero C++ Builder
A Check of the Open-Source Project WinSCP Developed in Embarcadero C++ BuilderAndrey Karpov
 
Top 10 bugs in C++ open source projects, checked in 2016
Top 10 bugs in C++ open source projects, checked in 2016Top 10 bugs in C++ open source projects, checked in 2016
Top 10 bugs in C++ open source projects, checked in 2016PVS-Studio
 
(Slightly) Smarter Smart Pointers
(Slightly) Smarter Smart Pointers(Slightly) Smarter Smart Pointers
(Slightly) Smarter Smart PointersCarlo Pescio
 
Linux version of PVS-Studio couldn't help checking CodeLite
Linux version of PVS-Studio couldn't help checking CodeLiteLinux version of PVS-Studio couldn't help checking CodeLite
Linux version of PVS-Studio couldn't help checking CodeLitePVS-Studio
 
Handling inline assembly in Clang and LLVM
Handling inline assembly in Clang and LLVMHandling inline assembly in Clang and LLVM
Handling inline assembly in Clang and LLVMMin-Yih Hsu
 
PVS-Studio delved into the FreeBSD kernel
PVS-Studio delved into the FreeBSD kernelPVS-Studio delved into the FreeBSD kernel
PVS-Studio delved into the FreeBSD kernelPVS-Studio
 
Bridge TensorFlow to run on Intel nGraph backends (v0.5)
Bridge TensorFlow to run on Intel nGraph backends (v0.5)Bridge TensorFlow to run on Intel nGraph backends (v0.5)
Bridge TensorFlow to run on Intel nGraph backends (v0.5)Mr. Vengineer
 
Windbg랑 친해지기
Windbg랑 친해지기Windbg랑 친해지기
Windbg랑 친해지기Ji Hun Kim
 
A few words about OpenSSL
A few words about OpenSSLA few words about OpenSSL
A few words about OpenSSLPVS-Studio
 
Linux Kernel, tested by the Linux-version of PVS-Studio
Linux Kernel, tested by the Linux-version of PVS-StudioLinux Kernel, tested by the Linux-version of PVS-Studio
Linux Kernel, tested by the Linux-version of PVS-StudioPVS-Studio
 
Intel IPP Samples for Windows - error correction
Intel IPP Samples for Windows - error correctionIntel IPP Samples for Windows - error correction
Intel IPP Samples for Windows - error correctionAndrey Karpov
 

Was ist angesagt? (20)

100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects 100 bugs in Open Source C/C++ projects
100 bugs in Open Source C/C++ projects
 
Heading for a Record: Chromium, the 5th Check
Heading for a Record: Chromium, the 5th CheckHeading for a Record: Chromium, the 5th Check
Heading for a Record: Chromium, the 5th Check
 
PVS-Studio for Linux (CoreHard presentation)
PVS-Studio for Linux (CoreHard presentation)PVS-Studio for Linux (CoreHard presentation)
PVS-Studio for Linux (CoreHard presentation)
 
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against itEvgeniy Muralev, Mark Vince, Working with the compiler, not against it
Evgeniy Muralev, Mark Vince, Working with the compiler, not against it
 
Дмитрий Демчук. Кроссплатформенный краш-репорт
Дмитрий Демчук. Кроссплатформенный краш-репортДмитрий Демчук. Кроссплатформенный краш-репорт
Дмитрий Демчук. Кроссплатформенный краш-репорт
 
"Why is there no artificial intelligence yet?" Or, analysis of CNTK tool kit ...
"Why is there no artificial intelligence yet?" Or, analysis of CNTK tool kit ..."Why is there no artificial intelligence yet?" Or, analysis of CNTK tool kit ...
"Why is there no artificial intelligence yet?" Or, analysis of CNTK tool kit ...
 
Checking Intel IPP Samples for Windows - Continuation
Checking Intel IPP Samples for Windows - ContinuationChecking Intel IPP Samples for Windows - Continuation
Checking Intel IPP Samples for Windows - Continuation
 
A Check of the Open-Source Project WinSCP Developed in Embarcadero C++ Builder
A Check of the Open-Source Project WinSCP Developed in Embarcadero C++ BuilderA Check of the Open-Source Project WinSCP Developed in Embarcadero C++ Builder
A Check of the Open-Source Project WinSCP Developed in Embarcadero C++ Builder
 
Top 10 bugs in C++ open source projects, checked in 2016
Top 10 bugs in C++ open source projects, checked in 2016Top 10 bugs in C++ open source projects, checked in 2016
Top 10 bugs in C++ open source projects, checked in 2016
 
(Slightly) Smarter Smart Pointers
(Slightly) Smarter Smart Pointers(Slightly) Smarter Smart Pointers
(Slightly) Smarter Smart Pointers
 
Linux version of PVS-Studio couldn't help checking CodeLite
Linux version of PVS-Studio couldn't help checking CodeLiteLinux version of PVS-Studio couldn't help checking CodeLite
Linux version of PVS-Studio couldn't help checking CodeLite
 
Cppcheck
CppcheckCppcheck
Cppcheck
 
Handling inline assembly in Clang and LLVM
Handling inline assembly in Clang and LLVMHandling inline assembly in Clang and LLVM
Handling inline assembly in Clang and LLVM
 
PVS-Studio delved into the FreeBSD kernel
PVS-Studio delved into the FreeBSD kernelPVS-Studio delved into the FreeBSD kernel
PVS-Studio delved into the FreeBSD kernel
 
Bridge TensorFlow to run on Intel nGraph backends (v0.5)
Bridge TensorFlow to run on Intel nGraph backends (v0.5)Bridge TensorFlow to run on Intel nGraph backends (v0.5)
Bridge TensorFlow to run on Intel nGraph backends (v0.5)
 
C++ Core Guidelines
C++ Core GuidelinesC++ Core Guidelines
C++ Core Guidelines
 
Windbg랑 친해지기
Windbg랑 친해지기Windbg랑 친해지기
Windbg랑 친해지기
 
A few words about OpenSSL
A few words about OpenSSLA few words about OpenSSL
A few words about OpenSSL
 
Linux Kernel, tested by the Linux-version of PVS-Studio
Linux Kernel, tested by the Linux-version of PVS-StudioLinux Kernel, tested by the Linux-version of PVS-Studio
Linux Kernel, tested by the Linux-version of PVS-Studio
 
Intel IPP Samples for Windows - error correction
Intel IPP Samples for Windows - error correctionIntel IPP Samples for Windows - error correction
Intel IPP Samples for Windows - error correction
 

Andere mochten auch

C++ memory leak detection
C++ memory leak detectionC++ memory leak detection
C++ memory leak detectionVõ Hòa
 
Nokia Web-Runtime Presentation (Phong Vu)
Nokia Web-Runtime Presentation (Phong Vu)Nokia Web-Runtime Presentation (Phong Vu)
Nokia Web-Runtime Presentation (Phong Vu)Daniel Appelquist
 
ISCA final presentation - Runtime
ISCA final presentation - RuntimeISCA final presentation - Runtime
ISCA final presentation - RuntimeHSA Foundation
 
Intel and Amazon - Powering your innovation together.
Intel and Amazon - Powering your innovation together. Intel and Amazon - Powering your innovation together.
Intel and Amazon - Powering your innovation together. Eran Shlomo
 
Microsoft Really Loves Linux – a Virtual Love Story
Microsoft Really Loves Linux – a Virtual Love StoryMicrosoft Really Loves Linux – a Virtual Love Story
Microsoft Really Loves Linux – a Virtual Love StoryChristian Heitkamp
 
OpenContrail, Real Speed: Offloading vRouter
OpenContrail, Real Speed: Offloading vRouterOpenContrail, Real Speed: Offloading vRouter
OpenContrail, Real Speed: Offloading vRouterOpen-NFP
 
Using GPUs to Achieve Massive Parallelism in Java 8
Using GPUs to Achieve Massive Parallelism in Java 8Using GPUs to Achieve Massive Parallelism in Java 8
Using GPUs to Achieve Massive Parallelism in Java 8Dev_Events
 
Java garbage collection & GC friendly coding
Java garbage collection  & GC friendly codingJava garbage collection  & GC friendly coding
Java garbage collection & GC friendly codingMd Ayub Ali Sarker
 
Cilium - BPF & XDP for containers
Cilium - BPF & XDP for containersCilium - BPF & XDP for containers
Cilium - BPF & XDP for containersThomas Graf
 
20170329 container technight-第一回勉強会
20170329 container technight-第一回勉強会20170329 container technight-第一回勉強会
20170329 container technight-第一回勉強会Minehiko Nohara
 
Serverless Application - Who the heck needs a Server?
Serverless Application - Who the heck needs a Server?Serverless Application - Who the heck needs a Server?
Serverless Application - Who the heck needs a Server?OPEN KNOWLEDGE GmbH
 
Serverless Architecture
Serverless ArchitectureServerless Architecture
Serverless Architecturejuly mon
 
Cilium - Container Networking with BPF & XDP
Cilium - Container Networking with BPF & XDPCilium - Container Networking with BPF & XDP
Cilium - Container Networking with BPF & XDPThomas Graf
 
Accelerating Hadoop, Spark, and Memcached with HPC Technologies
Accelerating Hadoop, Spark, and Memcached with HPC TechnologiesAccelerating Hadoop, Spark, and Memcached with HPC Technologies
Accelerating Hadoop, Spark, and Memcached with HPC Technologiesinside-BigData.com
 
BPF: Next Generation of Programmable Datapath
BPF: Next Generation of Programmable DatapathBPF: Next Generation of Programmable Datapath
BPF: Next Generation of Programmable DatapathThomas Graf
 
Introduction to OpenCV 3.x (with Java)
Introduction to OpenCV 3.x (with Java)Introduction to OpenCV 3.x (with Java)
Introduction to OpenCV 3.x (with Java)Luigi De Russis
 
Google ART (Android RunTime)
Google ART (Android RunTime)Google ART (Android RunTime)
Google ART (Android RunTime)Niraj Solanke
 
SOC Processors Used in SOC
SOC Processors Used in SOCSOC Processors Used in SOC
SOC Processors Used in SOCA B Shinde
 

Andere mochten auch (20)

C++ memory leak detection
C++ memory leak detectionC++ memory leak detection
C++ memory leak detection
 
Nokia Web-Runtime Presentation (Phong Vu)
Nokia Web-Runtime Presentation (Phong Vu)Nokia Web-Runtime Presentation (Phong Vu)
Nokia Web-Runtime Presentation (Phong Vu)
 
ISCA final presentation - Runtime
ISCA final presentation - RuntimeISCA final presentation - Runtime
ISCA final presentation - Runtime
 
Intel and Amazon - Powering your innovation together.
Intel and Amazon - Powering your innovation together. Intel and Amazon - Powering your innovation together.
Intel and Amazon - Powering your innovation together.
 
Microsoft Really Loves Linux – a Virtual Love Story
Microsoft Really Loves Linux – a Virtual Love StoryMicrosoft Really Loves Linux – a Virtual Love Story
Microsoft Really Loves Linux – a Virtual Love Story
 
OpenContrail, Real Speed: Offloading vRouter
OpenContrail, Real Speed: Offloading vRouterOpenContrail, Real Speed: Offloading vRouter
OpenContrail, Real Speed: Offloading vRouter
 
Using GPUs to Achieve Massive Parallelism in Java 8
Using GPUs to Achieve Massive Parallelism in Java 8Using GPUs to Achieve Massive Parallelism in Java 8
Using GPUs to Achieve Massive Parallelism in Java 8
 
Valgrind
ValgrindValgrind
Valgrind
 
Markus Tessmann, InnoGames
Markus Tessmann, InnoGames	Markus Tessmann, InnoGames
Markus Tessmann, InnoGames
 
Java garbage collection & GC friendly coding
Java garbage collection  & GC friendly codingJava garbage collection  & GC friendly coding
Java garbage collection & GC friendly coding
 
Cilium - BPF & XDP for containers
Cilium - BPF & XDP for containersCilium - BPF & XDP for containers
Cilium - BPF & XDP for containers
 
20170329 container technight-第一回勉強会
20170329 container technight-第一回勉強会20170329 container technight-第一回勉強会
20170329 container technight-第一回勉強会
 
Serverless Application - Who the heck needs a Server?
Serverless Application - Who the heck needs a Server?Serverless Application - Who the heck needs a Server?
Serverless Application - Who the heck needs a Server?
 
Serverless Architecture
Serverless ArchitectureServerless Architecture
Serverless Architecture
 
Cilium - Container Networking with BPF & XDP
Cilium - Container Networking with BPF & XDPCilium - Container Networking with BPF & XDP
Cilium - Container Networking with BPF & XDP
 
Accelerating Hadoop, Spark, and Memcached with HPC Technologies
Accelerating Hadoop, Spark, and Memcached with HPC TechnologiesAccelerating Hadoop, Spark, and Memcached with HPC Technologies
Accelerating Hadoop, Spark, and Memcached with HPC Technologies
 
BPF: Next Generation of Programmable Datapath
BPF: Next Generation of Programmable DatapathBPF: Next Generation of Programmable Datapath
BPF: Next Generation of Programmable Datapath
 
Introduction to OpenCV 3.x (with Java)
Introduction to OpenCV 3.x (with Java)Introduction to OpenCV 3.x (with Java)
Introduction to OpenCV 3.x (with Java)
 
Google ART (Android RunTime)
Google ART (Android RunTime)Google ART (Android RunTime)
Google ART (Android RunTime)
 
SOC Processors Used in SOC
SOC Processors Used in SOCSOC Processors Used in SOC
SOC Processors Used in SOC
 

Ähnlich wie Valgrind overview: runtime memory checker and a bit more aka использование #valgrind на селе

Advanced debugging  techniques in different environments
Advanced debugging  techniques in different environmentsAdvanced debugging  techniques in different environments
Advanced debugging  techniques in different environmentsAndrii Soldatenko
 
不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)Douglas Chen
 
Troubleshooting .net core on linux
Troubleshooting .net core on linuxTroubleshooting .net core on linux
Troubleshooting .net core on linuxPavel Klimiankou
 
A CTF Hackers Toolbox
A CTF Hackers ToolboxA CTF Hackers Toolbox
A CTF Hackers ToolboxStefan
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?Doug Hawkins
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsAzul Systems, Inc.
 
Linux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloudLinux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloudAndrea Righi
 
DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)Soshi Nemoto
 
The true story_of_hello_world
The true story_of_hello_worldThe true story_of_hello_world
The true story_of_hello_worldfantasy zheng
 
DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...
DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...
DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...DevSecCon
 
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)JiandSon
 
PythonBrasil[8] - CPython for dummies
PythonBrasil[8] - CPython for dummiesPythonBrasil[8] - CPython for dummies
PythonBrasil[8] - CPython for dummiesTatiana Al-Chueyr
 
OptView2 - C++ on Sea 2022
OptView2 - C++ on Sea 2022OptView2 - C++ on Sea 2022
OptView2 - C++ on Sea 2022Ofek Shilon
 
NovaProva, a new generation unit test framework for C programs
NovaProva, a new generation unit test framework for C programsNovaProva, a new generation unit test framework for C programs
NovaProva, a new generation unit test framework for C programsGreg Banks
 
The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6Wim Godden
 
Troubleshooting real production problems
Troubleshooting real production problemsTroubleshooting real production problems
Troubleshooting real production problemsTier1 app
 
Life of a Chromium Developer
Life of a Chromium DeveloperLife of a Chromium Developer
Life of a Chromium Developermpaproductions
 
Troubleshooting performanceavailabilityproblems (1)
Troubleshooting performanceavailabilityproblems (1)Troubleshooting performanceavailabilityproblems (1)
Troubleshooting performanceavailabilityproblems (1)Tier1 app
 

Ähnlich wie Valgrind overview: runtime memory checker and a bit more aka использование #valgrind на селе (20)

Advanced debugging  techniques in different environments
Advanced debugging  techniques in different environmentsAdvanced debugging  techniques in different environments
Advanced debugging  techniques in different environments
 
不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)不深不淺,帶你認識 LLVM (Found LLVM in your life)
不深不淺,帶你認識 LLVM (Found LLVM in your life)
 
groovy & grails - lecture 6
groovy & grails - lecture 6groovy & grails - lecture 6
groovy & grails - lecture 6
 
Troubleshooting .net core on linux
Troubleshooting .net core on linuxTroubleshooting .net core on linux
Troubleshooting .net core on linux
 
A CTF Hackers Toolbox
A CTF Hackers ToolboxA CTF Hackers Toolbox
A CTF Hackers Toolbox
 
JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?JVM Mechanics: When Does the JVM JIT & Deoptimize?
JVM Mechanics: When Does the JVM JIT & Deoptimize?
 
Silicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM MechanicsSilicon Valley JUG: JVM Mechanics
Silicon Valley JUG: JVM Mechanics
 
Linux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloudLinux kernel tracing superpowers in the cloud
Linux kernel tracing superpowers in the cloud
 
DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)DevOps(4) : Ansible(2) - (MOSG)
DevOps(4) : Ansible(2) - (MOSG)
 
The true story_of_hello_world
The true story_of_hello_worldThe true story_of_hello_world
The true story_of_hello_world
 
DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...
DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...
DevSecCon London 2017 - MacOS security, hardening and forensics 101 by Ben Hu...
 
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
2013.02.02 지앤선 테크니컬 세미나 - Xcode를 활용한 디버깅 팁(OSXDEV)
 
PythonBrasil[8] - CPython for dummies
PythonBrasil[8] - CPython for dummiesPythonBrasil[8] - CPython for dummies
PythonBrasil[8] - CPython for dummies
 
OptView2 - C++ on Sea 2022
OptView2 - C++ on Sea 2022OptView2 - C++ on Sea 2022
OptView2 - C++ on Sea 2022
 
New features in Ruby 2.5
New features in Ruby 2.5New features in Ruby 2.5
New features in Ruby 2.5
 
NovaProva, a new generation unit test framework for C programs
NovaProva, a new generation unit test framework for C programsNovaProva, a new generation unit test framework for C programs
NovaProva, a new generation unit test framework for C programs
 
The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6The why and how of moving to PHP 5.5/5.6
The why and how of moving to PHP 5.5/5.6
 
Troubleshooting real production problems
Troubleshooting real production problemsTroubleshooting real production problems
Troubleshooting real production problems
 
Life of a Chromium Developer
Life of a Chromium DeveloperLife of a Chromium Developer
Life of a Chromium Developer
 
Troubleshooting performanceavailabilityproblems (1)
Troubleshooting performanceavailabilityproblems (1)Troubleshooting performanceavailabilityproblems (1)
Troubleshooting performanceavailabilityproblems (1)
 

Mehr von Minsk Linux User Group

Vladimir ’mend0za’ Shakhov — Linux firmware for iRMC controller on Fujitsu P...
 Vladimir ’mend0za’ Shakhov — Linux firmware for iRMC controller on Fujitsu P... Vladimir ’mend0za’ Shakhov — Linux firmware for iRMC controller on Fujitsu P...
Vladimir ’mend0za’ Shakhov — Linux firmware for iRMC controller on Fujitsu P...Minsk Linux User Group
 
Андрэй Захарэвіч — Hack the Hackpad: Першая спроба публічнага кіравання задач...
Андрэй Захарэвіч — Hack the Hackpad: Першая спроба публічнага кіравання задач...Андрэй Захарэвіч — Hack the Hackpad: Першая спроба публічнага кіравання задач...
Андрэй Захарэвіч — Hack the Hackpad: Першая спроба публічнага кіравання задач...Minsk Linux User Group
 
Святлана Ермаковіч — Вікі-дапаможнік. Як узмацніць беларускую вікі-супольнасць
Святлана Ермаковіч — Вікі-дапаможнік. Як узмацніць беларускую вікі-супольнасцьСвятлана Ермаковіч — Вікі-дапаможнік. Як узмацніць беларускую вікі-супольнасць
Святлана Ермаковіч — Вікі-дапаможнік. Як узмацніць беларускую вікі-супольнасцьMinsk Linux User Group
 
Тимофей Титовец — Elastic+Logstash+Kibana: Архитектура и опыт использования
Тимофей Титовец — Elastic+Logstash+Kibana: Архитектура и опыт использованияТимофей Титовец — Elastic+Logstash+Kibana: Архитектура и опыт использования
Тимофей Титовец — Elastic+Logstash+Kibana: Архитектура и опыт использованияMinsk Linux User Group
 
Андрэй Захарэвіч - Як мы ставілі KDE пад FreeBSD
Андрэй Захарэвіч - Як мы ставілі KDE пад FreeBSDАндрэй Захарэвіч - Як мы ставілі KDE пад FreeBSD
Андрэй Захарэвіч - Як мы ставілі KDE пад FreeBSDMinsk Linux User Group
 
Vitaly ̈_Vi ̈ Shukela - My FOSS projects
Vitaly  ̈_Vi ̈ Shukela - My FOSS projectsVitaly  ̈_Vi ̈ Shukela - My FOSS projects
Vitaly ̈_Vi ̈ Shukela - My FOSS projectsMinsk Linux User Group
 
Alexander Lomov - Cloud Foundry и BOSH: истории из жизни
Alexander Lomov - Cloud Foundry и BOSH: истории из жизниAlexander Lomov - Cloud Foundry и BOSH: истории из жизни
Alexander Lomov - Cloud Foundry и BOSH: истории из жизниMinsk Linux User Group
 
Vikentsi Lapa — How does software testing become software development?
Vikentsi Lapa — How does software testing  become software development?Vikentsi Lapa — How does software testing  become software development?
Vikentsi Lapa — How does software testing become software development?Minsk Linux User Group
 
Михаил Волчек — Свободные лицензии. быть или не быть? Продолжение
Михаил Волчек — Свободные лицензии. быть или не быть? ПродолжениеМихаил Волчек — Свободные лицензии. быть или не быть? Продолжение
Михаил Волчек — Свободные лицензии. быть или не быть? ПродолжениеMinsk Linux User Group
 
Максим Мельников — IPv6 at Home: NAT64, DNS64, OpenVPN
Максим Мельников — IPv6 at Home: NAT64, DNS64, OpenVPNМаксим Мельников — IPv6 at Home: NAT64, DNS64, OpenVPN
Максим Мельников — IPv6 at Home: NAT64, DNS64, OpenVPNMinsk Linux User Group
 
Слава Машканов — “Wubuntu”: Построение гетерогенной среды Windows+Linux на н...
Слава Машканов — “Wubuntu”: Построение гетерогенной среды  Windows+Linux на н...Слава Машканов — “Wubuntu”: Построение гетерогенной среды  Windows+Linux на н...
Слава Машканов — “Wubuntu”: Построение гетерогенной среды Windows+Linux на н...Minsk Linux User Group
 
MajorDoMo: Открытая платформа Умного Дома
MajorDoMo: Открытая платформа Умного ДомаMajorDoMo: Открытая платформа Умного Дома
MajorDoMo: Открытая платформа Умного ДомаMinsk Linux User Group
 
Максим Салов - Отладочный монитор
Максим Салов - Отладочный мониторМаксим Салов - Отладочный монитор
Максим Салов - Отладочный мониторMinsk Linux User Group
 
Максим Мельников - FOSDEM 2014 overview
Максим Мельников - FOSDEM 2014 overviewМаксим Мельников - FOSDEM 2014 overview
Максим Мельников - FOSDEM 2014 overviewMinsk Linux User Group
 
Константин Шевцов - Пара слов о Jenkins
Константин Шевцов - Пара слов о JenkinsКонстантин Шевцов - Пара слов о Jenkins
Константин Шевцов - Пара слов о JenkinsMinsk Linux User Group
 
Ермакович Света - Операция «Пингвин»
Ермакович Света - Операция «Пингвин»Ермакович Света - Операция «Пингвин»
Ермакович Света - Операция «Пингвин»Minsk Linux User Group
 
Михаил Волчек - Смогут ли беларусы вкусить плоды Творческих Общин? Creative C...
Михаил Волчек - Смогут ли беларусы вкусить плоды Творческих Общин? Creative C...Михаил Волчек - Смогут ли беларусы вкусить плоды Творческих Общин? Creative C...
Михаил Волчек - Смогут ли беларусы вкусить плоды Творческих Общин? Creative C...Minsk Linux User Group
 
Алексей Туля - А нужен ли вам erlang?
Алексей Туля - А нужен ли вам erlang?Алексей Туля - А нужен ли вам erlang?
Алексей Туля - А нужен ли вам erlang?Minsk Linux User Group
 

Mehr von Minsk Linux User Group (20)

Vladimir ’mend0za’ Shakhov — Linux firmware for iRMC controller on Fujitsu P...
 Vladimir ’mend0za’ Shakhov — Linux firmware for iRMC controller on Fujitsu P... Vladimir ’mend0za’ Shakhov — Linux firmware for iRMC controller on Fujitsu P...
Vladimir ’mend0za’ Shakhov — Linux firmware for iRMC controller on Fujitsu P...
 
Андрэй Захарэвіч — Hack the Hackpad: Першая спроба публічнага кіравання задач...
Андрэй Захарэвіч — Hack the Hackpad: Першая спроба публічнага кіравання задач...Андрэй Захарэвіч — Hack the Hackpad: Першая спроба публічнага кіравання задач...
Андрэй Захарэвіч — Hack the Hackpad: Першая спроба публічнага кіравання задач...
 
Святлана Ермаковіч — Вікі-дапаможнік. Як узмацніць беларускую вікі-супольнасць
Святлана Ермаковіч — Вікі-дапаможнік. Як узмацніць беларускую вікі-супольнасцьСвятлана Ермаковіч — Вікі-дапаможнік. Як узмацніць беларускую вікі-супольнасць
Святлана Ермаковіч — Вікі-дапаможнік. Як узмацніць беларускую вікі-супольнасць
 
Тимофей Титовец — Elastic+Logstash+Kibana: Архитектура и опыт использования
Тимофей Титовец — Elastic+Logstash+Kibana: Архитектура и опыт использованияТимофей Титовец — Elastic+Logstash+Kibana: Архитектура и опыт использования
Тимофей Титовец — Elastic+Logstash+Kibana: Архитектура и опыт использования
 
Андрэй Захарэвіч - Як мы ставілі KDE пад FreeBSD
Андрэй Захарэвіч - Як мы ставілі KDE пад FreeBSDАндрэй Захарэвіч - Як мы ставілі KDE пад FreeBSD
Андрэй Захарэвіч - Як мы ставілі KDE пад FreeBSD
 
Vitaly ̈_Vi ̈ Shukela - My FOSS projects
Vitaly  ̈_Vi ̈ Shukela - My FOSS projectsVitaly  ̈_Vi ̈ Shukela - My FOSS projects
Vitaly ̈_Vi ̈ Shukela - My FOSS projects
 
Vitaly ̈_Vi ̈ Shukela - Dive
Vitaly  ̈_Vi ̈ Shukela - DiveVitaly  ̈_Vi ̈ Shukela - Dive
Vitaly ̈_Vi ̈ Shukela - Dive
 
Alexander Lomov - Cloud Foundry и BOSH: истории из жизни
Alexander Lomov - Cloud Foundry и BOSH: истории из жизниAlexander Lomov - Cloud Foundry и BOSH: истории из жизни
Alexander Lomov - Cloud Foundry и BOSH: истории из жизни
 
Vikentsi Lapa — How does software testing become software development?
Vikentsi Lapa — How does software testing  become software development?Vikentsi Lapa — How does software testing  become software development?
Vikentsi Lapa — How does software testing become software development?
 
Михаил Волчек — Свободные лицензии. быть или не быть? Продолжение
Михаил Волчек — Свободные лицензии. быть или не быть? ПродолжениеМихаил Волчек — Свободные лицензии. быть или не быть? Продолжение
Михаил Волчек — Свободные лицензии. быть или не быть? Продолжение
 
Максим Мельников — IPv6 at Home: NAT64, DNS64, OpenVPN
Максим Мельников — IPv6 at Home: NAT64, DNS64, OpenVPNМаксим Мельников — IPv6 at Home: NAT64, DNS64, OpenVPN
Максим Мельников — IPv6 at Home: NAT64, DNS64, OpenVPN
 
Слава Машканов — “Wubuntu”: Построение гетерогенной среды Windows+Linux на н...
Слава Машканов — “Wubuntu”: Построение гетерогенной среды  Windows+Linux на н...Слава Машканов — “Wubuntu”: Построение гетерогенной среды  Windows+Linux на н...
Слава Машканов — “Wubuntu”: Построение гетерогенной среды Windows+Linux на н...
 
MajorDoMo: Открытая платформа Умного Дома
MajorDoMo: Открытая платформа Умного ДомаMajorDoMo: Открытая платформа Умного Дома
MajorDoMo: Открытая платформа Умного Дома
 
Максим Салов - Отладочный монитор
Максим Салов - Отладочный мониторМаксим Салов - Отладочный монитор
Максим Салов - Отладочный монитор
 
Максим Мельников - FOSDEM 2014 overview
Максим Мельников - FOSDEM 2014 overviewМаксим Мельников - FOSDEM 2014 overview
Максим Мельников - FOSDEM 2014 overview
 
Константин Шевцов - Пара слов о Jenkins
Константин Шевцов - Пара слов о JenkinsКонстантин Шевцов - Пара слов о Jenkins
Константин Шевцов - Пара слов о Jenkins
 
Ермакович Света - Операция «Пингвин»
Ермакович Света - Операция «Пингвин»Ермакович Света - Операция «Пингвин»
Ермакович Света - Операция «Пингвин»
 
Михаил Волчек - Смогут ли беларусы вкусить плоды Творческих Общин? Creative C...
Михаил Волчек - Смогут ли беларусы вкусить плоды Творческих Общин? Creative C...Михаил Волчек - Смогут ли беларусы вкусить плоды Творческих Общин? Creative C...
Михаил Волчек - Смогут ли беларусы вкусить плоды Творческих Общин? Creative C...
 
Vikentsi Lapa - Tools for testing
Vikentsi Lapa - Tools for testingVikentsi Lapa - Tools for testing
Vikentsi Lapa - Tools for testing
 
Алексей Туля - А нужен ли вам erlang?
Алексей Туля - А нужен ли вам erlang?Алексей Туля - А нужен ли вам erlang?
Алексей Туля - А нужен ли вам erlang?
 

Kürzlich hochgeladen

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?Antenna Manufacturer Coco
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 

Kürzlich hochgeladen (20)

Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?What Are The Drone Anti-jamming Systems Technology?
What Are The Drone Anti-jamming Systems Technology?
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
Bajaj Allianz Life Insurance Company - Insurer Innovation Award 2024
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 

Valgrind overview: runtime memory checker and a bit more aka использование #valgrind на селе

  • 1. Valgrind overview: Runtime memory checker and a bit more... What can we do with it? Sergei Trofimovich – slyfox@gentoo.org MLUG Mar 30, 2013 Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 2. The problem When do we start thinking of weird bug in a program? Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 3. The problem When do we start thinking of weird bug in a program? the output is a random garbage Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 4. The problem When do we start thinking of weird bug in a program? the output is a random garbage random SIGSEGVs Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 5. The problem When do we start thinking of weird bug in a program? the output is a random garbage random SIGSEGVs abort() messages showing ”double free()” corruption Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 6. Introduction Meet the valgrind: Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 7. Introduction Meet the valgrind: a commandline tool $ valgrind program [args...] Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 8. Introduction Meet the valgrind: a commandline tool $ valgrind program [args...] to search bugs in binary applications Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 9. Introduction Meet the valgrind: a commandline tool $ valgrind program [args...] to search bugs in binary applications which contain C/C++ code Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 10. Introduction Meet the valgrind: a commandline tool $ valgrind program [args...] to search bugs in binary applications which contain C/C++ code not scripts or bytecode Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 11. Introduction Meet the valgrind: a commandline tool $ valgrind program [args...] to search bugs in binary applications which contain C/C++ code not scripts or bytecode Author: Julian Seward compiler writer bzip2 works on current Mozilla’s JavaScript engines Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 12. Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 13. First example: no errors simple.c 1 int main() { 2 return 0; 3 } Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 14. First example: no errors run-simple.sh make simple CFLAGS=-g valgrind ./simple # to stderr valgrind --log-file=simple.vglog ./simple # to log Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 15. First example: no errors simple.vglog ==14290== Memcheck, a memory error detector ==14290== Copyright (C) 2002-2012, and GNU GPL’d, by Julian Seward et al. ==14290== Using Valgrind-3.9.0.SVN and LibVEX; rerun with -h for copyright info ==14290== Command: ./simple ==14290== Parent PID: 14287 ==14290== ==14290== ==14290== HEAP SUMMARY: ==14290== in use at exit: 0 bytes in 0 blocks ==14290== total heap usage: 0 allocs, 0 frees, 0 bytes allocated ==14290== ==14290== All heap blocks were freed -- no leaks are possible ==14290== ==14290== For counts of detected and suppressed errors, rerun with: -v ==14290== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 2 from 2) Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 16. Simple leak 01-leaky.c 1 #include <stdlib.h> /* malloc(), free() */ 2 void * leaky() { 3 return malloc (42); 4 } 5 int main() { 6 free ((leaky(), leaky())); 7 return 0; 8 } 9 10 // check as: valgrind --show-reachable=yes 11 // --leak-check=full 12 // --track-origins=yes 13 // --quiet Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 17. Simple leak 01-leaky.vglog ==14293== 42 bytes in 1 blocks are definitely lost in loss record 1 of 1 ==14293== at 0x4C2C1DB: malloc (vg_replace_malloc.c:270) ==14293== by 0x4005C9: leaky (01-leaky.c:3) ==14293== by 0x4005D9: main (01-leaky.c:6) ==14293== Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 18. Use of uninitialized memory 02-uninit.c 1 int use_uninit (char * uninit) { 2 if (*uninit > 42) /* oh, what will happen ? */ 3 return 24; 4 else 5 return 42; 6 } 7 int foo (void) { 8 char garbage; 9 use_uninit (&garbage); 10 } 11 int main() { 12 return foo (); 13 } Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 19. Use of uninitialized memory 02-uninit.vglog ==14297== Conditional jump or move depends on uninitialised value(s) ==14297== at 0x40052D: use_uninit (02-uninit.c:2) ==14297== by 0x400550: foo (02-uninit.c:9) ==14297== by 0x40055B: main (02-uninit.c:12) ==14297== Uninitialised value was created by a stack allocation ==14297== at 0x40053D: foo (02-uninit.c:7) ==14297== Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 20. Out of bounds access 03-oob.c 1 #include <stdlib.h> /* malloc(), free() */ 2 3 int main() { 4 char * p = (char *) malloc (32); 5 *(p + 32 + 129) = ’0’; /* whoops */ 6 free (p); 7 return 0; 8 } Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 21. Out of bounds access 03-oob.vglog ==14302== Invalid write of size 1 ==14302== at 0x4005DC: main (03-oob.c:5) ==14302== Address 0x51d80e1 is not stack’d, malloc’d or (recently) free’d ==14302== Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 22. Helping valgrind Sometimes compiler optimizations make the final code a complete mess. Here is some tips to make valgrind logs more readable: Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 23. Helping valgrind Sometimes compiler optimizations make the final code a complete mess. Here is some tips to make valgrind logs more readable: build your programs/libraries with -g compiler options to emit DWARF debugging symbols (./configure CFLAGS=-g CXXFLAGS=-g) Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 24. Helping valgrind Sometimes compiler optimizations make the final code a complete mess. Here is some tips to make valgrind logs more readable: build your programs/libraries with -g compiler options to emit DWARF debugging symbols (./configure CFLAGS=-g CXXFLAGS=-g) or install debugging symbols for them (if exist) Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 25. Helping valgrind Sometimes compiler optimizations make the final code a complete mess. Here is some tips to make valgrind logs more readable: build your programs/libraries with -g compiler options to emit DWARF debugging symbols (./configure CFLAGS=-g CXXFLAGS=-g) or install debugging symbols for them (if exist) do not overoptimize things: -O2 optimization reorders and inlines too much code -O1 is usually good-enough -O0 is likely too slow -Og (gcc-4.8 feature) sounds promising Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 26. Helping valgrind Sometimes compiler optimizations make the final code a complete mess. Here is some tips to make valgrind logs more readable: build your programs/libraries with -g compiler options to emit DWARF debugging symbols (./configure CFLAGS=-g CXXFLAGS=-g) or install debugging symbols for them (if exist) do not overoptimize things: -O2 optimization reorders and inlines too much code -O1 is usually good-enough -O0 is likely too slow -Og (gcc-4.8 feature) sounds promising -fno-builtin is your friend as valgrind can detect more bugs in mem*() and str*() functions. Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 27. Helping valgrind: user’s assistance You can guide valgrind through the source code and tell him the facts about the program he does not know. There is a mechanism for it: /usr/include/valgrind/*.h Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 28. Helping valgrind: an example 04-helpy-uninit.c 1 static char tb[32]; 2 char * get_temp_buffer () { 3 return tb; 4 } 5 void free_temp_buffer (char * b) { /* superoptimization! */ } 6 int user1 (char * b) { 7 memset (b, 32, ’A’); 8 return b[7]; /* a lot of hard work on ’b’ */ 9 } 10 int user2 (char * b) { 11 /* we forgot this: memset (b, 32, ’B’); */ 12 return b[7]; /* a lot of hard work on ’b’ */ 13 } 14 int main() { 15 char * b; int r1, r2; 16 17 b = get_temp_buffer(); r1 = user1 (b); free_temp_buffer (b); 18 b = get_temp_buffer(); r2 = user2 (b); free_temp_buffer (b); 19 return r1 + r2; 20 } Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 29. Helping valgrind: an example 04-helpy-uninit.vglog Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 30. Helping valgrind: an example 04-helpy-uninit-2.c 1 #include <valgrind/memcheck.h> 2 static char tb[32]; 3 char * get_temp_buffer () { 4 VALGRIND_MAKE_MEM_UNDEFINED(tb, 32); 5 return tb; 6 } 7 void free_temp_buffer (char * b) { /* superoptimization! */ } 8 int user1 (char * b) { 9 memset (b, 32, ’A’); 10 return b[7]; /* a lot of hard work on ’b’ */ 11 } 12 int user2 (char * b) { 13 /* we forgot this: memset (b, 32, ’B’); */ 14 return b[7]; /* a lot of hard work on ’b’ */ 15 } 16 int main() { 17 char * b; int r1, r2; 18 19 b = get_temp_buffer(); r1 = user1 (b); free_temp_buffer (b); 20 b = get_temp_buffer(); r2 = user2 (b); free_temp_buffer (b); 21 return r1 + r2; 22 } Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 31. Helping valgrind: an example 04-helpy-uninit-2.vglog ==14306== Syscall param exit_group(status) contains uninitialised byte(s) ==14306== at 0x4EEAA79: _Exit (_exit.c:32) ==14306== by 0x4E6BC6F: __run_exit_handlers (exit.c:92) ==14306== by 0x4E6BC94: exit (exit.c:99) ==14306== by 0x4E5576B: (below main) (libc-start.c:257) ==14306== Uninitialised value was created by a client request ==14306== at 0x4007F4: get_temp_buffer (04-helpy-uninit-2.c:4) ==14306== by 0x400894: main (04-helpy-uninit-2.c:20) ==14306== Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 32. More APIs to plug into your code valgrind-APIs.h 1 /* valgrind/memcheck.h */ 2 VALGRIND_MAKE_MEM_NOACCESS(_qzz_addr,_qzz_len) 3 VALGRIND_MAKE_MEM_UNDEFINED(_qzz_addr,_qzz_len) 4 VALGRIND_MAKE_MEM_DEFINED(_qzz_addr,_qzz_len) 5 VALGRIND_CREATE_BLOCK(_qzz_addr,_qzz_len, _qzz_desc) 6 VALGRIND_CHECK_MEM_IS_ADDRESSABLE(_qzz_addr,_qzz_len) 7 VALGRIND_CHECK_MEM_IS_DEFINED(_qzz_addr,_qzz_len) 8 VALGRIND_CHECK_VALUE_IS_DEFINED(__lvalue) 9 VALGRIND_COUNT_LEAKS(leaked, dubious, reachable, suppressed) 10 /* valgrind/valgrind.h */ 11 RUNNING_ON_VALGRIND 12 VALGRIND_DISCARD_TRANSLATIONS(_qzz_addr,_qzz_len) 13 VALGRIND_NON_SIMD_CALL0(_qyy_fn) 14 VALGRIND_NON_SIMD_CALL1(_qyy_fn, _qyy_arg1) 15 ... 16 VALGRIND_MALLOCLIKE_BLOCK(addr, sizeB, rzB, is_zeroed) 17 VALGRIND_FREELIKE_BLOCK(addr, rzB) 18 VALGRIND_CREATE_MEMPOOL(pool, rzB, is_zeroed) 19 VALGRIND_DESTROY_MEMPOOL(pool) 20 VALGRIND_MEMPOOL_ALLOC(pool, addr, size) 21 VALGRIND_MEMPOOL_FREE(pool, addr) 22 ... Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 33. Bugs in the wild Recently found bugs: cvsps: invalid handling of external modules btrfs-progs: invalid checksums for built data cvs: massive memory leak on long sessions Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 34. Magic! What a great tool! Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 35. Or not? Well... there is something I have hidden from you. Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 36. Generic instrumentation framework How does valgrind work internally? userspace JIT compiler with full CPU emulation (just like qemu in binary translation mode) uses VEX library to decoding guest code CPU instructions and assembling host code uses coregrind library to emulate operating system syscalls Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 37. Portability As valgrind goes down to syscall instructions it needs to know the syscall ABI, signal ABI, etc. of host and guest (emulated) OSes. Thus valgrind: Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 38. Portability As valgrind goes down to syscall instructions it needs to know the syscall ABI, signal ABI, etc. of host and guest (emulated) OSes. Thus valgrind: won’t work on windows in it’s current form as there is no documented syscall ABI. But! Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 39. Portability As valgrind goes down to syscall instructions it needs to know the syscall ABI, signal ABI, etc. of host and guest (emulated) OSes. Thus valgrind: won’t work on windows in it’s current form as there is no documented syscall ABI. But! There is some gross hacks to run wine under valgrind to unstrument PE files. Scary :] Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 40. Portability As valgrind goes down to syscall instructions it needs to know the syscall ABI, signal ABI, etc. of host and guest (emulated) OSes. Thus valgrind: won’t work on windows in it’s current form as there is no documented syscall ABI. But! There is some gross hacks to run wine under valgrind to unstrument PE files. Scary :] works poorly on rare OSen (like various BSDs), but it’s a matter of adding some syscall effect definition (some lines of code to valgrind/coregrind/m syswrap/*). Worth looking at valgrind-freebsd. ported to relatively popular CPU architectures: IA-32 (i386) AMD64 ARM PPC (PPC64) S390X MIPS Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 41. Other tools By default valgrind runs the memcheck tool (valgrind –tool=memcheck). VEX + coregrind is quite generic framework for runtimes exploration. Other tools shipped with valgrind are: none - does nothing (useful to measure emulation overlead) memcheck - default tool to check for common memory errors helgrind - data race detection tool for multithreaded apps using POSIX threads for synchronization drd - another data race detector cachegrind - l2 cache hit/miss profiler callgrind - function call and instruction cost profiler Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 42. Other tools: callgrind An example callgraph of valgrind —-tool=callgrind ls is... Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 43. Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 44. Thank you! Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more
  • 45. Any questions? Sergei Trofimovich – slyfox@gentoo.org valgrind overview: runtime memory checker and a bit more