Closed mcourteaux closed 7 months ago
Okay it's my bad. The small repro here is like this:
struct Foo {
void destroy_and_dealloc();
memory::any_allocator_reference alloc;
}
void Foo::destroy_and_dealloc() {
memory::any_allocator_reference copy_ref = alloc; // copy ref before calling destructor.
this->~Foo();
alloc.deallocate_node(this, sizeof(Foo), alignof(Foo));
}
I accidentally still used the alloc
member field instead of my safe copy.
When making a Debug build (cmake) of my project using foonathan::memory under G++-12, I got an exception attempting to call a pure virtual function. More specifically, I was having an
memory::any_allocator_reference
to amemory::new_allocator
on which I called.deallocate_node()
, which somehow attempts to calldeallocate_node
on thebase_allocator
. Here is the relevant gdb backtrace:I spent a lot of time looking at the code, but all of the one-liner redirects and traits makes it impossible for me to figure out what's going on.