-
Notifications
You must be signed in to change notification settings - Fork 551
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
call sock_accept(or sock_recv) and close sock before next uv loop will cause entire program core dump #100
Comments
Maybe we could use a |
it's very helpful to me! |
There's not much we can do here. uvloop can't detect/intercept I filed an issue to add new API to CPython https://bugs.python.org/issue32038 to intercept |
@saghul Do you think it's possible to fix epoll code in libuv like this? diff --git a/src/unix/linux-core.c b/src/unix/linux-core.c
index 4d480ce1..29ca3fe2 100644
--- a/src/unix/linux-core.c
+++ b/src/unix/linux-core.c
@@ -241,6 +241,10 @@ void uv__io_poll(uv_loop_t* loop, int timeout) {
* events, skip the syscall and squelch the events after epoll_wait().
*/
if (uv__epoll_ctl(loop->backend_fd, op, w->fd, &e)) {
+ if (errno == EBADF) {
+ uv__io_stop(loop, w, POLLIN | POLLOUT | UV__POLLRDHUP | UV__POLLPRI);
+ continue;
+ }
if (errno != EEXIST)
abort(); |
@1st1 I filed an issue months ago (https://bugs.python.org/issue30996). |
Good news! It appears there's undocumented API for preventing socket objects from closing. uvloop will no longer crash. The fix will be in the next release (soon). |
Please try uvloop v0.9.0. |
PYTHONASYNCIODEBUG
in env?: yesHi all,
call
sock_accept
andclose
sock before nextuv
loop will cause entire programcore dump
. Becauseepoll
will returnEBADF
iflibuv
try register closed socket, thenlibuv
will callabort
. https://github.com/libuv/libuv/blob/7452ef4e06a4f99ee26b694c65476401534f2725/src/unix/linux-core.c#L225-L227Run any code below directly can reproduce
core dump
.Core dump
may cause programs hard to debug and make programmer take more time to find the root bug source.If I don't use
uvloop
(commentasyncio.set_event_loop(uvloop.new_event_loop())
), all code below will be fine.sock_accept
sock_recv
gdb backtrace
The text was updated successfully, but these errors were encountered: