The socket may get released if the sock_poll_event() is inspired by closing socket.
Here is a WIP test (where I am trying to test unrelated things) which causes assert in wineserver on closing socket (when server is trying to use already freed socket): https://gist.github.com/gofman/cc78a07ed58f6d02ff863388d5992acb
From: Paul Gofman pgofman@codeweavers.com
--- server/sock.c | 3 +++ 1 file changed, 3 insertions(+)
diff --git a/server/sock.c b/server/sock.c index 77a88a7fcf7..48ebf59ed88 100644 --- a/server/sock.c +++ b/server/sock.c @@ -1109,6 +1109,8 @@ static void sock_poll_event( struct fd *fd, int event ) int error = 0;
assert( sock->obj.ops == &sock_ops ); + grab_object( &sock->obj ); + if (debug_level) fprintf(stderr, "socket %p select event: %x\n", sock, event);
@@ -1188,6 +1190,7 @@ static void sock_poll_event( struct fd *fd, int event ) complete_async_polls( sock, event, error );
sock_reselect( sock ); + release_object( &sock->obj ); }
static void sock_dump( struct object *obj, int verbose )