Skip to content
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

Size requested from sbrk is not the actual size needed. #9155

Open
patacongo opened this issue May 2, 2023 · 0 comments
Open

Size requested from sbrk is not the actual size needed. #9155

patacongo opened this issue May 2, 2023 · 0 comments

Comments

@patacongo
Copy link
Contributor

Originally, there was logic like the following for KERNEL mode in mm/mm_heap/:

  brkaddr = sbrk(size);

When we modified this to handle the case of size == 0, this became:

  brkaddr = sbrk(size < 1 ? 1 : size);

But there still could be an issue here. Not just for size < 1 for for all sizes. The sizes don't include quantization overhead, or the overhead from the memory header. So the amount of memory requested is smaller than that which is actually needed. If nothing else, that does leave me a little uneasy.

I am thinking it should be like:

  chunksize = size < MM_MIN_CHUNK ? (size + (MM_MIN_CHUNK - 1)) % MM_MIN_CHUNK
  brkaddr = sbrk(chunksize);

But I have not looked at the detailed logic in sbrk to see how it handles the size. Perhaps there is no problem. This issue is simply to verify that that is the case.

As has been pointed out MM_MIN_CHUNK is not valid for tlsf_realloc(). But even if tlsf_realloc() and mm_realloc() are different in this way, that would not change the issue, that would just make any solution that might be needed more difficult (and I'm not even certain that any solution is needed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant