Bug 61682

Summary: StackOverflowError while executing HTTP/2 Server Push
Product: Tomcat 9 Reporter: Michael Ernst <chiptv>
Component: ConnectorsAssignee: Tomcat Developers Mailing List <dev>
Status: RESOLVED FIXED    
Severity: normal    
Priority: P2    
Version: 9.0.1   
Target Milestone: -----   
Hardware: PC   
OS: All   

Description Michael Ernst 2017-10-27 16:38:32 UTC
While pushing some resources from the Server I received the following StackOverflowError sometimes when refreshing my page (the resource failed to load of course). 

```
Okt 27, 2017 3:10:26 PM org.apache.coyote.AbstractProtocol$ConnectionHandler process
SEVERE: Error reading request, ignored
java.lang.StackOverflowError
	at java.util.concurrent.ConcurrentHashMap$BaseIterator.<init>(ConcurrentHashMap.java:3391)
	at java.util.concurrent.ConcurrentHashMap$KeyIterator.<init>(ConcurrentHashMap.java:3410)
	at java.util.concurrent.ConcurrentHashMap$KeySetView.iterator(ConcurrentHashMap.java:4578)
	at java.util.Collections$SetFromMap.iterator(Collections.java:5462)
	at org.apache.coyote.http2.AbstractStream.isDescendant(AbstractStream.java:69)
	at org.apache.coyote.http2.AbstractStream.isDescendant(AbstractStream.java:70)
	at org.apache.coyote.http2.AbstractStream.isDescendant(AbstractStream.java:70)
	at org.apache.coyote.http2.AbstractStream.isDescendant(AbstractStream.java:70)
	at org.apache.coyote.http2.AbstractStream.isDescendant(AbstractStream.java:70)
	at org.apache.coyote.http2.AbstractStream.isDescendant(AbstractStream.java:70)
```
Comment 1 Remy Maucherat 2017-11-03 14:44:01 UTC
Please provide a test case.
Comment 2 Mark Thomas 2017-11-15 22:37:01 UTC
I've managed to find a way to reproduce this. The logic for re-prioritising streams doesn't always remove children from their old parent when they are re-prioritised. With the right sequence of moves, you can generate circular references.
Comment 3 Mark Thomas 2017-11-16 10:16:12 UTC
Thanks for the report.
Fixed in:
- trunk for 9.0.2 onwards
- 8.5.x for 8.5.24 onwards
Comment 4 Michael Ernst 2017-11-24 09:45:12 UTC
Hi Mark, thanks for fix. I had a look into the commit and I guess I wouldn't be able to provide such a test case without having a deeper knowledge about the code base.