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
Sporadic SIGSEGV in src/unix/stream.c #425
Comments
What version of libuv is that? Going by the line numbers, it's not the most recent release. Can you try a debug build and post the output of |
I believe we're running libuv 1.3 -- I'll investigate whether we can upgrade easily. uv__write (stream=0x7fffb8000a90) at src/unix/stream.c:841 (gdb) print req |
Libuv follows semver so an upgrade should be a drop-in replacement.
|
I updated to libuv 1.6.1, saw the crash again. Looks like the same basic issue (bufs is NULL) Program received signal SIGSEGV, Segmentation fault. (gdb) info locals (gdb) p req Thanks for the handle close idea -- I'll investigate. |
Quick sanity check: there is no chance you're reusing |
|
Ah, that's not right. None of the APIs are thread-safe unless stated
— |
Can you clarify this? If you have one thread driving uv_run (which blocks in the default run mode), how should one then call uv_write?
|
As a result of any other operation, such as a connection was made, data was received, a timer kicked in, etc. None of the loop or handle APIs are thread-safe, the only exception is |
Thanks for the clarification. |
@saghul , as a developer coming from *nix select/epoll background, I like to get a bit more clarification on the "single threaded network I/O " nature of libuv. And the req is : Thanks in advance, |
@franknj You cannot call |
@bnoordhuis , thanks for clarification. That is a big difference from select/epoll based approach. |
I run into this same problem for blindly reusing the @saghul I think it would be useful to mention in the documentation that |
@neevek mind submitting a documentation PR? |
@saghul I will do it later. |
After the callback fires it should be fine to reuse it, if not, there is a bug somewhere. A test case would definitely help. |
@saghul Your are right, it was a bug in my code. And I just submitted a documentation PR~ |
I can't provide a consistent repro case for this, but I've noticed that after some thousands of reads and writes to a TCP socket stream using libuv, I encounter a segmentation fault. Here's the backtrace from gdb:
From what I can, the problem is in this line:
uv_buf_t* buf = &(req->bufs[req->write_index]);
It looks like bufs is already null:
(gdb) p req-> bufs
$34 = (uv_buf_t *) 0x0
Looking through the code, it looks like req->bufs is cleared or not cleared depending on whether write succeeds. Is it possible I'm unintentionally ignoring some error status and causing this?
Thanks for any suggestions.
The text was updated successfully, but these errors were encountered: