Skip to content

SIGSEGV #103

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
maciejhirsz opened this issue Jan 3, 2017 · 5 comments
Closed

SIGSEGV #103

maciejhirsz opened this issue Jan 3, 2017 · 5 comments
Labels

Comments

@maciejhirsz
Copy link
Owner

maciejhirsz commented Jan 3, 2017

Need to find a way to reproduce, as it apparently happens on stable Rust: rust-lang/rust#38687

edit: running cargo test --test value reproduces the issue

@maciejhirsz maciejhirsz added the bug label Jan 3, 2017
@meh
Copy link

meh commented Jan 4, 2017

@maciejhirsz you should try and use american fuzzy lop, it works wonders, would you accept a pull request that sets that up?

(Although it probably wouldn't have found this :P)

@maciejhirsz
Copy link
Owner Author

Would definitely accept a PR. Even if it can't find this particular issue, there had been others issues in the past.

@dtolnay
Copy link

dtolnay commented Jan 16, 2017

I wonder what is changing on the compiler side to affect this. On my computer:

while cargo +1.12.0 test --test value; do :; done # does not fail
while cargo +1.13.0 test --test value; do :; done # does not fail
while cargo +1.14.0 test --test value; do :; done # fails almost immediately
while cargo +beta test --test value; do :; done # fails almost immediately
while cargo +nightly test --test value; do :; done # does not fail

@maciejhirsz
Copy link
Owner Author

Interesting thing is that I'm unable to reproduce it on OSX, but I can reproduce it on a Linux machine.

@maciejhirsz
Copy link
Owner Author

Identified the problem. I was playing with fire and got humbled by the compiler once I tried rewriting object.rs to safe rust at cost of performance to see if that eliminates the segfault.

I wrongly attributed the borrow lifetimes to be call scope instead of bound to the Node here:

json-rust/src/object.rs

Lines 100 to 112 in 9eabb90

#[inline(always)]
fn key<'a>(&self) -> &'a [u8] {
unsafe {
slice::from_raw_parts(self.key_ptr, self.key_len)
}
}
#[inline(always)]
fn key_str<'a>(&self) -> &'a str {
unsafe {
str::from_utf8_unchecked(self.key())
}
}

Fix and new release should follow shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants