C/C++: free(): double free detected / double free or corruption (out) — Aborted (core dumped)
Memory was freed twice or the heap was corrupted (buffer overflow, freeing a non-heap pointer), so glibc aborted the program.
Seen on:
C/C++
Meaning
Common sources: two owners freeing the same pointer, copying a class with a raw pointer member (shallow copy then two destructors), writing past an array’s end, or delete on stack memory. AddressSanitizer pinpoints it.
Common causes
- Same pointer freed/deleted twice
- Shallow copy of a class owning raw memory (rule of three)
- Buffer overflow corrupting heap metadata
- Freeing memory not from malloc/new
⚡ Quick fix
- Build with -fsanitize=address -g and run again
- Use std::unique_ptr/std::vector instead of raw new/delete
- Set pointers to nullptr after free
Detailed fix by platform
Shell
- cpp
g++ -g -fsanitize=address -fno-omit-frame-pointer main.cpp -o app && ./app valgrind --leak-check=full ./app
How to diagnose
- ASan — Report of first invalid free/write
- Ownership — Who frees the memory?
🔧 Still not fixed?
Many errors look alike. If the steps above didn’t solve it, one of these is probably what you’re facing:
Similar errors
- 0xC0000005 The application was unable to start correctly (0xc0000005) / Exception code 0xc0000005 access violation
- 0xC0000142 The application was unable to start correctly (0xc0000142)
- attempted to access privacy-sensitive data without a usage description This app has crashed because it attempted to access privacy-sensitive data without a usage description
Other ways to find it
🧠 Still stuck? Analyze your error
Paste the full message, response headers or stack trace — we'll detect the platform and point to the most likely cause.
Was this page helpful?
Report a correction or suggest an improvement
Last updated 7 Oct 2026