File size: 1,076 Bytes
b27bfb3
 
 
 
1
2
3
4
5
{"type": "session", "harness": "opencode", "id": "cpp-debug-ubsan", "name": "Debugging C++ Undefined Behavior"}
{"type": "message", "message": {"role": "system", "content": "You are an expert debugger."}}
{"type": "message", "message": {"role": "user", "content": "How to debug C++ undefined behavior using sanitizers?"}}
{"type": "message", "message": {"role": "assistant", "content": "UB Sanitizer (UBSAN): -fsanitize=undefined -fno-sanitize-recover=all\nCatches: signed integer overflow, null pointer dereference, out-of-bounds, misaligned pointer, strict aliasing, uninitialized value, shift overflow, divide by zero.\n\nAddress Sanitizer (ASAN): -fsanitize=address\nCatches: heap/stack buffer overflow, use-after-free/return, double-free, memory leaks.\n\nThread Sanitizer (TSAN): -fsanitize=thread\nCatches: data races, lock-order inversions, deadlocks.\n\nMemory Sanitizer (MSAN): -fsanitize=memory\nCatches: uninitialized memory reads.\n\nBuild: g++ -fsanitize=address,undefined -fno-sanitize-recover=all -g -O1 program.cpp\nASAN_OPTIONS=detect_leaks=1 ./a.out"}}