Skip to content

fix malloc mmap implementation's header size#9

Open
veisveer wants to merge 1 commit intorockytriton:mainfrom
veisveer:main
Open

fix malloc mmap implementation's header size#9
veisveer wants to merge 1 commit intorockytriton:mainfrom
veisveer:main

Conversation

@veisveer
Copy link
Copy Markdown

@veisveer veisveer commented Mar 2, 2023

Hey!

I am working on a similar project and am taking some guidance.
I was looking through your malloc implementation and found a logical error.
In the mmap call, you seem to have mixed up HEADER_SIZE_MASK and HEADER_SIZE
This probably hasn't been tested. (as allocations over 128kb are rare)

old header size: 4294967288 bytes
new header size: 4 bytes
diff: -4294967284 bytes (:D)

There seems to be a bug in malloc's mmap implementation.
The old implementation used HEADER_SIZE_MASK, let the numbers speak:
old header size: 4294967288 bytes
new header size: 4 bytes
diff: -4294967284 bytes (:D)

Signed-off-by: chm46e <chm46e@duck.com>
@veisveer
Copy link
Copy Markdown
Author

veisveer commented Mar 2, 2023

Let me be clear, I'm a newcomer to memory management.

I found another logical error:
In the comment, you explain, that mmap chunk consists of only start header and data.
But in the next calls to set size and flags for the mmap chunk, it writes to both start header and end header.
The End header doesn't exist? (isn't allocated for & doesn't comply with comment).

So my proposals are:

  1. change mmap chunk's implementation to allocate for the end header
  2. check for FLAG_MEM_MAPPED in all header modifier functions

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

Successfully merging this pull request may close these issues.

1 participant