SlideShare a Scribd company logo
1 of 54
Download to read offline
Address/Thread/MemorySanitizer
Slaughtering C++ bugs
Dmitry Vyukov, Google
dvyukov@
Feb 2015 @C++ User Group, Russia
● AddressSanitizer (aka ASan)
○ detects use-after-free and buffer overflows (C++)
● ThreadSanitizer (aka TSan)
○ detects data races (C++ & Go)
● MemorySanitizer (aka MSan)
○ detects uses of uninitialized memory (C++)
Agenda
AddressSanitizer
addressability bugs
AddressSanitizer overview
● Finds
○ buffer overflows (stack, heap, globals)
○ heap-use-after-free, stack-use-after-return
○ some more
● Compiler module (clang, gcc)
○ instruments all loads/stores
○ inserts redzones around stack and global variables
● Run-time library
○ malloc replacement (redzones, quarantine)
○ Bookkeeping for error messages
int main(int argc, char **argv) {
int stack_array[100];
stack_array[1] = 0;
return stack_array[argc + 100]; // BOOM
}
% clang++ -O1 -fsanitize=address a.cc; ./a.out
ERROR: AddressSanitizer stack-buffer-overflow
READ of size 4 at 0x7f5620d981b4 thread T0
#0 0x4024e8 in main a.cc:4
Address 0x7f5620d981b4 is located at offset 436 in frame
<main> of T0's stack:
This frame has 1 object(s):
[32, 432) 'stack_array'
ASan report example: stack-buffer-overflow
int main(int argc, char **argv) {
int *array = new int[100];
int res = array[argc + 100]; // BOOM
delete [] array;
return res;
}
% clang++ -O1 -fsanitize=address a.cc; ./a.out
ERROR: AddressSanitizer heap-buffer-overflow
READ of size 4 at 0x7fe4b0c76214 thread T0
#0 0x40246f in main a.cc:3
0x7fe4b0c76214 is located 4 bytes to the right of 400-
byte region [0x7fe..., 0x7fe...)
allocated by thread T0 here:
#0 0x402c36 in operator new[](unsigned long)
#1 0x402422 in main a.cc:2
ASan report example: heap-buffer-overflow
ASan report example: use-after-free
int main(int argc, char **argv) {
int *array = new int[100];
delete [] array;
return array[argc]; // BOOM
}
% clang++ -O1 -fsanitize=address a.cc && ./a.out
ERROR: AddressSanitizer heap-use-after-free
READ of size 4 at 0x7faa07fce084 thread T0
#0 0x40433c in main a.cc:4
0x7faa07fce084 is located 4 bytes inside of 400-byte region
freed by thread T0 here:
#0 0x4058fd in operator delete[](void*) _asan_rtl_
#1 0x404303 in main a.cc:3
previously allocated by thread T0 here:
#0 0x405579 in operator new[](unsigned long) _asan_rtl_
#1 0x4042f3 in main a.cc:2
Any aligned 8 bytes may have 9 states:
N good bytes and 8 - N bad (0<=N<=8)
0
7
6
5
4
3
2
1
-1
Good byte
Bad byte
Shadow value
ASan shadow byte
ASan virtual address space
0xffffffff
0x20000000
0x1fffffff
0x04000000
0x03ffffff
0x00000000
Application
Shadow
mprotect-ed
Shadow = Addr >> 3
ASan instrumentation: 8-byte access
char *shadow = a >> 3;
if (*shadow)
ReportError(a);
*a = ...
*a = ...
ASan instrumentation: N-byte access (1, 2, 4)
char *shadow = a >> 3;
if (*shadow &&
*shadow <= ((a&7)+N-1))
ReportError(a);
*a = ...
*a = ...
Instrumentation example (x86_64)
mov %rdi,%rax
shr $0x3,%rax # shift by 3
cmpb $0x0,(%rax) # load shadow
je 1f <foo+0x1f>
ud2a # generate SIGILL*
movq $0x1234,(%rdi) # original store
* May use call instead of UD2
Instrumenting stack frames
void foo() {
char a[328];
<------------- CODE ------------->
}
Instrumenting stack frames
void foo() {
char rz1[32]; // 32-byte aligned
char a[328];
char rz2[24];
char rz3[32];
int *shadow = &rz1 >> 3;
shadow[0] = 0xffffffff; // poison rz1
shadow[11] = 0xffffff00; // poison rz2
shadow[12] = 0xffffffff; // poison rz3
<------------- CODE ------------->
shadow[0] = shadow[11] = shadow[12] = 0;
}
Instrumenting globals
int a;
struct {
int original;
char redzone[60];
} a; // 32-aligned
Malloc replacement
● Insert redzones around every allocation
○ poison redzones on malloc
● Delay the reuse of freed memory
○ poison entire memory region on free
● Collect stack traces for every malloc/free
● 2x slowdown (Valgrind: 20x and more)
● 1.5x-3x memory overhead
● 3000+ bugs found in Chrome in 3 years
● 3000+ bugs found in Google server software
● 1000+ bugs everywhere else
○ Firefox, FreeType, FFmpeg, WebRTC, libjpeg-turbo,
Perl, Vim, LLVM, GCC, MySQL
ASan marketing slide
ThreadSanitizer
data races
What is a data race?
A data race happens when two threads access
the same variable concurrently, and at least
one of the accesses is a write.
This is undefined behavior in C and C++.
ThreadSanitizer
● Compile-time instrumentation (clang, gcc)
○ Intercepts all reads/writes
○ Function entry/exit
○ Atomic operations
● Run-time library
○ Malloc replacement
○ Intercepts all synchronization and thread mgmt
○ Handles reads/writes
TSan report example: data race
void Thread1() { Global = 42; }
int main() {
pthread_create(&t, 0, Thread1, 0);
Global = 43;
...
% clang -fsanitize=thread -g a.c && ./a.out
WARNING: ThreadSanitizer: data race (pid=20373)
Write of size 4 at 0x7f... by thread 1:
#0 Thread1 a.c:1
Previous write of size 4 at 0x7f... by main thread:
#0 main a.c:4
Thread 1 (tid=20374, running) created at:
#0 pthread_create ??:0
#1 main a.c:3
Compiler instrumentation
void foo(int *p) {
*p = 42;
}
void foo(int *p) {
__tsan_func_entry(__builtin_return_address(0));
__tsan_write4(p);
*p = 42;
__tsan_func_exit()
}
Compiler instrumentation
a.compare_exchange_strong(cmp, xchg)
__tsan_atomic32_compare_exchange(
&a, &cmp, xchg, seq_cst, seq_cst)
Direct shadow mapping (64-bit Linux)
Application
0x7fffffffffff
0x7f0000000000
Protected
0x7effffffffff
0x200000000000
Shadow
0x1fffffffffff
0x180000000000
Protected
0x17ffffffffff
0x000000000000
Shadow = 4 * (Addr & kMask);
Shadow cell
An 8-byte shadow cell represents one memory
access:
○ ~16 bits: TID (thread ID)
○ ~42 bits: Epoch (scalar clock)
○ 5 bits: position/size in 8-byte word
○ 1 bit: IsWrite
Full information (no more dereferences)
TID
Epo
Pos
IsW
4 shadow cells per 8 app. bytes
TID
Epo
Pos
IsW
TID
Epo
Pos
IsW
TID
Epo
Pos
IsW
TID
Epo
Pos
IsW
Example: first access
T1
E1
0:2
W
Write in thread T1
Example: second access
T1
E1
0:2
W
T2
E2
4:8
R
Read in thread T2
Example: third access
T1
E1
0:2
W
T3
E3
0:4
R
T2
E2
4:8
R
Read in thread T3
Example: race?
T1
E1
0:2
W
T3
E3
0:4
R
T2
E2
4:8
R
- overlap?
- different threads?
- one write?
- happens-before?
Fast happens-before
Previous access by T1 at TS1 (from shadow).
Current access by T3.
T3->vclock[T1] > TS1 -> no race
T3->vclock[T1] < TS1 -> RACE
Constant-time operation: 1 local load + 1
comparison.
Stack trace for previous access
● Important to understand the report
● Per-thread cyclic buffer of events
○ 64 bits per event (type + PC)
○ Events: memory access, function entry/exit
○ Information will be lost after some time
○ Buffer size is configurable
● Replay the event buffer on report
○ Unlimited number of frames
TSan overhead
● CPU: 4x-10x
● RAM: 5x-8x
Trophies
● 3000+ races in Google server-side C++ code
○ Scales to huge apps
● 500+ races in Go code
○ 60+ bugs in Go stdlib
● 200+ races in Chromium
1000+ races everywhere: Firefox, WebRTC,
OpenSSL, libgomp, llvm, gcc,
Key advantages
● Speed
○ > 10+x faster than other tools
● Native support for atomics
○ Hard or impossible to implement with binary
translation (Helgrind, Intel Inspector)
MemorySanitizer
uses of uninitialized memory (UUM)
MSan report example: UMR
int main(int argc, char **argv) {
int x[10];
x[0] = 1;
if (x[argc]) return 1;
...
% clang -fsanitize=memory -fPIE -pie a.c -g; ./a.out
WARNING: MemorySanitizer: UMR (uninitialized-memory-read)
#0 0x7ff6b05d9ca7 in main stack_umr.c:4
ORIGIN: stack allocation: x@main
Shadow memory
● Bit to bit shadow mapping
○ 1 means 'poisoned' (uninitialized)
● Uninitialized memory:
○ Returned by malloc
○ Local stack objects
● Initialized memory:
○ Constants
○ Executable and modules (.text, .data, .bss)
○ IO/Syscalls (read)
Shadow propagation
Reporting every load of uninitialized data is too noisy.
struct {
char x;
// 3-byte padding
int y;
}
It's OK to copy uninitialized data around.
Uninit calculations are OK, too, as long as the result is not
used. Programs do it. A lot!
Shadow propagation
A = B << C: A' = B' << C
A = B & C: A' = (B' & C') | (B & C') | (B' & C)
A = B + C: A' = B' | C' (approx.)
Report errors only on some uses: conditional
branch, dereference, syscall argument (visible
side-effect).
Tracking origins
Secondary shadow
○ Origin-ID is 4 bytes, 1:1 mapping
○ 1.5x additional slowdown
Remember origin on malloc/local allocation.
Propagate origin along with uninit value.
Tracking origins
WARNING: MemorySanitizer: use-of-uninitialized-value
#0 0x7fa14df37e1d in main test.c:19:10
Uninitialized value was stored to memory at
#0 0x7fa14df37a57 in pop() test.c:8:3
#1 0x7fa14df37dd5 in main test.c:19:10
Uninitialized value was stored to memory at
#0 0x7fa14df37733 in shift() test.c:2:16
#1 0x7fa14df37dbb in main test.c:18:3
Uninitialized value was stored to memory at
#0 0x7fa14df3793f in push(int*) test.c:5:3
#1 0x7fa14df37b2f in func1() test.c:14:3
#2 0x7fa14df37db6 in main test.c:17:3
Uninitialized value was created by an allocation of
’local_var’ in the stack frame of function ’func1’
#0 0x7fa14df37ad0 in func1() test.c:12
Shadow mapping
Application
0x7fffffffffff
0x600000000000
Origin
0x5fffffffffff
0x400000000000
Shadow
0x3fffffffffff
0x200000000000
Protected
0x1fffffffffff
0x000000000000
Shadow = Addr - 0x400000000000;
Origin = Addr - 0x200000000000;
● Without origins:
○ CPU: 2.5x
○ RAM: 2x
● With origins:
○ CPU: 4x
○ RAM: 3x
MSan overhead
Tricky part :(
Missing any write causes false reports.
● Libc
○ Solution: function wrappers
● Inline assembly
○ Openssl, libjpeg_turbo, etc
● JITs (e.g. V8)
MSan Trophies
● 1200+ bugs in Google server-size code
● 300+ in Chromium
● 30+ in clang
● hundreds of bugs elsewhere
What’s next?
You can help
Faster
● Use hardware features
○ Or even create them (!)
● Static analysis: eliminate redundant checks
○ Many attempts were made; not trivial!
○ How to test it??
More bugs
● Instrument assembler & binaries
○ SyzyASAN: instruments binaries statically, Win32
● Instrument JIT-ed code & JIT’s heap
● More types of bugs
○ Intra-object overflows
○ Annotations in STL, e.g. std::vector<>
● Other languages (e.g. races in Java)
More environments
● Microsoft Windows
● Mobile, embedded
● OS Kernel (Linux and others)
Q&A
http://code.google.com/p/address-sanitizer/
http://code.google.com/p/thread-sanitizer/
http://code.google.com/p/memory-sanitizer/
Dmitry Vyukov, Google, dvyukov@
● AddressSanitizer (memory corruption)
○ Linux, FreeBSD, OSX, CrOS, Android, iOS
○ i386, x86_64, ARM, PowerPC
○ WIP: Windows, *BSD (?)
○ Clang 3.1+ and GCC 4.8+
● ThreadSanitizer (data races)
○ A "must use" if you have threads (C++, Go)
○ Only x86_64 Linux/FreeBSD; Clang 3.2+ and GCC
4.8+
● MemorySanitizer (uses of uninitialized data)
○ Only x86_64 Linux; Clang 3.3
○ WIP: MIPS64, FreeBSD
Supported platforms
ASan/MSan vs Valgrind (Memcheck)
Valgrind ASan MSan
Heap out-of-bounds YES YES NO
Stack out-of-bounds NO YES NO
Global out-of-bounds NO YES NO
Use-after-free YES YES NO
Use-after-return NO Sometimes NO
Uninitialized reads YES NO YES
CPU Overhead 10x-300x 1.5x-3x 3x
● Slowdowns will add up
○ Bad for interactive or network apps
● Memory overheads will multiply
○ ASan redzone vs TSan/MSan large shadow
● Not trivial to implement
Why not a single tool?

More Related Content

What's hot

Decompressed vmlinux: linux kernel initialization from page table configurati...
Decompressed vmlinux: linux kernel initialization from page table configurati...Decompressed vmlinux: linux kernel initialization from page table configurati...
Decompressed vmlinux: linux kernel initialization from page table configurati...Adrian Huang
 
Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBshimosawa
 
Physical Memory Models.pdf
Physical Memory Models.pdfPhysical Memory Models.pdf
Physical Memory Models.pdfAdrian Huang
 
semaphore & mutex.pdf
semaphore & mutex.pdfsemaphore & mutex.pdf
semaphore & mutex.pdfAdrian Huang
 
DWARF Data Representation
DWARF Data RepresentationDWARF Data Representation
DWARF Data RepresentationWang Hsiangkai
 
Linux 4.x Tracing Tools: Using BPF Superpowers
Linux 4.x Tracing Tools: Using BPF SuperpowersLinux 4.x Tracing Tools: Using BPF Superpowers
Linux 4.x Tracing Tools: Using BPF SuperpowersBrendan Gregg
 
Heap exploitation
Heap exploitationHeap exploitation
Heap exploitationAngel Boy
 
Page cache in Linux kernel
Page cache in Linux kernelPage cache in Linux kernel
Page cache in Linux kernelAdrian Huang
 
Debugging linux kernel tools and techniques
Debugging linux kernel tools and  techniquesDebugging linux kernel tools and  techniques
Debugging linux kernel tools and techniquesSatpal Parmar
 
用十分鐘 向jserv學習作業系統設計
用十分鐘  向jserv學習作業系統設計用十分鐘  向jserv學習作業系統設計
用十分鐘 向jserv學習作業系統設計鍾誠 陳鍾誠
 
Process Address Space: The way to create virtual address (page table) of user...
Process Address Space: The way to create virtual address (page table) of user...Process Address Space: The way to create virtual address (page table) of user...
Process Address Space: The way to create virtual address (page table) of user...Adrian Huang
 
UM2019 Extended BPF: A New Type of Software
UM2019 Extended BPF: A New Type of SoftwareUM2019 Extended BPF: A New Type of Software
UM2019 Extended BPF: A New Type of SoftwareBrendan Gregg
 
プログラムを高速化する話Ⅱ 〜GPGPU編〜
プログラムを高速化する話Ⅱ 〜GPGPU編〜プログラムを高速化する話Ⅱ 〜GPGPU編〜
プログラムを高速化する話Ⅱ 〜GPGPU編〜京大 マイコンクラブ
 
Memory Mapping Implementation (mmap) in Linux Kernel
Memory Mapping Implementation (mmap) in Linux KernelMemory Mapping Implementation (mmap) in Linux Kernel
Memory Mapping Implementation (mmap) in Linux KernelAdrian Huang
 
Linux Kernel - Virtual File System
Linux Kernel - Virtual File SystemLinux Kernel - Virtual File System
Linux Kernel - Virtual File SystemAdrian Huang
 
malloc & vmalloc in Linux
malloc & vmalloc in Linuxmalloc & vmalloc in Linux
malloc & vmalloc in LinuxAdrian Huang
 

What's hot (20)

Decompressed vmlinux: linux kernel initialization from page table configurati...
Decompressed vmlinux: linux kernel initialization from page table configurati...Decompressed vmlinux: linux kernel initialization from page table configurati...
Decompressed vmlinux: linux kernel initialization from page table configurati...
 
淺談探索 Linux 系統設計之道
淺談探索 Linux 系統設計之道 淺談探索 Linux 系統設計之道
淺談探索 Linux 系統設計之道
 
Linux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKBLinux Kernel Booting Process (1) - For NLKB
Linux Kernel Booting Process (1) - For NLKB
 
Physical Memory Models.pdf
Physical Memory Models.pdfPhysical Memory Models.pdf
Physical Memory Models.pdf
 
semaphore & mutex.pdf
semaphore & mutex.pdfsemaphore & mutex.pdf
semaphore & mutex.pdf
 
DWARF Data Representation
DWARF Data RepresentationDWARF Data Representation
DWARF Data Representation
 
Linux 4.x Tracing Tools: Using BPF Superpowers
Linux 4.x Tracing Tools: Using BPF SuperpowersLinux 4.x Tracing Tools: Using BPF Superpowers
Linux 4.x Tracing Tools: Using BPF Superpowers
 
C++ マルチスレッド 入門
C++ マルチスレッド 入門C++ マルチスレッド 入門
C++ マルチスレッド 入門
 
Heap exploitation
Heap exploitationHeap exploitation
Heap exploitation
 
Page cache in Linux kernel
Page cache in Linux kernelPage cache in Linux kernel
Page cache in Linux kernel
 
Debugging linux kernel tools and techniques
Debugging linux kernel tools and  techniquesDebugging linux kernel tools and  techniques
Debugging linux kernel tools and techniques
 
用十分鐘 向jserv學習作業系統設計
用十分鐘  向jserv學習作業系統設計用十分鐘  向jserv學習作業系統設計
用十分鐘 向jserv學習作業系統設計
 
Process Address Space: The way to create virtual address (page table) of user...
Process Address Space: The way to create virtual address (page table) of user...Process Address Space: The way to create virtual address (page table) of user...
Process Address Space: The way to create virtual address (page table) of user...
 
Basic Linux Internals
Basic Linux InternalsBasic Linux Internals
Basic Linux Internals
 
GDB Rocks!
GDB Rocks!GDB Rocks!
GDB Rocks!
 
UM2019 Extended BPF: A New Type of Software
UM2019 Extended BPF: A New Type of SoftwareUM2019 Extended BPF: A New Type of Software
UM2019 Extended BPF: A New Type of Software
 
プログラムを高速化する話Ⅱ 〜GPGPU編〜
プログラムを高速化する話Ⅱ 〜GPGPU編〜プログラムを高速化する話Ⅱ 〜GPGPU編〜
プログラムを高速化する話Ⅱ 〜GPGPU編〜
 
Memory Mapping Implementation (mmap) in Linux Kernel
Memory Mapping Implementation (mmap) in Linux KernelMemory Mapping Implementation (mmap) in Linux Kernel
Memory Mapping Implementation (mmap) in Linux Kernel
 
Linux Kernel - Virtual File System
Linux Kernel - Virtual File SystemLinux Kernel - Virtual File System
Linux Kernel - Virtual File System
 
malloc & vmalloc in Linux
malloc & vmalloc in Linuxmalloc & vmalloc in Linux
malloc & vmalloc in Linux
 

Viewers also liked

HKG15-207: Advanced Toolchain Usage Part 3
HKG15-207: Advanced Toolchain Usage Part 3HKG15-207: Advanced Toolchain Usage Part 3
HKG15-207: Advanced Toolchain Usage Part 3Linaro
 
High quality library from scratch
High quality library from scratchHigh quality library from scratch
High quality library from scratchPlatonov Sergey
 
Debugging and Profiling C++ Template Metaprograms
Debugging and Profiling C++ Template MetaprogramsDebugging and Profiling C++ Template Metaprograms
Debugging and Profiling C++ Template MetaprogramsPlatonov Sergey
 
Конверсия управляемых языков в неуправляемые
Конверсия управляемых языков в неуправляемыеКонверсия управляемых языков в неуправляемые
Конверсия управляемых языков в неуправляемыеPlatonov Sergey
 
How to use KASAN to debug memory corruption in OpenStack environment- (2)
How to use KASAN to debug memory corruption in OpenStack environment- (2)How to use KASAN to debug memory corruption in OpenStack environment- (2)
How to use KASAN to debug memory corruption in OpenStack environment- (2)Gavin Guo
 
Практика Lock-free. RealTime-сервер
Практика Lock-free. RealTime-серверПрактика Lock-free. RealTime-сервер
Практика Lock-free. RealTime-серверPlatonov Sergey
 
Асинхронность и сопрограммы
Асинхронность и сопрограммыАсинхронность и сопрограммы
Асинхронность и сопрограммыPlatonov Sergey
 
С++ without new and delete
С++ without new and deleteС++ without new and delete
С++ without new and deletePlatonov Sergey
 
Конкурентные ассоциативные контейнеры
Конкурентные ассоциативные контейнерыКонкурентные ассоциативные контейнеры
Конкурентные ассоциативные контейнерыPlatonov Sergey
 
from old Java to modern Java
from old Java to modern Javafrom old Java to modern Java
from old Java to modern Java心 谷本
 
Multithreading done right
Multithreading done rightMultithreading done right
Multithreading done rightPlatonov Sergey
 
Architecting for the Cloud: demo and best practices, by Simone Brunozzi (2011...
Architecting for the Cloud: demo and best practices, by Simone Brunozzi (2011...Architecting for the Cloud: demo and best practices, by Simone Brunozzi (2011...
Architecting for the Cloud: demo and best practices, by Simone Brunozzi (2011...Amazon Web Services
 
[AWSマイスターシリーズ] AWS CLI / AWS Tools for Windows PowerShell
[AWSマイスターシリーズ] AWS CLI / AWS Tools for Windows PowerShell[AWSマイスターシリーズ] AWS CLI / AWS Tools for Windows PowerShell
[AWSマイスターシリーズ] AWS CLI / AWS Tools for Windows PowerShellAmazon Web Services Japan
 

Viewers also liked (13)

HKG15-207: Advanced Toolchain Usage Part 3
HKG15-207: Advanced Toolchain Usage Part 3HKG15-207: Advanced Toolchain Usage Part 3
HKG15-207: Advanced Toolchain Usage Part 3
 
High quality library from scratch
High quality library from scratchHigh quality library from scratch
High quality library from scratch
 
Debugging and Profiling C++ Template Metaprograms
Debugging and Profiling C++ Template MetaprogramsDebugging and Profiling C++ Template Metaprograms
Debugging and Profiling C++ Template Metaprograms
 
Конверсия управляемых языков в неуправляемые
Конверсия управляемых языков в неуправляемыеКонверсия управляемых языков в неуправляемые
Конверсия управляемых языков в неуправляемые
 
How to use KASAN to debug memory corruption in OpenStack environment- (2)
How to use KASAN to debug memory corruption in OpenStack environment- (2)How to use KASAN to debug memory corruption in OpenStack environment- (2)
How to use KASAN to debug memory corruption in OpenStack environment- (2)
 
Практика Lock-free. RealTime-сервер
Практика Lock-free. RealTime-серверПрактика Lock-free. RealTime-сервер
Практика Lock-free. RealTime-сервер
 
Асинхронность и сопрограммы
Асинхронность и сопрограммыАсинхронность и сопрограммы
Асинхронность и сопрограммы
 
С++ without new and delete
С++ without new and deleteС++ without new and delete
С++ without new and delete
 
Конкурентные ассоциативные контейнеры
Конкурентные ассоциативные контейнерыКонкурентные ассоциативные контейнеры
Конкурентные ассоциативные контейнеры
 
from old Java to modern Java
from old Java to modern Javafrom old Java to modern Java
from old Java to modern Java
 
Multithreading done right
Multithreading done rightMultithreading done right
Multithreading done right
 
Architecting for the Cloud: demo and best practices, by Simone Brunozzi (2011...
Architecting for the Cloud: demo and best practices, by Simone Brunozzi (2011...Architecting for the Cloud: demo and best practices, by Simone Brunozzi (2011...
Architecting for the Cloud: demo and best practices, by Simone Brunozzi (2011...
 
[AWSマイスターシリーズ] AWS CLI / AWS Tools for Windows PowerShell
[AWSマイスターシリーズ] AWS CLI / AWS Tools for Windows PowerShell[AWSマイスターシリーズ] AWS CLI / AWS Tools for Windows PowerShell
[AWSマイスターシリーズ] AWS CLI / AWS Tools for Windows PowerShell
 

Similar to Address/Thread/Memory Sanitizer

Yandex may 2013 a san-tsan_msan
Yandex may 2013   a san-tsan_msanYandex may 2013   a san-tsan_msan
Yandex may 2013 a san-tsan_msanYandex
 
Yandex may 2013 a san-tsan_msan
Yandex may 2013   a san-tsan_msanYandex may 2013   a san-tsan_msan
Yandex may 2013 a san-tsan_msanYandex
 
Yandex may 2013 a san-tsan_msan
Yandex may 2013   a san-tsan_msanYandex may 2013   a san-tsan_msan
Yandex may 2013 a san-tsan_msanYandex
 
Potapenko, vyukov forewarned is forearmed. a san and tsan
Potapenko, vyukov   forewarned is forearmed. a san and tsanPotapenko, vyukov   forewarned is forearmed. a san and tsan
Potapenko, vyukov forewarned is forearmed. a san and tsanDefconRussia
 
20140531 serebryany lecture02_find_scary_cpp_bugs
20140531 serebryany lecture02_find_scary_cpp_bugs20140531 serebryany lecture02_find_scary_cpp_bugs
20140531 serebryany lecture02_find_scary_cpp_bugsComputer Science Club
 
Cryptography and secure systems
Cryptography and secure systemsCryptography and secure systems
Cryptography and secure systemsVsevolod Stakhov
 
Happy To Use SIMD
Happy To Use SIMDHappy To Use SIMD
Happy To Use SIMDWei-Ta Wang
 
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...Akihiro Hayashi
 
A Speculative Technique for Auto-Memoization Processor with Multithreading
A Speculative Technique for Auto-Memoization Processor with MultithreadingA Speculative Technique for Auto-Memoization Processor with Multithreading
A Speculative Technique for Auto-Memoization Processor with MultithreadingMatsuo and Tsumura lab.
 
Lrz kurs: gpu and mic programming with r
Lrz kurs: gpu and mic programming with rLrz kurs: gpu and mic programming with r
Lrz kurs: gpu and mic programming with rFerdinand Jamitzky
 
Jvm profiling under the hood
Jvm profiling under the hoodJvm profiling under the hood
Jvm profiling under the hoodRichardWarburton
 
Productive OpenCL Programming An Introduction to OpenCL Libraries with Array...
Productive OpenCL Programming An Introduction to OpenCL Libraries  with Array...Productive OpenCL Programming An Introduction to OpenCL Libraries  with Array...
Productive OpenCL Programming An Introduction to OpenCL Libraries with Array...AMD Developer Central
 
C Programming Training in Ambala ! Batra Computer Centre
C Programming Training in Ambala ! Batra Computer CentreC Programming Training in Ambala ! Batra Computer Centre
C Programming Training in Ambala ! Batra Computer Centrejatin batra
 
Gpu workshop cluster universe: scripting cuda
Gpu workshop cluster universe: scripting cudaGpu workshop cluster universe: scripting cuda
Gpu workshop cluster universe: scripting cudaFerdinand Jamitzky
 
Windbg랑 친해지기
Windbg랑 친해지기Windbg랑 친해지기
Windbg랑 친해지기Ji Hun Kim
 

Similar to Address/Thread/Memory Sanitizer (20)

Yandex may 2013 a san-tsan_msan
Yandex may 2013   a san-tsan_msanYandex may 2013   a san-tsan_msan
Yandex may 2013 a san-tsan_msan
 
Yandex may 2013 a san-tsan_msan
Yandex may 2013   a san-tsan_msanYandex may 2013   a san-tsan_msan
Yandex may 2013 a san-tsan_msan
 
Yandex may 2013 a san-tsan_msan
Yandex may 2013   a san-tsan_msanYandex may 2013   a san-tsan_msan
Yandex may 2013 a san-tsan_msan
 
Potapenko, vyukov forewarned is forearmed. a san and tsan
Potapenko, vyukov   forewarned is forearmed. a san and tsanPotapenko, vyukov   forewarned is forearmed. a san and tsan
Potapenko, vyukov forewarned is forearmed. a san and tsan
 
20140531 serebryany lecture02_find_scary_cpp_bugs
20140531 serebryany lecture02_find_scary_cpp_bugs20140531 serebryany lecture02_find_scary_cpp_bugs
20140531 serebryany lecture02_find_scary_cpp_bugs
 
Cryptography and secure systems
Cryptography and secure systemsCryptography and secure systems
Cryptography and secure systems
 
Happy To Use SIMD
Happy To Use SIMDHappy To Use SIMD
Happy To Use SIMD
 
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
Exploring Compiler Optimization Opportunities for the OpenMP 4.x Accelerator...
 
Meltdown & Spectre
Meltdown & Spectre Meltdown & Spectre
Meltdown & Spectre
 
A Speculative Technique for Auto-Memoization Processor with Multithreading
A Speculative Technique for Auto-Memoization Processor with MultithreadingA Speculative Technique for Auto-Memoization Processor with Multithreading
A Speculative Technique for Auto-Memoization Processor with Multithreading
 
Meltdown & spectre
Meltdown & spectreMeltdown & spectre
Meltdown & spectre
 
Valgrind
ValgrindValgrind
Valgrind
 
Lrz kurs: gpu and mic programming with r
Lrz kurs: gpu and mic programming with rLrz kurs: gpu and mic programming with r
Lrz kurs: gpu and mic programming with r
 
Jvm profiling under the hood
Jvm profiling under the hoodJvm profiling under the hood
Jvm profiling under the hood
 
Productive OpenCL Programming An Introduction to OpenCL Libraries with Array...
Productive OpenCL Programming An Introduction to OpenCL Libraries  with Array...Productive OpenCL Programming An Introduction to OpenCL Libraries  with Array...
Productive OpenCL Programming An Introduction to OpenCL Libraries with Array...
 
C Programming Training in Ambala ! Batra Computer Centre
C Programming Training in Ambala ! Batra Computer CentreC Programming Training in Ambala ! Batra Computer Centre
C Programming Training in Ambala ! Batra Computer Centre
 
Gpu workshop cluster universe: scripting cuda
Gpu workshop cluster universe: scripting cudaGpu workshop cluster universe: scripting cuda
Gpu workshop cluster universe: scripting cuda
 
Windbg랑 친해지기
Windbg랑 친해지기Windbg랑 친해지기
Windbg랑 친해지기
 
Programar para GPUs
Programar para GPUsProgramar para GPUs
Programar para GPUs
 
Auto Tuning
Auto TuningAuto Tuning
Auto Tuning
 

More from Platonov Sergey

Евгений Зуев, С++ в России: Стандарт языка и его реализация
Евгений Зуев, С++ в России: Стандарт языка и его реализацияЕвгений Зуев, С++ в России: Стандарт языка и его реализация
Евгений Зуев, С++ в России: Стандарт языка и его реализацияPlatonov Sergey
 
Алексей Кутумов, C++ без исключений, часть 3
Алексей Кутумов,  C++ без исключений, часть 3Алексей Кутумов,  C++ без исключений, часть 3
Алексей Кутумов, C++ без исключений, часть 3Platonov Sergey
 
Евгений Рыжков, Андрей Карпов Как потратить 10 лет на разработку анализатора ...
Евгений Рыжков, Андрей Карпов Как потратить 10 лет на разработку анализатора ...Евгений Рыжков, Андрей Карпов Как потратить 10 лет на разработку анализатора ...
Евгений Рыжков, Андрей Карпов Как потратить 10 лет на разработку анализатора ...Platonov Sergey
 
Евгений Крутько, Многопоточные вычисления, современный подход.
Евгений Крутько, Многопоточные вычисления, современный подход.Евгений Крутько, Многопоточные вычисления, современный подход.
Евгений Крутько, Многопоточные вычисления, современный подход.Platonov Sergey
 
Тененёв Анатолий, Boost.Asio в алгоритмической торговле
Тененёв Анатолий, Boost.Asio в алгоритмической торговлеТененёв Анатолий, Boost.Asio в алгоритмической торговле
Тененёв Анатолий, Boost.Asio в алгоритмической торговлеPlatonov Sergey
 
Павел Беликов, Опыт мигрирования крупного проекта с Windows-only на Linux
Павел Беликов, Опыт мигрирования крупного проекта с Windows-only на LinuxПавел Беликов, Опыт мигрирования крупного проекта с Windows-only на Linux
Павел Беликов, Опыт мигрирования крупного проекта с Windows-only на LinuxPlatonov Sergey
 
Дмитрий Кашицын, Вывод типов в динамических и не очень языках II
Дмитрий Кашицын, Вывод типов в динамических и не очень языках IIДмитрий Кашицын, Вывод типов в динамических и не очень языках II
Дмитрий Кашицын, Вывод типов в динамических и не очень языках IIPlatonov Sergey
 
Дмитрий Кашицын, Вывод типов в динамических и не очень языках I
Дмитрий Кашицын, Вывод типов в динамических и не очень языках IДмитрий Кашицын, Вывод типов в динамических и не очень языках I
Дмитрий Кашицын, Вывод типов в динамических и не очень языках IPlatonov Sergey
 
QML\Qt Quick на практике
QML\Qt Quick на практикеQML\Qt Quick на практике
QML\Qt Quick на практикеPlatonov Sergey
 
Визуализация автомобильных маршрутов
Визуализация автомобильных маршрутовВизуализация автомобильных маршрутов
Визуализация автомобильных маршрутовPlatonov Sergey
 
Функциональный микроскоп: линзы в C++
Функциональный микроскоп: линзы в C++Функциональный микроскоп: линзы в C++
Функциональный микроскоп: линзы в C++Platonov Sergey
 
Как мы уменьшили количество ошибок в Unreal Engine с помощью статического ана...
Как мы уменьшили количество ошибок в Unreal Engine с помощью статического ана...Как мы уменьшили количество ошибок в Unreal Engine с помощью статического ана...
Как мы уменьшили количество ошибок в Unreal Engine с помощью статического ана...Platonov Sergey
 
HPX: C++11 runtime система для параллельных и распределённых вычислений
HPX: C++11 runtime система для параллельных и распределённых вычисленийHPX: C++11 runtime система для параллельных и распределённых вычислений
HPX: C++11 runtime система для параллельных и распределённых вычисленийPlatonov Sergey
 
Ranges calendar-novosibirsk-2015-08
Ranges calendar-novosibirsk-2015-08Ranges calendar-novosibirsk-2015-08
Ranges calendar-novosibirsk-2015-08Platonov Sergey
 
Использование maven для сборки больших модульных c++ проектов на примере Odin...
Использование maven для сборки больших модульных c++ проектов на примере Odin...Использование maven для сборки больших модульных c++ проектов на примере Odin...
Использование maven для сборки больших модульных c++ проектов на примере Odin...Platonov Sergey
 
Дракон в мешке: от LLVM к C++ и проблемам неопределенного поведения
Дракон в мешке: от LLVM к C++ и проблемам неопределенного поведенияДракон в мешке: от LLVM к C++ и проблемам неопределенного поведения
Дракон в мешке: от LLVM к C++ и проблемам неопределенного поведенияPlatonov Sergey
 
One definition rule - что это такое, и как с этим жить
One definition rule - что это такое, и как с этим житьOne definition rule - что это такое, и как с этим жить
One definition rule - что это такое, и как с этим житьPlatonov Sergey
 
DI в C++ тонкости и нюансы
DI в C++ тонкости и нюансыDI в C++ тонкости и нюансы
DI в C++ тонкости и нюансыPlatonov Sergey
 
Аскетичная разработка браузера
Аскетичная разработка браузераАскетичная разработка браузера
Аскетичная разработка браузераPlatonov Sergey
 

More from Platonov Sergey (20)

Евгений Зуев, С++ в России: Стандарт языка и его реализация
Евгений Зуев, С++ в России: Стандарт языка и его реализацияЕвгений Зуев, С++ в России: Стандарт языка и его реализация
Евгений Зуев, С++ в России: Стандарт языка и его реализация
 
Алексей Кутумов, C++ без исключений, часть 3
Алексей Кутумов,  C++ без исключений, часть 3Алексей Кутумов,  C++ без исключений, часть 3
Алексей Кутумов, C++ без исключений, часть 3
 
Евгений Рыжков, Андрей Карпов Как потратить 10 лет на разработку анализатора ...
Евгений Рыжков, Андрей Карпов Как потратить 10 лет на разработку анализатора ...Евгений Рыжков, Андрей Карпов Как потратить 10 лет на разработку анализатора ...
Евгений Рыжков, Андрей Карпов Как потратить 10 лет на разработку анализатора ...
 
Евгений Крутько, Многопоточные вычисления, современный подход.
Евгений Крутько, Многопоточные вычисления, современный подход.Евгений Крутько, Многопоточные вычисления, современный подход.
Евгений Крутько, Многопоточные вычисления, современный подход.
 
Тененёв Анатолий, Boost.Asio в алгоритмической торговле
Тененёв Анатолий, Boost.Asio в алгоритмической торговлеТененёв Анатолий, Boost.Asio в алгоритмической торговле
Тененёв Анатолий, Boost.Asio в алгоритмической торговле
 
Павел Беликов, Опыт мигрирования крупного проекта с Windows-only на Linux
Павел Беликов, Опыт мигрирования крупного проекта с Windows-only на LinuxПавел Беликов, Опыт мигрирования крупного проекта с Windows-only на Linux
Павел Беликов, Опыт мигрирования крупного проекта с Windows-only на Linux
 
Дмитрий Кашицын, Вывод типов в динамических и не очень языках II
Дмитрий Кашицын, Вывод типов в динамических и не очень языках IIДмитрий Кашицын, Вывод типов в динамических и не очень языках II
Дмитрий Кашицын, Вывод типов в динамических и не очень языках II
 
Дмитрий Кашицын, Вывод типов в динамических и не очень языках I
Дмитрий Кашицын, Вывод типов в динамических и не очень языках IДмитрий Кашицын, Вывод типов в динамических и не очень языках I
Дмитрий Кашицын, Вывод типов в динамических и не очень языках I
 
QML\Qt Quick на практике
QML\Qt Quick на практикеQML\Qt Quick на практике
QML\Qt Quick на практике
 
Визуализация автомобильных маршрутов
Визуализация автомобильных маршрутовВизуализация автомобильных маршрутов
Визуализация автомобильных маршрутов
 
Функциональный микроскоп: линзы в C++
Функциональный микроскоп: линзы в C++Функциональный микроскоп: линзы в C++
Функциональный микроскоп: линзы в C++
 
C++ exceptions
C++ exceptionsC++ exceptions
C++ exceptions
 
Как мы уменьшили количество ошибок в Unreal Engine с помощью статического ана...
Как мы уменьшили количество ошибок в Unreal Engine с помощью статического ана...Как мы уменьшили количество ошибок в Unreal Engine с помощью статического ана...
Как мы уменьшили количество ошибок в Unreal Engine с помощью статического ана...
 
HPX: C++11 runtime система для параллельных и распределённых вычислений
HPX: C++11 runtime система для параллельных и распределённых вычисленийHPX: C++11 runtime система для параллельных и распределённых вычислений
HPX: C++11 runtime система для параллельных и распределённых вычислений
 
Ranges calendar-novosibirsk-2015-08
Ranges calendar-novosibirsk-2015-08Ranges calendar-novosibirsk-2015-08
Ranges calendar-novosibirsk-2015-08
 
Использование maven для сборки больших модульных c++ проектов на примере Odin...
Использование maven для сборки больших модульных c++ проектов на примере Odin...Использование maven для сборки больших модульных c++ проектов на примере Odin...
Использование maven для сборки больших модульных c++ проектов на примере Odin...
 
Дракон в мешке: от LLVM к C++ и проблемам неопределенного поведения
Дракон в мешке: от LLVM к C++ и проблемам неопределенного поведенияДракон в мешке: от LLVM к C++ и проблемам неопределенного поведения
Дракон в мешке: от LLVM к C++ и проблемам неопределенного поведения
 
One definition rule - что это такое, и как с этим жить
One definition rule - что это такое, и как с этим житьOne definition rule - что это такое, и как с этим жить
One definition rule - что это такое, и как с этим жить
 
DI в C++ тонкости и нюансы
DI в C++ тонкости и нюансыDI в C++ тонкости и нюансы
DI в C++ тонкости и нюансы
 
Аскетичная разработка браузера
Аскетичная разработка браузераАскетичная разработка браузера
Аскетичная разработка браузера
 

Recently uploaded

%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...Shane Coughlan
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile EnvironmentVictorSzoltysek
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Bert Jan Schrijver
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 

Recently uploaded (20)

%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
OpenChain - The Ramifications of ISO/IEC 5230 and ISO/IEC 18974 for Legal Pro...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
Abortion Pill Prices Tembisa [(+27832195400*)] 🏥 Women's Abortion Clinic in T...
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With SimplicityWSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
WSO2Con2024 - Enabling Transactional System's Exponential Growth With Simplicity
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT  - Elevating Productivity in Today's Agile EnvironmentHarnessing ChatGPT  - Elevating Productivity in Today's Agile Environment
Harnessing ChatGPT - Elevating Productivity in Today's Agile Environment
 
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
Devoxx UK 2024 - Going serverless with Quarkus, GraalVM native images and AWS...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?WSO2CON 2024 - Does Open Source Still Matter?
WSO2CON 2024 - Does Open Source Still Matter?
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 

Address/Thread/Memory Sanitizer

  • 1. Address/Thread/MemorySanitizer Slaughtering C++ bugs Dmitry Vyukov, Google dvyukov@ Feb 2015 @C++ User Group, Russia
  • 2. ● AddressSanitizer (aka ASan) ○ detects use-after-free and buffer overflows (C++) ● ThreadSanitizer (aka TSan) ○ detects data races (C++ & Go) ● MemorySanitizer (aka MSan) ○ detects uses of uninitialized memory (C++) Agenda
  • 4. AddressSanitizer overview ● Finds ○ buffer overflows (stack, heap, globals) ○ heap-use-after-free, stack-use-after-return ○ some more ● Compiler module (clang, gcc) ○ instruments all loads/stores ○ inserts redzones around stack and global variables ● Run-time library ○ malloc replacement (redzones, quarantine) ○ Bookkeeping for error messages
  • 5. int main(int argc, char **argv) { int stack_array[100]; stack_array[1] = 0; return stack_array[argc + 100]; // BOOM } % clang++ -O1 -fsanitize=address a.cc; ./a.out ERROR: AddressSanitizer stack-buffer-overflow READ of size 4 at 0x7f5620d981b4 thread T0 #0 0x4024e8 in main a.cc:4 Address 0x7f5620d981b4 is located at offset 436 in frame <main> of T0's stack: This frame has 1 object(s): [32, 432) 'stack_array' ASan report example: stack-buffer-overflow
  • 6. int main(int argc, char **argv) { int *array = new int[100]; int res = array[argc + 100]; // BOOM delete [] array; return res; } % clang++ -O1 -fsanitize=address a.cc; ./a.out ERROR: AddressSanitizer heap-buffer-overflow READ of size 4 at 0x7fe4b0c76214 thread T0 #0 0x40246f in main a.cc:3 0x7fe4b0c76214 is located 4 bytes to the right of 400- byte region [0x7fe..., 0x7fe...) allocated by thread T0 here: #0 0x402c36 in operator new[](unsigned long) #1 0x402422 in main a.cc:2 ASan report example: heap-buffer-overflow
  • 7. ASan report example: use-after-free int main(int argc, char **argv) { int *array = new int[100]; delete [] array; return array[argc]; // BOOM } % clang++ -O1 -fsanitize=address a.cc && ./a.out ERROR: AddressSanitizer heap-use-after-free READ of size 4 at 0x7faa07fce084 thread T0 #0 0x40433c in main a.cc:4 0x7faa07fce084 is located 4 bytes inside of 400-byte region freed by thread T0 here: #0 0x4058fd in operator delete[](void*) _asan_rtl_ #1 0x404303 in main a.cc:3 previously allocated by thread T0 here: #0 0x405579 in operator new[](unsigned long) _asan_rtl_ #1 0x4042f3 in main a.cc:2
  • 8. Any aligned 8 bytes may have 9 states: N good bytes and 8 - N bad (0<=N<=8) 0 7 6 5 4 3 2 1 -1 Good byte Bad byte Shadow value ASan shadow byte
  • 9. ASan virtual address space 0xffffffff 0x20000000 0x1fffffff 0x04000000 0x03ffffff 0x00000000 Application Shadow mprotect-ed Shadow = Addr >> 3
  • 10. ASan instrumentation: 8-byte access char *shadow = a >> 3; if (*shadow) ReportError(a); *a = ... *a = ...
  • 11. ASan instrumentation: N-byte access (1, 2, 4) char *shadow = a >> 3; if (*shadow && *shadow <= ((a&7)+N-1)) ReportError(a); *a = ... *a = ...
  • 12. Instrumentation example (x86_64) mov %rdi,%rax shr $0x3,%rax # shift by 3 cmpb $0x0,(%rax) # load shadow je 1f <foo+0x1f> ud2a # generate SIGILL* movq $0x1234,(%rdi) # original store * May use call instead of UD2
  • 13. Instrumenting stack frames void foo() { char a[328]; <------------- CODE -------------> }
  • 14. Instrumenting stack frames void foo() { char rz1[32]; // 32-byte aligned char a[328]; char rz2[24]; char rz3[32]; int *shadow = &rz1 >> 3; shadow[0] = 0xffffffff; // poison rz1 shadow[11] = 0xffffff00; // poison rz2 shadow[12] = 0xffffffff; // poison rz3 <------------- CODE -------------> shadow[0] = shadow[11] = shadow[12] = 0; }
  • 15. Instrumenting globals int a; struct { int original; char redzone[60]; } a; // 32-aligned
  • 16. Malloc replacement ● Insert redzones around every allocation ○ poison redzones on malloc ● Delay the reuse of freed memory ○ poison entire memory region on free ● Collect stack traces for every malloc/free
  • 17. ● 2x slowdown (Valgrind: 20x and more) ● 1.5x-3x memory overhead ● 3000+ bugs found in Chrome in 3 years ● 3000+ bugs found in Google server software ● 1000+ bugs everywhere else ○ Firefox, FreeType, FFmpeg, WebRTC, libjpeg-turbo, Perl, Vim, LLVM, GCC, MySQL ASan marketing slide
  • 19. What is a data race? A data race happens when two threads access the same variable concurrently, and at least one of the accesses is a write. This is undefined behavior in C and C++.
  • 20. ThreadSanitizer ● Compile-time instrumentation (clang, gcc) ○ Intercepts all reads/writes ○ Function entry/exit ○ Atomic operations ● Run-time library ○ Malloc replacement ○ Intercepts all synchronization and thread mgmt ○ Handles reads/writes
  • 21. TSan report example: data race void Thread1() { Global = 42; } int main() { pthread_create(&t, 0, Thread1, 0); Global = 43; ... % clang -fsanitize=thread -g a.c && ./a.out WARNING: ThreadSanitizer: data race (pid=20373) Write of size 4 at 0x7f... by thread 1: #0 Thread1 a.c:1 Previous write of size 4 at 0x7f... by main thread: #0 main a.c:4 Thread 1 (tid=20374, running) created at: #0 pthread_create ??:0 #1 main a.c:3
  • 22. Compiler instrumentation void foo(int *p) { *p = 42; } void foo(int *p) { __tsan_func_entry(__builtin_return_address(0)); __tsan_write4(p); *p = 42; __tsan_func_exit() }
  • 24. Direct shadow mapping (64-bit Linux) Application 0x7fffffffffff 0x7f0000000000 Protected 0x7effffffffff 0x200000000000 Shadow 0x1fffffffffff 0x180000000000 Protected 0x17ffffffffff 0x000000000000 Shadow = 4 * (Addr & kMask);
  • 25. Shadow cell An 8-byte shadow cell represents one memory access: ○ ~16 bits: TID (thread ID) ○ ~42 bits: Epoch (scalar clock) ○ 5 bits: position/size in 8-byte word ○ 1 bit: IsWrite Full information (no more dereferences) TID Epo Pos IsW
  • 26. 4 shadow cells per 8 app. bytes TID Epo Pos IsW TID Epo Pos IsW TID Epo Pos IsW TID Epo Pos IsW
  • 30. Example: race? T1 E1 0:2 W T3 E3 0:4 R T2 E2 4:8 R - overlap? - different threads? - one write? - happens-before?
  • 31. Fast happens-before Previous access by T1 at TS1 (from shadow). Current access by T3. T3->vclock[T1] > TS1 -> no race T3->vclock[T1] < TS1 -> RACE Constant-time operation: 1 local load + 1 comparison.
  • 32. Stack trace for previous access ● Important to understand the report ● Per-thread cyclic buffer of events ○ 64 bits per event (type + PC) ○ Events: memory access, function entry/exit ○ Information will be lost after some time ○ Buffer size is configurable ● Replay the event buffer on report ○ Unlimited number of frames
  • 33. TSan overhead ● CPU: 4x-10x ● RAM: 5x-8x
  • 34. Trophies ● 3000+ races in Google server-side C++ code ○ Scales to huge apps ● 500+ races in Go code ○ 60+ bugs in Go stdlib ● 200+ races in Chromium 1000+ races everywhere: Firefox, WebRTC, OpenSSL, libgomp, llvm, gcc,
  • 35. Key advantages ● Speed ○ > 10+x faster than other tools ● Native support for atomics ○ Hard or impossible to implement with binary translation (Helgrind, Intel Inspector)
  • 37. MSan report example: UMR int main(int argc, char **argv) { int x[10]; x[0] = 1; if (x[argc]) return 1; ... % clang -fsanitize=memory -fPIE -pie a.c -g; ./a.out WARNING: MemorySanitizer: UMR (uninitialized-memory-read) #0 0x7ff6b05d9ca7 in main stack_umr.c:4 ORIGIN: stack allocation: x@main
  • 38. Shadow memory ● Bit to bit shadow mapping ○ 1 means 'poisoned' (uninitialized) ● Uninitialized memory: ○ Returned by malloc ○ Local stack objects ● Initialized memory: ○ Constants ○ Executable and modules (.text, .data, .bss) ○ IO/Syscalls (read)
  • 39. Shadow propagation Reporting every load of uninitialized data is too noisy. struct { char x; // 3-byte padding int y; } It's OK to copy uninitialized data around. Uninit calculations are OK, too, as long as the result is not used. Programs do it. A lot!
  • 40. Shadow propagation A = B << C: A' = B' << C A = B & C: A' = (B' & C') | (B & C') | (B' & C) A = B + C: A' = B' | C' (approx.) Report errors only on some uses: conditional branch, dereference, syscall argument (visible side-effect).
  • 41. Tracking origins Secondary shadow ○ Origin-ID is 4 bytes, 1:1 mapping ○ 1.5x additional slowdown Remember origin on malloc/local allocation. Propagate origin along with uninit value.
  • 42. Tracking origins WARNING: MemorySanitizer: use-of-uninitialized-value #0 0x7fa14df37e1d in main test.c:19:10 Uninitialized value was stored to memory at #0 0x7fa14df37a57 in pop() test.c:8:3 #1 0x7fa14df37dd5 in main test.c:19:10 Uninitialized value was stored to memory at #0 0x7fa14df37733 in shift() test.c:2:16 #1 0x7fa14df37dbb in main test.c:18:3 Uninitialized value was stored to memory at #0 0x7fa14df3793f in push(int*) test.c:5:3 #1 0x7fa14df37b2f in func1() test.c:14:3 #2 0x7fa14df37db6 in main test.c:17:3 Uninitialized value was created by an allocation of ’local_var’ in the stack frame of function ’func1’ #0 0x7fa14df37ad0 in func1() test.c:12
  • 44. ● Without origins: ○ CPU: 2.5x ○ RAM: 2x ● With origins: ○ CPU: 4x ○ RAM: 3x MSan overhead
  • 45. Tricky part :( Missing any write causes false reports. ● Libc ○ Solution: function wrappers ● Inline assembly ○ Openssl, libjpeg_turbo, etc ● JITs (e.g. V8)
  • 46. MSan Trophies ● 1200+ bugs in Google server-size code ● 300+ in Chromium ● 30+ in clang ● hundreds of bugs elsewhere
  • 48. Faster ● Use hardware features ○ Or even create them (!) ● Static analysis: eliminate redundant checks ○ Many attempts were made; not trivial! ○ How to test it??
  • 49. More bugs ● Instrument assembler & binaries ○ SyzyASAN: instruments binaries statically, Win32 ● Instrument JIT-ed code & JIT’s heap ● More types of bugs ○ Intra-object overflows ○ Annotations in STL, e.g. std::vector<> ● Other languages (e.g. races in Java)
  • 50. More environments ● Microsoft Windows ● Mobile, embedded ● OS Kernel (Linux and others)
  • 52. ● AddressSanitizer (memory corruption) ○ Linux, FreeBSD, OSX, CrOS, Android, iOS ○ i386, x86_64, ARM, PowerPC ○ WIP: Windows, *BSD (?) ○ Clang 3.1+ and GCC 4.8+ ● ThreadSanitizer (data races) ○ A "must use" if you have threads (C++, Go) ○ Only x86_64 Linux/FreeBSD; Clang 3.2+ and GCC 4.8+ ● MemorySanitizer (uses of uninitialized data) ○ Only x86_64 Linux; Clang 3.3 ○ WIP: MIPS64, FreeBSD Supported platforms
  • 53. ASan/MSan vs Valgrind (Memcheck) Valgrind ASan MSan Heap out-of-bounds YES YES NO Stack out-of-bounds NO YES NO Global out-of-bounds NO YES NO Use-after-free YES YES NO Use-after-return NO Sometimes NO Uninitialized reads YES NO YES CPU Overhead 10x-300x 1.5x-3x 3x
  • 54. ● Slowdowns will add up ○ Bad for interactive or network apps ● Memory overheads will multiply ○ ASan redzone vs TSan/MSan large shadow ● Not trivial to implement Why not a single tool?