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

Misaligned metadata #888

Closed
wks opened this issue Aug 5, 2023 · 1 comment · Fixed by #887
Closed

Misaligned metadata #888

wks opened this issue Aug 5, 2023 · 1 comment · Fixed by #887

Comments

@wks
Copy link
Collaborator

wks commented Aug 5, 2023

On i686-unknown-linux-gnu, the metadata spec mmtk::util::metadata::side_metadata::spec_defs::MS_FREE (aliased as mmtk::policy::marksweepspace::native_ms::block::Block::FREE_LIST_TABLE) has the offset.rel_offset field holding the value 150081 (0x24a41) which is not 4-byte aligned. As a result, its meta_addr is 0x40024a41 on the DummyVM. It will be an error when loading the free list pointer (usize which is 4 bytes) from that metadata using unaligned pointer. The error passed silently on Rust 1.66.1, but will panic on 1.71.0 because of unaligned pointer access.

If the MS_FREE metadata is intended to store 4-byte elements, the metadata itself should be 4-byte aligned. Since the metadata specs are constants, the bug should be in the computing of the relative offset or the starting address of the metadata.

@wks
Copy link
Collaborator Author

wks commented Aug 5, 2023

The reason is that the CHUNK_MARK local side metadata occupies only one byte per chunk, and local metadata are allocated in a per-chunk basis. That caused subsequent local side metadata to be misaligned.

I have added a fix in #887

@wks wks closed this as completed in #887 Aug 7, 2023
wks added a commit that referenced this issue Aug 7, 2023
`align_offset_alloc` and related functions now use
`ptr::{read,write}_unaligned` to access the prepended address.

When calculating the address or offset of metadata, we ensure its
address or offset is at least word-aligned.

Fixes: #886
Fixes: #888

---------

Co-authored-by: Yi Lin <qinsoon@gmail.com>
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 a pull request may close this issue.

1 participant