-
Notifications
You must be signed in to change notification settings - Fork 200
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Segfault when providing a very small initial block_size to constructor of memory pool #113
Comments
That is what |
Ok, but it's not clear that users must initialize |
I'll see what I can do to handle it more gracefully. |
That would be great! Otherwise mentioning it in the documentation would be fine as well I think. |
The behavior is now documented, and I've added more internal assertions in debug mode. The block size of a memory pool must be at least
That approach doesn't work as the next block size is based on the previous one, so a bigger block might not be big enough, and it needs yet another block etc. It also just wastes memory: the block size that is too small won't ever be used. |
Even though it doesn't make much sense to do so, if you provide a very small initial
block_size
argument to memory_pool's constructor, it segfaults. This stripped down version of the example in README.md crashes for me:If I change the
39
to40
it's all fine. It seems to be related to thenode_size
argument: to largernode_size
is, the largerblock_size
needs to be for it not to crash.Tested with:
When I compiled foonathan/memory in debug mode, the problem is caught in an assert and the following error is thrown:
[foonathan::memory] Assertion failure in function insert_impl (<path>/memory/src/detail/free_list.cpp:527): Assertion "no_nodes > 0" failed.
The text was updated successfully, but these errors were encountered: