-
-
Notifications
You must be signed in to change notification settings - Fork 113
-
-
Notifications
You must be signed in to change notification settings - Fork 113
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Infinite loop in osmium::memory::Buffer::reserve_space #202
Comments
This avoids an infinite loop in reserve_space(). See #202.
Looks like I didn't expect anybody to choose a zero capacity. This is fixed in 7685449 by using a minimum capacity for the buffer. If you don't want to switch, you can use a non-zero capacity yourself. |
Were there any reason to use a growth factor = 2 rather than 1.5 as an example here FBVector.md? |
@botanegg I didn't think too much about it. The reasoning in FBVector.md is interesting, but I don't think it is particularly important. You don't just allocate one vector/buffer and keep it around a long time, but a typical program will have many of them being allocated and deallocated, etc. So memory can just be reused for something else. Maybe somebody wants to benchmark this? |
This avoids an infinite loop in reserve_space(). See #202.
I catch an inf loop by simple code using
Buffer(size_t capacity, auto_grow auto_grow = auto_grow::yes)
ctorBuffer(size_t capacity, auto_grow auto_grow = auto_grow::yes)
usesnew unsigned char[capacity]
and set m_memory to non-null (that is "valid buffer"), however m_capacity is 0;Because m_capacity is 0 reserve_space is infinite:
Simple fixing
m_memory(capacity ? new unsigned char[capacity] : nullptr)
leads to assertionThe text was updated successfully, but these errors were encountered: