mercredi 27 décembre 2017

Rust benchmark throws invalid memory reference error

I have some Rust code, and when I tried to do some testing, it give me good and correct results using normal tests, but when I run some benchmarks, it throws signal: 11, SIGSEGV: invalid memory reference error. Here is the same test both as a normal test and as a bench test.

// works fine!
#[test]
fn mul_test() {
    let r = Point::new();
    let x = Element::zero();
    let scalar: [u8; 48] = [// 48 values];

    let res = Point::mul(&r, &x, &scalar[..]);
    println!("{:?}", res);
}

// throws error
#[bench]
fn mul_bench(b: &mut Bencher) {
    let r = Point::new();
    let x = Element::zero();
    let scalar: [u8; 48] = [// 48 values];

    b.iter(|| Point::mul(&r, &x, &scalar[..]));
}

I know that there isn't much code provided here, but it is all nested structures, and posting all the code that is relevant for these tests, will require posting a huge amount of code. But as I said, the mul_test test works fine, and gives me correct result. But, the mul_bench benchmarks throws invalid memory reference error. What could possibly cause it?

Aucun commentaire:

Enregistrer un commentaire