Skip to content

Assert in debug build when memory_pool alloc/dealloc in certain order #111

@jwdevel

Description

@jwdevel

Below is a simple test that fails for me on the debug build.
I get the error:

[foonathan::memory] Assertion failure in function allocate (.../foonathan-memory/src/detail/free_list.cpp:444): Assertion "last_dealloc_prev_ == prev" failed.

I am not sure if this is a genuine error that the debug build is detecting, or if it is an error introduced by the different behavior present in debug builds...

typedef foonathan::memory::memory_pool<> MyPool;
MyPool pool(100, 1024);
auto p1 = pool.allocate_node();
auto p2 = pool.allocate_node();
pool.deallocate_node(p1);
pool.deallocate_node(p2);

p1 = pool.allocate_node();
p2 = pool.allocate_node();  // <-- assertion happens here
pool.deallocate_node(p1);
pool.deallocate_node(p2);

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions