-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
Potential infinite loop when request is not fully read #5737
Comments
So if we understand the logs correctly.... you have:
So my first instinct is to say DON'T DO THAT!!!! I'm not sure it is exactly legal to try to complete the async cycle whilst you are still blocked in a read. So I'll try to reproduce this and if my analysis is right, I think the solution is that complete will have to fail any reads (or writes for that matter) that are in progress in other threads. The problem you will have of course is that once we do that, then the thread that did the read will get an exception and hopefully it will not then try to write the response, as if it does then it may do so whilst the complete is actually writing the response... and response is not a threadsafe object, so if 2 threads are messing with it at the same time, more chaos may result.... but at least that wont be our fault! So if you can confirm my outline above, I'll proceed to try make a reproduction. |
Also did this used to work in earlier releases and had just failed in 9.4.35? |
I can reproduce the
We should try to avoid this exception anyway, |
The test case is
We can make this a little bit better by doing a Of course then there will still be the race between any error handling on the read caller and potentially it might interfere with the next cycle of the recycled response. This demonstrates the danger of writing applications in this style. |
We had this occur using the REST Easy framework when a method handling a slow upload asynchronously ( We changed the handling of the timeout but this may still be an unexpected behavior. |
@Marco85Li Note that the servlet spec allows request and response objects to be recycled and explicitly says that an application is responsible for not using a request/response object passed the end of the natural request/response cycle. So in this case, it is an error for the REST Easy framework to complete the request when there may be other threads still interacting with it. Specifically if the other thread catches any exception that it receives from the read and then tries to write a response, it may well end up writing a response to the next request. Now having said that - jetty should not infinite loop - nor behave badly in other ways when it sees a complete whilst a blocking operation is in effect. So we need to improve here, at least with the ReadPendingException. However, we can't reproduce the loop in our testing of this scenario. How sure are you that it is related? |
Signed-off-by: gregw <[email protected]>
This issue has been automatically marked as stale because it has been a |
Since this issue was opened, many bugs were fixed in multiple code area whose impact could solve the reported issue. At least those ones are related:
Upgrading to the latest 9.4 release should be tried to see if that helps. If that fails, the investigation should be resumed. @Marco85Li are you still interested in investigating this? Thanks! |
As you said, different issues have been fixed. We can close this issue as "undetermined". I'll try to reproduce the issue against the latest released build of the 9.4 branch and, if the loop occurs again, I'll attach new logs and hopefully a code sample. Regards, |
@Marco85Li Thank you for your feedback. Please do open a new issue if you run into this problem again. |
Jetty version
9.4.35.v20201120
Java version
jdk-14.0.1
OS type/version
Win7
Description
During the upload of a large request, if the server application (in an async handler) responds without fully reading the content (e.g. due to timeout), Jetty may enter an infinite loop.
jetty infinite loop.log
The text was updated successfully, but these errors were encountered: