-
Notifications
You must be signed in to change notification settings - Fork 30
remove the custom allocator #124
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
Conversation
|
I find the motivation for doing this very strong. The sooner we can turn on Valgrind and ASan in CI, the sooner we can be systematically ratcheting safety upward. |
c94f73d to
33a101b
Compare
|
We have 2 possibilities: either merge #113 first, which renames the usages of alloc in cdb code, or we just remove it. Either way, we have to touch that anyway as otherwise the |
33a101b to
316fa25
Compare
316fa25 to
c17daa8
Compare
cdbmss.c
Outdated
| uint32 u; | ||
|
|
||
| if (!cdbmake_split(&c->cdbm,alloc)) return -1; | ||
| if (!cdbmake_split(&c->cdbm,malloc)) return -1; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as previous
c24c897 to
cf0b2ac
Compare
cf0b2ac to
0c56b6d
Compare
865ed34 to
6727a89
Compare
Both of these functions are only called from a single place, where both pass in the alloc() function. The parameter was also named alloc, which can cause compiler warnings when -Wshadow is enabled. Simply remove the parameter, which makes everything work exactly as before.
* it's as simple as possible, probably intentional. This makes things like alloc_re() (i.e. realloc()) inefficient as it does not look if the thing it reallocates is already the last thing in the batch, and simply extends that, or if alloc_free() has the last block and adds things back to the pool (ideally with zeroing for security reasons). * it makes it basically impossible to detect overruns on early small allocations with tools like valgrind, address sanitizer or friends as those allocations never hit malloc(), so are never traced by any custom tools. Any overrun will just go into the next variable, untracable. * allocators do their own buffering, alignment, and so on. If they are broken, your system is severely screwed. And if we need more money^H^H^H^Hemory we will hit that buggy allocator anyway, making things harder to detect as it will only happen on "heavy" memory usage. This is not TruOS, SunOS 1.x or something like that anymore. We expect a reasonably sane OS. Everything else will get us screwed in much more severe ways. * it has shown issues when coming close to 4GiB allocations (#37, #109, older reports). DJB correctly says that an allocation of that size in your mailer shows that you have already done something wrong, but still: 64 bit platforms are the default, so using a 32 bit type to pass allocation sizes is a bug of it's own. * when any additional patch accidentially mixes calls to this functions with normal realloc()/free() this can lead to random crashes * why bother at all with having a custom allocator?
6727a89 to
1720e0b
Compare
Fixes #112