Use __heap_base by dlmalloc - #114
Merged
Merged
Conversation
bjorn3
reviewed
Oct 21, 2019
sunfishcode
reviewed
Oct 21, 2019
| if (!is_initialized(gm)) { | ||
| try_init_allocator(); | ||
| } | ||
| #endif |
Member
There was a problem hiding this comment.
Would it work to call this from within init_mparams instead? That way it'd get called for all entrypoints, not just malloc.
In that case, it shouldn't do ensure_initialization itself, but just do its work after init_mparams has done its work.
Contributor
Author
There was a problem hiding this comment.
Hmmm, I've though about it, but there are some clues:
ensure_initializationis used for mspace also (mspace is like arena in ptmalloc for different continuous space of allocations). At now, mspace is disabled, but if someone want to enable it, there will some unobvious problems. And it is logically incorrect.- Currently,
ensure_initializationis disabled indlmalloc, because it is inside#if USE_LOCKSthat is also disabled. And it is called intosys_alloc. But for our purpose it is important to have it initialized before main logic of chunk choosing indlmallocbeing called. => in case ofensure_initializationwe will need two augmentation (intoensure_initializationanddlmalloc) instead of one in current case. - On the other side this initialization into
dlmallocseems correct, because other entry points (realloc,calloc) in all important CFG paths will call it before any chunk manipulation. The only exception here isfree, but it is UB to callfreewithout any previousmalloc.
So, yes, it possible to move top chunk initialization into ensure_initialization, but it seems that it is better leave it as now.
What do you think?
Member
There was a problem hiding this comment.
Thanks for looking into that! I think what you have right now looks like a reasonable approach then.
sunfishcode
approved these changes
Nov 4, 2019
Member
|
Merging; thanks for implementing this! |
Contributor
Author
|
And mimalloc is on the way :) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Force dlmalloc to use free memory between __heap_base and initial. Some details described here.