This is an automated email from the ASF dual-hosted git repository.
markt pushed a commit to branch 9.0.x
in repository https://gitbox.apache.org/repos/asf/tomcat.git
The following commit(s) were added to refs/heads/9.0.x by this push:
new 39e4c4e Fix potential deadlock with concurrent new frames and close
for stream
39e4c4e is described below
commit 39e4c4e86c8552b3861a43955d6636ee5fbbbd72
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 ed8b90b..83a061c 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 fdc8a4b..f64b3b6 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>
<subsection name="Other">
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]