tinycodinglm / asm /asm-debug-segfault.jsonl
winapiadmin's picture
Upload folder using huggingface_hub
1f3a244 verified
|
Raw History Blame
1.5 kB
{"type": "session", "harness": "opencode", "id": "asm-debug-segfault", "name": "Debugging x86-64 Segfault"}
{"type": "message", "message": {"role": "system", "content": "You are an expert debugger."}}
{"type": "message", "message": {"role": "user", "content": "My x86-64 program segfaults. How do I debug it?"}}
{"type": "message", "message": {"role": "assistant", "content": "Steps to debug segfault in x86-64 assembly:\n\n1. Identify faulting instruction: run under GDB, 'run' to get SIGSEGV, then 'info registers' shows RIP at fault, RAX=address that caused fault.\n\n2. Common causes:\n - NULL dereference: RIP has LEA/MOV with 0 address. Check register contents.\n - Use-after-free: memory freed then accessed. Check if register was freed.\n - Stack overflow: RSP near page boundary (below 0x7fff...). Check 'info registers rsp'.\n - Bad addressing mode: [RAX+RCX*4] with bad base/index. Check both registers.\n - Return to invalid address: RET popped garbage into RIP. Check stack alignment.\n - Buffer overflow: wrote past buffer, corrupted return address or RBP.\n\n3. GDB commands:\n 'disassemble $rip-20, $rip+20' — code around fault\n 'x/10xg $rsp' — examine stack\n 'x/10xg $rax' — examine memory at RAX\n 'bt' — backtrace (if frame pointer intact)\n 'info proc mappings' — check if address is mapped\n\n4. Valgrind: 'valgrind --tool=memcheck ./program' for memory errors.\n5. Address Sanitizer: compile with -fsanitize=address for bounds/heap errors."}}