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

Fix invalid pointer casting #750

Merged
merged 1 commit into from
Feb 7, 2023
Merged

Conversation

wenyuzhao
Copy link
Member

fl has type of &&CommonFreeListPageResource.

fl as *const _ as *mut _ will first implicitly convert fl to *const &CommonFreeListPageResource, then to *mut CommonFreeListPageResource. The second conversion from *const to *mut is incorrect.

Copy link
Member

@caizixian caizixian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’ve been debugging this with Wenyu. This looks good to me. Before this fix, the write is incorrect, and could sometimes be out of bound of the vector, corrupting the header of adjacent malloc’ed cells.

@wenyuzhao wenyuzhao merged commit bde20a5 into mmtk:master Feb 7, 2023
@wenyuzhao wenyuzhao deleted the fix-map32-ptr-cast branch February 7, 2023 04:44
wenyuzhao added a commit to wenyuzhao/mmtk-core that referenced this pull request Mar 20, 2023
`fl` has type of `&&CommonFreeListPageResource`.

`fl as *const _ as *mut _` will first implicitly convert `fl` to `*const
&CommonFreeListPageResource`, then to `*mut CommonFreeListPageResource`.
The second conversion from `*const` to `*mut` is incorrect.
@wenyuzhao wenyuzhao mentioned this pull request Sep 15, 2023
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.

2 participants