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 bug in validate_cast_and_convert_metadata #376

Merged
merged 1 commit into from
Sep 18, 2023

Conversation

joshlf
Copy link
Member

@joshlf joshlf commented Sep 13, 2023

Previously, validate_cast_and_convert_metadata incorrectly assumed
that, for slice DSTs, the trailing slice element would always have an
alignment at least as large as the outer type's alignment, and so there
would never be any padding added after the trailing slice. In this
commit, we rewrite validate_cast_and_convert_metadata to no longer
assume this behavior.

While we're here, we add the test_validate_rust_layout test, which
validates many of our assumptions about Rust's type layout against the
standard library to help catch mismatches like this in the future.

@joshlf joshlf marked this pull request as draft September 13, 2023 00:20
@joshlf joshlf force-pushed the fix-validate-cast-and-convert-metadata branch 3 times, most recently from d221456 to 27c0511 Compare September 13, 2023 04:38
@jswrenn jswrenn force-pushed the fix-validate-cast-and-convert-metadata branch 3 times, most recently from abe2e9d to 60777ef Compare September 15, 2023 21:04
@joshlf joshlf force-pushed the fix-validate-cast-and-convert-metadata branch 4 times, most recently from 2fb97bb to 91a1547 Compare September 18, 2023 22:01
@jswrenn jswrenn marked this pull request as ready for review September 18, 2023 22:02
jswrenn
jswrenn previously approved these changes Sep 18, 2023
Previously, `validate_cast_and_convert_metadata` incorrectly assumed
that, for slice DSTs, the trailing slice element would always have an
alignment at least as large as the outer type's alignment, and so there
would never be any padding added after the trailing slice. In this
commit, we rewrite `validate_cast_and_convert_metadata` to no longer
assume this behavior.

While we're here, we add the `test_validate_rust_layout` test, which
validates many of our assumptions about Rust's type layout against the
standard library to help catch mismatches like this in the future.
@jswrenn jswrenn merged commit 524b2e2 into main Sep 18, 2023
141 of 150 checks passed
@jswrenn jswrenn deleted the fix-validate-cast-and-convert-metadata branch September 18, 2023 22:14
joshlf added a commit that referenced this pull request Sep 19, 2023
In #376, we introduced `test_validate_rust_layout`, which took a long
time to run under Miri. In order to prevent it from consuming too much
time in CI, we marked it as `#[cfg_attr(miri, ignore)]`, and configured
CI to pass `-- --ignored` to Miri only a small percentage of the time.

This had the unintended side effect of running
`test_validate_cast_and_convert_metadata` under Miri. That test is
marked as `#[cfg_attr(miri, ignore)]` for good reason - it takes far too
long to run under Miri, and doesn't exercise any `unsafe` code, so
doesn't benefit from Miri. Enabling this test has caused CI to timeout.

In the interim, in #395, we optimized `test_validate_rust_layout` so
that it no longer takes an unreasonably long time to run under Miri.
Thus, in this commit, we remove the `#[cfg_attr(miri, ignore)]`
annotation from that test, and no longer pass `-- --ignored` to Miri in
CI.

Closes #397
joshlf added a commit that referenced this pull request Sep 19, 2023
In #376, we introduced `test_validate_rust_layout`, which took a long
time to run under Miri. In order to prevent it from consuming too much
time in CI, we marked it as `#[cfg_attr(miri, ignore)]`, and configured
CI to pass `-- --ignored` to Miri only a small percentage of the time.

This had the unintended side effect of running
`test_validate_cast_and_convert_metadata` under Miri. That test is
marked as `#[cfg_attr(miri, ignore)]` for good reason - it takes far too
long to run under Miri, and doesn't exercise any `unsafe` code, so
doesn't benefit from Miri. Enabling this test has caused CI to timeout.

In the interim, in #395, we optimized `test_validate_rust_layout` so
that it no longer takes an unreasonably long time to run under Miri.
Thus, in this commit, we remove the `#[cfg_attr(miri, ignore)]`
annotation from that test, and no longer pass `-- --ignored` to Miri in
CI.

Closes #397
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