-
Notifications
You must be signed in to change notification settings - Fork 261
Make analysis/test
miri-compatible and add a miri
test for it
#686
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
Conversation
analysis/test
miri-compatible and add a miri
test for it
Fixes #680. See the commits for the individual fixes. The fixes are: * 2 use after frees: 429962d, 95e483d * 2 uninitialized reads: 50b1bb4, f6e5bce * 2 nullptr derefs: f96bcb2, 69de3c3 Now `cd analysis/test && cargo miri run` reports no UB. However, `miri` can't run variadic functions like `printf`, so running this requires the monomorphic `printf` shim in #686.
c02f3e4
to
8c42e54
Compare
…so that it works with `miri`. This works in `analysis/test` because all `printf`s are monomorphic.
…rintf` shim is defined instead.
…i run --features miri`.
…at it's used to test `analysis/test`.
… running `miri` (which installs `xargo`) in CI. The test can still be manually run with `cargo test -p c2rust-pdg -- --ignored analysis_test_miri`.
8c42e54
to
4152d34
Compare
There are issues with running |
Fixes #685.
This makes
analysis/test
miri
-compatible when running with--features miri
. This is done by using a monomorphicprintf
shim, sincemiri
can't handle variadic functions likeprintf
. Since all uses ofprintf
inanalysis/test
are monomorphic (they all have the same format string), we can substitute afn printf
that is non-extern "C"
, non-variadic (and thusmiri
-compatible), and that still has the same behavior for its call sites.Then we add a test in
c2rust-pdg
that runsmiri
onanalysis/test
to ensure it stays UB-free.However, we don't yet run this test by default (it's
#[ignore]
d for now) as there are issues with runningmiri
in CI (it installsxargo
every time and I'm getting a permission denied error (not sure from quite what exactly), and it'd be better to installxargo
upfront, not on every run). Thus, I'm#[ignore]
ing it for now in 4152d34. We can get it to run in CI correctly later in another PR, but I want to merge this now and avoid over-complicating it here. The test can still be manually run withcargo test -p c2rust-pdg -- --ignored analysis_test_miri
. See #698 for the tracking issue to re-enable this test by default.The new test passing is blocked on:
analysis/test
#683 (f ixes Fix UB inanalysis/test
#680)analysis/test
#684 (f ixes Fix non-intentional memory leaks inanalysis/test
#681)It would also be nice to f ix #682, but that's not completely necessary for this (though it would create a much less noisy output).