-
-
Notifications
You must be signed in to change notification settings - Fork 62
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
thread 'isahc-agent-42001' panicked #295
Comments
Thanks for filing an issue! First let's get some additional info so that I can help troubleshoot:
|
|
The request body's length is around 65536. If I truncate it to 8192, that will increase the chance of success. But still will fail (in that infinite loop). |
Thanks, this is very helpful! Based on the stack trace, I think this might be caused by a bug in |
`Writer` has a race condition that might cause a panic if `poll_write` is called more than once while the `Reader` is in the processed of being dropped on another thread. The race condition is caused by the drop order of `Reader`: Since fields are dropped in the order they are defined in, the buffer pool channel is dropped _before_ the buffer stream channel. If `poll_write` is called more than once between these two drop calls, then the underlying channel will panic because we've polled it after already returning `None`. The fix is to ensure the buffer stream channel is closed _first_ before the buffer pool channel, since that is the channel we use to detect when the reader is closed. One way of doing this would be to just reverse the order these two fields are defined in, but it is better to be clear that the drop order matters by using an explicit drop handler. See also sagebind/isahc#295.
My hunch was correct; this appears to be a rare race condition bug in sluice: sagebind/sluice#16. I will push a patch for sluice and a patch in Isahc that pulls in the fix shortly. |
…#16) `Writer` has a race condition that might cause a panic if `poll_write` is called more than once while the `Reader` is in the processed of being dropped on another thread. The race condition is caused by the drop order of `Reader`: Since fields are dropped in the order they are defined in, the buffer pool channel is dropped _before_ the buffer stream channel. If `poll_write` is called more than once between these two drop calls, then the underlying channel will panic because we've polled it after already returning `None`. The fix is to ensure the buffer stream channel is closed _first_ before the buffer pool channel, since that is the channel we use to detect when the reader is closed. One way of doing this would be to just reverse the order these two fields are defined in, but it is better to be clear that the drop order matters by using an explicit drop handler. With this fix, we know that the second channel will be polled _at most_ once when closed, because subsequent calls to `poll_write` will check the first channel before polling the second. See also sagebind/isahc#295.
Is this a bug of isahc? I just:
Then it:
The text was updated successfully, but these errors were encountered: