Test failing for unknown reason


All I can see is

error: An unknown error occurred

build log - https://travis-ci.org/mmrath/rbuf

Individually all tests are passing locally. but cargo test is failing locally as well for same reason as travis


Not sure if I looked at the right place, but the log there has a segfault towards the end.


It is a plain old segfault. Fortunately your crate only has 2 lines of unsafe code so we know the bug must be in one of those.

unsafe {
    let val = self.values[index].swap(&mut None, Ordering::SeqCst);

Here the None is part of the stack frame of this function and goes out of scope, which leaves &mut None (of type *mut Option<V>) as a dangling pointer.


@dtolnay Thank you very much. I was wondering why the behaviour is not consistent, this answers. I will try to resolve.


You’ve got to love how Rust makes it so easy to find memory issues…


Coming from Java, this is so different though. I was finally able to resolve the problem.