-
Notifications
You must be signed in to change notification settings - Fork 236
Segfault with html5ever when using it in golang with a signal handler #393
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
Comments
Are you able to get a more precise stack trace at the time of segfault? Perhaps with gdb? Are there multiple kernel threads in this process? Does more than one of them call into Rust code? Can they run at the same time, or does your reduced program only do one call into Rust? Is Rust code called from a signal handler? (I’m not familiar with Go but you mentioning a "signal channel" suggest that the handler only sends a message.) Is the unknown attribute name more than 7 bytes? If so That said, I still have no idea how this could be affected so badly by settings up an unrelated signal handler. |
Unfortunetaly no, the only stack trace that i got is this one:
I believe using compiler_builtins on 0.1.19 would give me a better stack trace (thanks to rust-lang/compiler-builtins@985a430), but don't really know how to build the whole toolchain to have it
I believe there are since i got this from gdb (but not an expert on this subject)
On our original program yes there are (since we are doing this on a web server that spawn threads),
Yes they can, but i made an example that is only doing one call so i don't think this is related
No it's not, in fact in the example i don't have an handler, i just created the signal, but maybe creating a signal will put following code into a different context (not sure either)
Yes it is, and confirming that having an unknown attribute name under 8 bytes does not create a segfault
Maybe not related to signal handler but everything that switch current thread (but not an expert on how golang does that :/) and thread-safe initialization is not done on the main thread so it segfault |
This looks like the Rust code in your program doesn’t have debug info. Do you call Cargo with Removing
Short strings are kept inline by
… and this suggests a problem related to initialization with
The goal of |
No i'm using the debug version see https://github.com/joelwurtz/segfault-golang-with-rust/blob/master/main.go#L4 which got the bug |
Thanks to nagisa for investigating in rust-lang/rust#64834. I can reproduce a segfault when creating a dynamic atom with a small stack: fn main() {
std::thread::Builder::new().stack_size(50_000).spawn(|| {
string_cache::DefaultAtom::from("12345678");
}).unwrap().join().unwrap()
} Running target/debug/deps/small_stack-128211424cdfd6be
thread '<unknown>' has overflowed its stack
fatal runtime error: stack overflow
error: process didn't exit successfully: `/home/simon/projects/servo-deps/string-cache/target/debug/deps/small_stack-128211424cdfd6be small` (signal: 6, SIGABRT: process abort signal) servo/string-cache#227 fixes it for me. Could you try it? See https://doc.rust-lang.org/cargo/reference/specifying-dependencies.html#overriding-dependencies about overriding the |
Fix initializing the global hash map with a small stack Fix servo/html5ever#393 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/string-cache/227) <!-- Reviewable:end -->
Yes it works, thanks a lot for fixing this |
This is really a weird bug that occurs on one of our program, i managed to make a reproduce small example under this repository: https://github.com/joelwurtz/segfault-golang-with-rust
What it does:
LocalName::from(&*attribute_name)
call with a not defined local nameThis result in a segfault 100% of the time
There a some workaround for this:
I really don't know what happens inside and it's really difficult to trace it due to the way of compiling this.
I'm pretty sure this is a race case on rust lang and will do also an issue there.
The text was updated successfully, but these errors were encountered: