This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 10.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/10.0.x by this push:
new d77177d Fix potential deadlock with concurrent new frames and close
for stream
d77177d is described below
commit d77177dbe153078291605c1813cd9125dade4b41
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 1451a1b..ed5da75 100644
--- a/java/org/apache/coyote/http2/Stream.java
+++ b/java/org/apache/coyote/http2/Stream.java
@@ -1246,17 +1246,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 e0e3d32..d1befde 100644
--- a/webapps/docs/changelog.xml
+++ b/webapps/docs/changelog.xml
@@ -285,6 +285,10 @@
on MacOS as it does on Linux and Windows when no trusted certificate
authorities are configured and reject all client certificates. (markt)
</add>
+ <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>
</section>
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]