You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@nuttx.apache.org by "patacongo (via GitHub)" <gi...@apache.org> on 2023/05/02 17:14:07 UTC

[GitHub] [nuttx] patacongo opened a new issue, #9155: Size requested from sbrk is not the actual size needed.

patacongo opened a new issue, #9155:
URL: https://github.com/apache/nuttx/issues/9155

   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).


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@nuttx.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org