Test failing for unknown reason

All I can see is

error: An unknown error occurred

https://github.com/mmrath/rbuf

build log - Travis CI - Test and Deploy Your Code with Confidence

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);
    bucket.push((*val).take().unwrap());
}

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.

3 Likes

@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...

4 Likes

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