Make analysis/test miri-compatible and add a miri test for it
#686
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #685.
This makes
analysis/testmiri-compatible when running with--features miri. This is done by using a monomorphicprintfshim, sincemirican't handle variadic functions likeprintf. Since all uses ofprintfinanalysis/testare monomorphic (they all have the same format string), we can substitute afn printfthat 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-pdgthat runsmirionanalysis/testto 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 runningmiriin CI (it installsxargoevery time and I'm getting a permission denied error (not sure from quite what exactly), and it'd be better to installxargoupfront, 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).