Skip to content

Commit

Permalink
Fix miri validation errors through now stricter provenance (#103)
Browse files Browse the repository at this point in the history
* fix(miri): box transmute and invalid references

The general causes for the miri invalidation is the prevelant use of
`Box` and its references to `ErrorImpl<()>`.

`mem::transmute` does not preserve the tag stack for transmuting the
boxes.

Additionally, having references to `ErrorImpl<()>` which has a different
layout than the allocation or `ErrorImpl<E>` for some unknown `E`. This
causes the new "untyped" reference to now have a provenance that
includes the size of E and thus is outside the provenance.

* fix(miri): downcast_mut using `&mut _ => *const _ => *mut`

* fix(miri): stub file reading

* fix(miri): don't construct temp references of shunk provenance

* ci: miri

* fix: `unsafe_op_in_unsafe_fn`

* chore!: bump MSRV

* chore: address PR comments

* fix: ci workflow names

* chore: raise msrv to 1.65 (addr2line)

* chore: revert distinctive CI names due to branch protection rules

The new names, such as `Test Platform Matrix` which do make it easier to
see which jobs failed, rather than msrv, test, and miri all being called
`Test Suite`, the in-place branch protection rules wait forever until
the now non-existent `Test Suite` passes
  • Loading branch information
ten3roberts authored Sep 19, 2023
1 parent 2d984da commit 9f4ecc4
Show file tree
Hide file tree
Showing 10 changed files with 469 additions and 147 deletions.
19 changes: 18 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,9 @@ on:

name: Continuous integration

env:
MIRIFLAGS: -Zmiri-strict-provenance

jobs:
check:
name: Check
Expand Down Expand Up @@ -66,7 +69,7 @@ jobs:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: 1.42
toolchain: 1.65
override: true
- uses: actions-rs/cargo@v1
with:
Expand Down Expand Up @@ -126,3 +129,17 @@ jobs:
with:
command: clippy
args: -- -D warnings
miri:
name: Miri
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
components: miri
override: true
- uses: actions-rs/cargo@v1
with:
command: miri
args: test
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ pyo3 = { version = "0.13", default-features = false, features = ["auto-initializ

[dependencies]
indenter = "0.3.0"
once_cell = "1.4.0"
once_cell = "1.18.0"
pyo3 = { version = "0.13", optional = true, default-features = false }

[package.metadata.docs.rs]
Expand Down
4 changes: 2 additions & 2 deletions src/context.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use crate::error::ContextError;
use crate::error::{ContextError, ErrorImpl};
use crate::{ContextCompat, Report, StdError, WrapErr};
use core::fmt::{self, Debug, Display, Write};

Expand Down Expand Up @@ -158,7 +158,7 @@ where
D: Display,
{
fn source(&self) -> Option<&(dyn StdError + 'static)> {
Some(self.error.inner.error())
Some(ErrorImpl::error(self.error.inner.as_ref()))
}
}

Expand Down
Loading

0 comments on commit 9f4ecc4

Please sign in to comment.