SlideShare a Scribd company logo
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

More Related Content

What's hot

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 Check
PVS-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 it
Sergey 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 - Continuation
PVS-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++ Builder
Andrey 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 2016
PVS-Studio
 
(Slightly) Smarter Smart Pointers
(Slightly) Smarter Smart Pointers(Slightly) Smarter Smart Pointers
(Slightly) Smarter Smart Pointers
Carlo 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 CodeLite
PVS-Studio
 
Cppcheck
CppcheckCppcheck
Cppcheck
PVS-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 LLVM
Min-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 kernel
PVS-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
 
C++ Core Guidelines
C++ Core GuidelinesC++ Core Guidelines
C++ Core Guidelines
Thomas Pollak
 
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 OpenSSL
PVS-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-Studio
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
Andrey Karpov
 

What's hot (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
 

Viewers also liked

C++ memory leak detection
C++ memory leak detectionC++ memory leak detection
C++ memory leak detection
Võ 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 Story
Christian Heitkamp
 
OpenContrail, Real Speed: Offloading vRouter
OpenContrail, Real Speed: Offloading vRouterOpenContrail, Real Speed: Offloading vRouter
OpenContrail, Real Speed: Offloading vRouter
Open-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 8
Dev_Events
 
Valgrind
ValgrindValgrind
Markus Tessmann, InnoGames
Markus Tessmann, InnoGames	Markus Tessmann, InnoGames
Markus Tessmann, InnoGames
White Nights Conference
 
Java garbage collection & GC friendly coding
Java garbage collection  & GC friendly codingJava garbage collection  & GC friendly coding
Java garbage collection & GC friendly coding
Md Ayub Ali Sarker
 
Cilium - BPF & XDP for containers
Cilium - BPF & XDP for containersCilium - BPF & XDP for containers
Cilium - BPF & XDP for containers
Thomas 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 Architecture
july mon
 
Cilium - Container Networking with BPF & XDP
Cilium - Container Networking with BPF & XDPCilium - Container Networking with BPF & XDP
Cilium - Container Networking with BPF & XDP
Thomas 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 Technologies
inside-BigData.com
 
BPF: Next Generation of Programmable Datapath
BPF: Next Generation of Programmable DatapathBPF: Next Generation of Programmable Datapath
BPF: Next Generation of Programmable Datapath
Thomas 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 SOC
A B Shinde
 

Viewers also liked (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
 

Similar to 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 environments
Andrii 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
 
groovy & grails - lecture 6
groovy & grails - lecture 6groovy & grails - lecture 6
groovy & grails - lecture 6
Alexandre Masselot
 
Troubleshooting .net core on linux
Troubleshooting .net core on linuxTroubleshooting .net core on linux
Troubleshooting .net core on linux
Pavel Klimiankou
 
A CTF Hackers Toolbox
A CTF Hackers ToolboxA CTF Hackers Toolbox
A CTF Hackers Toolbox
Stefan
 
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 Mechanics
Azul 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 cloud
Andrea 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_world
fantasy 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 dummies
Tatiana Al-Chueyr
 
OptView2 - C++ on Sea 2022
OptView2 - C++ on Sea 2022OptView2 - C++ on Sea 2022
OptView2 - C++ on Sea 2022
Ofek Shilon
 
New features in Ruby 2.5
New features in Ruby 2.5New features in Ruby 2.5
New features in Ruby 2.5
Ireneusz Skrobiś
 
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
Greg 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.6
Wim Godden
 
Troubleshooting real production problems
Troubleshooting real production problemsTroubleshooting real production problems
Troubleshooting real production problems
Tier1 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
 

Similar to 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)
 

More from 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 пад FreeBSD
Minsk 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 projects
Minsk Linux User Group
 
Vitaly ̈_Vi ̈ Shukela - Dive
Vitaly  ̈_Vi ̈ Shukela - DiveVitaly  ̈_Vi ̈ Shukela - Dive
Vitaly ̈_Vi ̈ Shukela - Dive
Minsk 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, OpenVPN
Minsk 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 overview
Minsk Linux User Group
 
Константин Шевцов - Пара слов о Jenkins
Константин Шевцов - Пара слов о JenkinsКонстантин Шевцов - Пара слов о Jenkins
Константин Шевцов - Пара слов о Jenkins
Minsk Linux User Group
 
Ермакович Света - Операция «Пингвин»
Ермакович Света - Операция «Пингвин»Ермакович Света - Операция «Пингвин»
Ермакович Света - Операция «Пингвин»
Minsk Linux User Group
 
Михаил Волчек - Смогут ли беларусы вкусить плоды Творческих Общин? Creative C...
Михаил Волчек - Смогут ли беларусы вкусить плоды Творческих Общин? Creative C...Михаил Волчек - Смогут ли беларусы вкусить плоды Творческих Общин? Creative C...
Михаил Волчек - Смогут ли беларусы вкусить плоды Творческих Общин? Creative C...
Minsk Linux User Group
 
Vikentsi Lapa - Tools for testing
Vikentsi Lapa - Tools for testingVikentsi Lapa - Tools for testing
Vikentsi Lapa - Tools for testing
Minsk Linux User Group
 
Алексей Туля - А нужен ли вам erlang?
Алексей Туля - А нужен ли вам erlang?Алексей Туля - А нужен ли вам erlang?
Алексей Туля - А нужен ли вам erlang?
Minsk Linux User Group
 

More from 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?
 

Recently uploaded

Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Product School
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
Product School
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
Jemma Hussein Allen
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
91mobiles
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
Kari Kakkonen
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
Alan Dix
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
DianaGray10
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Albert Hoitingh
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Product School
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
DianaGray10
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
Cheryl Hung
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
UiPathCommunity
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
James Anderson
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
KatiaHIMEUR1
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
Elena Simperl
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
Guy Korland
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Thierry Lestable
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Inflectra
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Tobias Schneck
 

Recently uploaded (20)

Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
Unsubscribed: Combat Subscription Fatigue With a Membership Mentality by Head...
 
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
De-mystifying Zero to One: Design Informed Techniques for Greenfield Innovati...
 
The Future of Platform Engineering
The Future of Platform EngineeringThe Future of Platform Engineering
The Future of Platform Engineering
 
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdfSmart TV Buyer Insights Survey 2024 by 91mobiles.pdf
Smart TV Buyer Insights Survey 2024 by 91mobiles.pdf
 
DevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA ConnectDevOps and Testing slides at DASA Connect
DevOps and Testing slides at DASA Connect
 
Epistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI supportEpistemic Interaction - tuning interfaces to provide information for AI support
Epistemic Interaction - tuning interfaces to provide information for AI support
 
Connector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a buttonConnector Corner: Automate dynamic content and events by pushing a button
Connector Corner: Automate dynamic content and events by pushing a button
 
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
Encryption in Microsoft 365 - ExpertsLive Netherlands 2024
 
Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...Mission to Decommission: Importance of Decommissioning Products to Increase E...
Mission to Decommission: Importance of Decommissioning Products to Increase E...
 
UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3UiPath Test Automation using UiPath Test Suite series, part 3
UiPath Test Automation using UiPath Test Suite series, part 3
 
Key Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdfKey Trends Shaping the Future of Infrastructure.pdf
Key Trends Shaping the Future of Infrastructure.pdf
 
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
Dev Dives: Train smarter, not harder – active learning and UiPath LLMs for do...
 
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
GDG Cloud Southlake #33: Boule & Rebala: Effective AppSec in SDLC using Deplo...
 
Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !Securing your Kubernetes cluster_ a step-by-step guide to success !
Securing your Kubernetes cluster_ a step-by-step guide to success !
 
Knowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and backKnowledge engineering: from people to machines and back
Knowledge engineering: from people to machines and back
 
GraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge GraphGraphRAG is All You need? LLM & Knowledge Graph
GraphRAG is All You need? LLM & Knowledge Graph
 
FIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdfFIDO Alliance Osaka Seminar: Overview.pdf
FIDO Alliance Osaka Seminar: Overview.pdf
 
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
Empowering NextGen Mobility via Large Action Model Infrastructure (LAMI): pav...
 
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered QualitySoftware Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
Software Delivery At the Speed of AI: Inflectra Invests In AI-Powered Quality
 
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
Kubernetes & AI - Beauty and the Beast !?! @KCD Istanbul 2024
 

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