Hi, I’m a beginner to Rust, (not a beginner to systems programming, but I’m still just a college student). I’ve been writing a simple matrix class in unsafe Rust, and I’ve been running into weird errors with
cargo test. About 1/4 of the time,
cargo test runs successfully and passes all the tests I’ve written. The other 3/4 of the time (approximately), it segfaults at some point within the execution of the tests, or after all of the tests have run. Running the compiled test program in gdb, the segfault always occurs in the execution of
clone() from within
start_thread(). Now, I’m pretty experienced with understanding C and the assembly it generates, but I do not know what the problem is here. Is this an issue with my code? I’m not doing any multithreading, so I would assume
cargo test is running the tests in parallel, and that sometimes these threads are having some sort of memory error? I could really use some help debugging this.
I’m running rustc 1.5.0-nightly 2015-10-16, cargo 0.6.0-nightly 2015-10-17. My library code is here on GitHub: https://github.com/peterdelevoryas/linear-rs. Inside the repository is lib.rs, containing all of my library code and the test module, and two log files: gdb_log, containing the output of two executions through gdb, and test_log, showing the output from a few executions of
cargo test. Also, I noticed gdb states the code is using my system’s libthread_db library file, so perhaps this is specific to my computer? I’m running x86_64 Arch Linux 4.1.6-1 on a late 2008 Aluminum Macbook (I believe it’s called the Macbook 5-1).