Finding Hidden Memory Bugs in PostgreSQL with Custom Memory Allocators
summary
A custom malloc-based allocator bypasses AllocSet freelists and routes allocations through the system allocator so ASan poisoning actually happens; integrating it as a memory-context implementation lets AddressSanitizer flag real frees during normal regression runs. The method uncovers three critical use-after-free bugs across PostgreSQL v16–v18, produces allocation/deallocation/access stacks, and results in upstream fixes; the allocator is slower by design but reliably exposes freelist-hidden lifetime bugs.
AI-written summary · about
chapters (10)
- 0:00Introduction to talk
- 1:11PostgreSQL memory contexts
- 3:23Memory issues in PostgreSQL
- 7:16PostgreSQL allocators overview
- 9:04AddressSanitizer limitations
- 13:01PostgreSQL memory safety tools
- 16:38Custom memory context solution
- 20:38Bugs found in PostgreSQL
- 24:10AddressSanitizer benefits
- 26:18Key takeaways
related talks
31mAll in a context!
45mEnhancing PostgreSQL Plasticity: New Frontiers in Memory Management
33mFinding and fixing a data-corruption bug...
56mPostgreSQL at low Level: stay curious!
32mDesigning and implementing a monitoring feature in PostgreSQL
50mHacking on Postgres: An Overview
01h 00mThe 10 Deadly PostgreSQL Sins
48mPractical Memory Tuning for PostgreSQL
