Fix Rust UB problems (#6393)

* Fix miri problems by assuming alignment is 1 in rust

* Removed is_aligned fn from rust verifier.

* Add back is_aligned, but make it w.r.t. buffer[0]

* touch unused variable

* touch unused variable

* +nightly

* Move Rust miri testing into its own docker

* fix bash

* missing one endian conversion

* fix endianness2

* format stuff

Co-authored-by: Casper Neo <cneo@google.com>
This commit is contained in:
Casper
2021-01-11 15:24:52 -05:00
committed by GitHub
parent 39e115fdb4
commit 408cf58024
17 changed files with 540 additions and 197 deletions

View File

@@ -108,6 +108,7 @@ fn store_vec_uint_16() {
);
}
#[cfg(not(miri))] // slow.
quickcheck! {
fn qc_f32(x: f32) -> bool {
let fxb = singleton(x);

View File

@@ -15,5 +15,6 @@
mod binary_format;
mod interop;
mod other_api;
#[cfg(not(miri))] // slow.
mod qc_serious;
mod rwyw;

View File

@@ -13,9 +13,11 @@
// limitations under the License.
use flexbuffers::*;
#[cfg(not(miri))] // slow.
use quickcheck::QuickCheck;
#[test]
#[cfg(not(miri))] // slow.
fn qc_reader_no_crash() {
fn no_crash(xs: Vec<u8>) -> bool {
let r = Reader::get_root(&xs);

View File

@@ -14,6 +14,7 @@
// Read what you wrote.
use flexbuffers::*;
#[cfg(not(miri))] // slow.
use quickcheck;
use serde::{Deserialize, Serialize};
@@ -33,6 +34,7 @@ impl quickcheck::Arbitrary for NonNullString {
}
}
#[cfg(not(miri))] // slow.
quickcheck! {
fn qc_vec_bool(xs: Vec<bool>) -> bool {
let mut builder = Builder::default();
@@ -363,6 +365,8 @@ struct Foo {
c: Vec<u32>,
d: String,
}
#[cfg(not(miri))] // slow.
quickcheck! {
fn serde_foo(a: i8,
b: f64,