Hi, I have hit what I believe is UB and since I am not using any unsafe myself, I believe this results from some issues with nalgebra. The nasal demons take the shape of a unit test which is intermittent despite not having any randomness in it, with different patterns of success depending if I run it along with other unit tests (always fails) or alone (by filtering it by name), in which case it succeeds if I println!
some of the matrices involved or succeeds/fails randomly if I don’t. I haven’t had to deal with any UB in rustland until now, but this resembles what I used to see in C++ too much… The error started appearing after I refactored my code to cache some matrices inside a struct instead of recomputing them inside a repeatedly called method.
Before I open an issue on github I would like to ask what kind of information should I provide to make it the easiest for you? Because of its heisenbug behavior, it’s difficult to create a minimal repro case. It’s also not obvious if you would even see the same behavior on your machine. That being said, this is the test which is intermittent for me and it depends on whether I print my MatrixCache
here or not. The always failing version is cargo test
and the intermittent one is cargo test _4
.
One particularly scary and suspicious operation I do is selecting columns (in fitting.rs::build_m) from a dynamic matrix stored in a lazy_static
(defined in cubicfit.rs::M_8). Could it be that matrices somehow misbehave when used in lazy_static
contexts?