-
Notifications
You must be signed in to change notification settings - Fork 35
Make sure pointers are correctly aligned in os_mmap_aligned() #84
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
Make sure pointers are correctly aligned in os_mmap_aligned() #84
Conversation
58d296a
to
23a96a5
Compare
|
||
size_t head_len = aligned_addr - addr; | ||
if (head_len > 0) { | ||
// head_len has to be page-aligned, because aligned_addr has to be page-aligned | ||
assert_is_page_aligned(head_len, page_size); |
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.
Why do we just crash? Assert indicates a mistake in the code logic. Is this condition only possible by mistake? what if the page size 4kb and the requested alignment 6kb?
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.
Code changed.
Done.
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.
BTW tests added in a separate PR: #93
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.
I still only see asserts and not the INVALID_ARGUMENT error code.
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.
Assert indicates a mistake in the code logic. Those conditions are possible only by mistake.
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.
I meant those asserts verify if os_alloc()
passed a correct alignment. A user cannot trigger them changing the input alignment. All required checks are done in os_alloc()
and os_alloc()
passes only a correct alignment to this function. So IMHO those asserts are correct.
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.
Ah yes, sorry, I missed the PR that changed the checks in os_alloc.
c834b71
to
192d1df
Compare
Requires: |
Signed-off-by: Lukasz Dorau <[email protected]>
Signed-off-by: Lukasz Dorau <[email protected]>
192d1df
to
f3ede04
Compare
Rebased |
Ref: #74 (comment)