Skip to content
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

Reproducer for request failures present in 2.2.25 and 2.3.7. #1495

Closed

Conversation

carterkozak
Copy link
Contributor

I attempted a simpler reproducer without servlets and jersey, however I was unable to reproduce the issue. Similarly, when I read the response without parsing JSON, I failed to reproduce the issue. Parsing response JSON may be adding some backpressure necessary to trigger the failure.

I've shared this reproducer as a draft PR into the undertow repo for ease of use in debugging, I don't expect it to be merged.

I attempted a simpler reproducer without servlets and jersey,
however I was unable to reproduce the issue. Similarly, when I
read the response without parsing JSON, I failed to reproduce
the issue. Parsing response JSON may be adding some backpressure
necessary to trigger the failure.
@baranowb
Copy link
Contributor

baranowb commented Apr 3, 2024

@carterkozak - is there a ticket for those failures? Also, could you please rebase it?

@carterkozak
Copy link
Contributor Author

@baranowb I don't think I filed one -- I chatted with @fl4via on the Wildfly Zulipchat, though.

@fl4via fl4via added the under verification Currently being verified (running tests, reviewing) before posting a review to contributor label Jun 20, 2024
@fl4via
Copy link
Member

fl4via commented Jun 20, 2024

After a big void dealing with CVEs and releases, we are finally back to this one. I'll be away during next week, but then I'll pick up from here in early July.

@fl4via fl4via added the bug reproducer Not to be merged. Used for indicating PRs that provided bug reproducers waiting for investigation. label Jun 20, 2024
carterkozak added a commit to carterkozak/undertow that referenced this pull request Aug 12, 2024
The failure was the result of disagreement over the owner of a
connection, after an initial thread ends an exchange and releases
the connection, but continues to operate upon it with a premature
`flush()` from an illegal thread (per undertow thread model).

The HttpServerExchange uses a `WriteDispatchChannel` in order to
avoid interfering with the underlying connection after the exchange
is completed, however the `WriteDispatchChannel` is an outer layer,
around all response-wrappers. Response wrappers themselves may still
interact with the underlying connections even after the `HttpReadListener`
state has been reset to allow another request to be parsed.
We must wrap the lower level streams with a similar function to prevent
this spillover.

In practice, the failure I've encountered and reproduced was the result
of `DeflatingStreamSinkConduit` invoking `next.terminateWrites()` followed
by `next.flush()`. The `terminateWrites()` invocation causes the delegate
`ChunkedStreamSinkConduit` to flush within `terminateWrites` which triggers
the end of the exchange. Then, the following `flush()` in
`DeflatingStreamSinkConduit` applies to another request entirely.
This can be reproduced quickly using the reproducer branch (undertow-io#1495)
with a slight code modification, adding a `sleep(100)` thusly:
```diff
if (performFlushIfRequired()) {
    state |= NEXT_SHUTDOWN;
    freeBuffer();
    next.terminateWrites();
+    try {
+        Thread.sleep(100);
+    } catch (InterruptedException e) {}
    return next.flush();
} else {
```
@fl4via fl4via removed the under verification Currently being verified (running tests, reviewing) before posting a review to contributor label Aug 22, 2024
@fl4via
Copy link
Member

fl4via commented Aug 22, 2024

I'm closing this as the issue is solved by PR #1648

@fl4via fl4via closed this Aug 22, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug reproducer Not to be merged. Used for indicating PRs that provided bug reproducers waiting for investigation.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants