Cargo test crash on Windows with access

Hi All,

I'm starting work on my first commerical project with Rust after doing a few trials without issue but I've hit a snag.

This project is on Windows and I've tried Rust 1.45 and 1.46 and right now it is just reading some data out of an sqlite database. I've tried rusqlite and sqlite crates and both give the same behaviour.

The program itself runs with any issues. However running cargo test crashes with an access violation.

I suspected the sqlite interface so I removed all but a trivial test which adds two numbers and the crash still happens. Sometimes rusqlite fails to build - but not consistently which is also very strange.

Where should I start with troubleshooting this?

By default each tests are runs in parallel with cargo test. Don't tests access into same sqlite concurrently? Does the sqlite allows such access?

Hi Hyeonu,

Good thought. Unfortunately, right now I have excluded all of the code from the tests. The only test in the project is:

#[cfg(test)]
mod tests {

    #[test]
    fn test_add() {
        assert_eq!(1+2,3);
    }
}

Most likely I won't be able to help but to make it easier for others to spot the problem, what is the full output when you run

cargo test test_add

?

Can you reproduce the problem with a basic hello world project with just the test above?

1 Like

Weird - I tried cargo test test_add and that worked. When I go back to cargo test that also now works!

I tried re-introducing the sqlite library into a test and it is still working.

So no idea why - but thanks!

OK so this is back again. Will probably just jump on a Linux VM to get this done but I:

  1. Created a new project with cargo init
  2. Edited main.rs so it looks like this:
    fn main() {

        println!("Hello, world!");

    }

    #[cfg(test)]

    mod tests {

        use super::*;

        #[test]

        fn test_add() {

            assert_eq!(1+2,3);

        }

    }
  1. cargo test and I get the access violation.

The active toolchain is given as:

active toolchain
----------------

stable-x86_64-pc-windows-msvc (default)
rustc 1.46.0 (04488afe3 2020-08-24)

cargo run works just fine so I guess the basics of the toolchain must be OK.