tinycodinglm / asm /asm-debug-atomic.jsonl
winapiadmin's picture
Upload folder using huggingface_hub
1f3a244 verified
|
Raw History Blame Contribute Delete
1.27 kB
{"type": "session", "harness": "opencode", "id": "asm-debug-atomic", "name": "Debugging x86-64 Lock-Free Races"}
{"type": "message", "message": {"role": "system", "content": "You are an expert debugger."}}
{"type": "message", "message": {"role": "user", "content": "How do I debug race conditions in x86-64 lock-free assembly?"}}
{"type": "message", "message": {"role": "assistant", "content": "Race condition debugging in lock-free code (CMPXCHG, XCHG loops):\n\n1. Thread Sanitizer: compile with -fsanitize=thread. Detects data races, lock-order inversions.\n\n2. Common race bugs:\n - Lost update: CAS loop retries but another thread already changed value. Check CAS return value (0=failed).\n - ABA problem: value changed A->B->A between load and CAS. CAS succeeds but data is inconsistent.\n - Memory ordering: x86 is TSO so loads not reordered, but stores can be delayed. LFENCE/SFENCE for MMIO.\n\n3. GDB multi-thread debugging:\n 'thread apply all bt' — backtrace all threads\n 'thread apply all info registers' — check register state\n 'set scheduler-locking on' — single-step one thread\n\n4. Valgrind DRD: 'valgrind --tool=drd ./program' for data race detection.\n\n5. Lock-step debugging: use deterministic scheduler to reproduce races."}}