-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
Segmentation fault on Sierra #164
Comments
Does the same happen with How did you install Can you run What if you run |
No. 0.2.1 works right.
Manually. I downloaded the x86_64 darwign package, and copied
Yes.
Same. Segfault. |
I can reproduce this on Yosemite:
|
This looks like the specific point of failure:
This points back into the implementation of |
I can reproduce this when compiling from source, but only on Mac, not Linux. |
A debug build does not segfault. |
sigh It looks like this is happening because of thread locals. I don't believe I'm misusing them, but if I remove the thread local, things work again. |
To clarify, I changed this code: pub fn matched_stripped(&self, path: &Path, is_dir: bool) -> Match {
thread_local! {
static MATCHES: RefCell<Vec<usize>> = {
RefCell::new(vec![])
}
};
MATCHES.with(|matches| {
let mut matches = matches.borrow_mut();
let candidate = Candidate::new(path);
self.set.matches_candidate_into(&candidate, &mut *matches);
for &i in matches.iter().rev() {
let pat = &self.patterns[i];
if !pat.only_dir || is_dir {
return if pat.whitelist {
Match::Whitelist(pat)
} else {
Match::Ignored(pat)
};
}
}
Match::None
})
} to this: pub fn matched_stripped(&self, path: &Path, is_dir: bool) -> Match {
let mut matches = vec![];
let candidate = Candidate::new(path);
self.set.matches_candidate_into(&candidate, &mut matches);
for &i in matches.iter().rev() {
let pat = &self.patterns[i];
if !pat.only_dir || is_dir {
return if pat.whitelist {
Match::Whitelist(pat)
} else {
Match::Ignored(pat)
};
}
}
Match::None
} |
Compiling with Rust stable works. Compiling with Rust beta or nightly yields the sigsegv above. |
Not sure if (still) relevant, but I found this. |
@elmart Hmm that looks related to OS X 10.6 or older. |
I can't seem to come up with a minimally reproducible example. Trying this works fine on Rust beta/nightly on Mac: use std::cell::RefCell;
fn foo(n: usize) -> bool {
thread_local! {
static MATCHES: RefCell<Vec<usize>> = {
RefCell::new(vec![])
}
};
MATCHES.with(|matches| {
let mut matches = matches.borrow_mut();
matches.clear();
for i in 0..n {
matches.push(i);
}
for &i in matches.iter().rev() {
if i > 0 && i % 7 == 0 {
return true;
}
}
false
})
}
fn main() {
println!("{}", foo(::std::env::args().count()));
println!("{}", foo(::std::env::args().count() * 2));
} |
cc @alexcrichton Do you have any ideas about this? TL;DR - I'm seeing a segfault on macos (not Linux) from using thread locals on current Rust beta/nightly, but not on current Rust stable. Efforts to repro a small example have failed. :-( |
Oh dear, sounds quite suspicious! The only funkiness I know of with OSX and thread locals has to do with destructors maybe, but there's no interesting destructors here. @BurntSushi what's the current reproduction? (large or small). This is quite worrisome! |
@alexcrichton This should do it:
(I'm about to commit a work around that stops using thread locals, so this issue is hopefully going to get closed, but it's not because I've figured out the underlying problem. :-)) |
I've fixed this on master and will put out a (The fix was to switch to the |
The plot thickens! I can't seem to reproduce...
(no segfaults) |
ripgrep |
You're welcome. Thx for fixing it so quickly. |
I just installed release 0.2.2 on Sierra, and have a segfault when running
rg anything
.Core dump attached.
rg_2016-10-11-142243_Eliseos-MacBook-Pro.txt
The text was updated successfully, but these errors were encountered: