Skip to content

Fix invalid pointer casting#750

Merged
wenyuzhao merged 1 commit intommtk:masterfrom
wenyuzhao:fix-map32-ptr-cast
Feb 7, 2023
Merged

Fix invalid pointer casting#750
wenyuzhao merged 1 commit intommtk:masterfrom
wenyuzhao:fix-map32-ptr-cast

Conversation

@wenyuzhao
Copy link
Copy Markdown
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
Copy Markdown
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