-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
C API deadlock in hyper_executor::poll_next #3369
Comments
This was referenced Oct 23, 2023
Wow, thanks so much for the write-up, and finding this deadlock! Fixing that up shouldn't be too complicated. |
Oh, you even submitted a PR already, double thanks! |
seanmonstar
pushed a commit
that referenced
this issue
Oct 23, 2023
poll_next locks the driver, and also calls drain_queue while holding that lock. Since drain_queue locks the driver too, that results in a deadlock. To fix, unlock the driver before calling drain_queue. Closes #3369
0xE282B0
pushed a commit
to 0xE282B0/hyper
that referenced
this issue
Jan 12, 2024
poll_next locks the driver, and also calls drain_queue while holding that lock. Since drain_queue locks the driver too, that results in a deadlock. To fix, unlock the driver before calling drain_queue. Closes hyperium#3369
. nvm |
0xE282B0
pushed a commit
to 0xE282B0/hyper
that referenced
this issue
Jan 16, 2024
poll_next locks the driver, and also calls drain_queue while holding that lock. Since drain_queue locks the driver too, that results in a deadlock. To fix, unlock the driver before calling drain_queue. Closes hyperium#3369 Signed-off-by: Sven Pfennig <s.pfennig@reply.de>
# for free
to join this conversation on GitHub.
Already have an account?
# to comment
Version: current master, dd638b5
Platform: Linux 6.2.0-34-generic #34-Ubuntu SMP PREEMPT_DYNAMIC Mon Sep 4 13:06:55 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux
In curl/curl#11203 (comment), @marlonbaeten reported that removing
hyper_clientconn_free(client);
from curl's c-hyper code caused curl to never send the request.I did a little poking around and I believe what's happening is a deadlock. I'm not sure yet why freeing the client triggers the deadlock, but I can see in the Hyper code where it happens.
In hyper_executor::poll_next,
self.driver
is locked and thendrain_queue
is called :hyper/src/ffi/task.rs
Lines 129 to 134 in dd638b5
drain_queue
then tries to lockself.driver
a second time:hyper/src/ffi/task.rs
Lines 151 to 156 in dd638b5
The docs for Mutex::lock say:
Steps to reproduce:
Build Hyper's FFI library using this patch to add some println debugging lines:
Build curl against that version of Hyper's FFI library, using this patch against curl:
Observe this output, followed by a hang:
The text was updated successfully, but these errors were encountered: