This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 8.5.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/8.5.x by this push:
new 1b2d056 Fix potential deadlock with concurrent new frames and close
for stream
1b2d056 is described below
commit 1b2d0560500958206a954013fa15ce96d12f83a7
Author: Mark Thomas <[email protected]>
AuthorDate: Tue Jan 4 15:23:06 2022 +0000
Fix potential deadlock with concurrent new frames and close for stream
---
java/org/apache/coyote/http2/Stream.java | 11 +++++++++--
webapps/docs/changelog.xml | 4 ++++
2 files changed, 13 insertions(+), 2 deletions(-)
diff --git a/java/org/apache/coyote/http2/Stream.java
b/java/org/apache/coyote/http2/Stream.java
index a4d6484..b8aa5ce 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -1308,17 +1308,24 @@ class Stream extends AbstractNonZeroStream implements
HeaderEmitter {
closed = true;
}
if (inBuffer != null) {
+ int unreadByteCount = 0;
synchronized (inBuffer) {
- int unreadByteCount = inBuffer.position();
+ unreadByteCount = inBuffer.position();
if (log.isDebugEnabled()) {
log.debug(sm.getString("stream.inputBuffer.swallowUnread",
Integer.valueOf(unreadByteCount)));
}
if (unreadByteCount > 0) {
inBuffer.position(0);
inBuffer.limit(inBuffer.limit() - unreadByteCount);
- handler.onSwallowedDataFramePayload(getIdAsInt(),
unreadByteCount);
}
}
+ // Do this outside of the sync because:
+ // - it doesn't need to be inside the sync
+ // - if inside the sync it can trigger a deadlock
+ // https://markmail.org/message/vbglzkvj6wxlhh3p
+ if (unreadByteCount > 0) {
+ handler.onSwallowedDataFramePayload(getIdAsInt(),
unreadByteCount);
+ }
}
}
}
diff --git a/webapps/docs/changelog.xml b/webapps/docs/changelog.xml
index 433fad9..0067fbd 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -189,6 +189,10 @@
<bug>65757</bug>: Missing initial IO listener notification on Servlet
container dispatch to another container thread. (remm)
</fix>
+ <fix>
+ Avoid a potential deadlock during the concurrent processing of incoming
+ HTTP/2 frames for a stream and that stream being reset. (markt)
+ </fix>
</changelog>
</subsection>
<subsection name="Jasper">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]