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

java.nio.ReadOnlyBufferException #6470

Closed
Horcrux7 opened this issue Jun 24, 2021 · 4 comments
Closed

java.nio.ReadOnlyBufferException #6470

Horcrux7 opened this issue Jun 24, 2021 · 4 comments
Assignees
Labels
Bug For general bugs on Jetty side

Comments

@Horcrux7
Copy link

Jetty version(s): 9.4.42.v20210604

Java version/vendor (use: java -version)
openjdk version "11.0.11" 2021-04-20
OpenJDK Runtime Environment AdoptOpenJDK-11.0.11+9 (build 11.0.11+9)
OpenJDK 64-Bit Server VM AdoptOpenJDK-11.0.11+9 (build 11.0.11+9, mixed mode)

OS type/version: Alpine 3.11 in a Docker container

Description
It looks like that after update from 9.4.40.v20210413 to version 9.4.42.v20210604 we get the follow exception on every second request. It occur also on other OS like Windows and OSX. Any idea?

java.nio.ReadOnlyBufferException
	at java.base/java.nio.HeapByteBufferR.put(Unknown Source)
	at org.eclipse.jetty.util.BufferUtil.putCRLF(BufferUtil.java:1251)
	at org.eclipse.jetty.http.HttpGenerator.prepareChunk(HttpGenerator.java:501)
	at org.eclipse.jetty.http.HttpGenerator.committed(HttpGenerator.java:317)
	at org.eclipse.jetty.http.HttpGenerator.generateResponse(HttpGenerator.java:469)
	at org.eclipse.jetty.server.HttpConnection$SendCallback.process(HttpConnection.java:744)
	at org.eclipse.jetty.util.IteratingCallback.processing(IteratingCallback.java:241)
	at org.eclipse.jetty.util.IteratingCallback.iterate(IteratingCallback.java:223)
	at org.eclipse.jetty.server.HttpConnection.send(HttpConnection.java:550)
	at org.eclipse.jetty.server.HttpChannel.sendResponse(HttpChannel.java:915)
	at org.eclipse.jetty.server.HttpChannel.write(HttpChannel.java:987)
	at org.eclipse.jetty.server.handler.gzip.GzipHttpOutputInterceptor$GzipBufferCB.process(GzipHttpOutputInterceptor.java:416)
	at org.eclipse.jetty.util.IteratingCallback.processing(IteratingCallback.java:241)
	at org.eclipse.jetty.util.IteratingCallback.iterate(IteratingCallback.java:223)
	at org.eclipse.jetty.server.handler.gzip.GzipHttpOutputInterceptor.gzip(GzipHttpOutputInterceptor.java:139)
	at org.eclipse.jetty.server.handler.gzip.GzipHttpOutputInterceptor.write(GzipHttpOutputInterceptor.java:121)
	at org.eclipse.jetty.server.HttpOutput.channelWrite(HttpOutput.java:285)
	at org.eclipse.jetty.server.HttpOutput.channelWrite(HttpOutput.java:269)
	at org.eclipse.jetty.server.HttpOutput.write(HttpOutput.java:892)
        ...
	at org.eclipse.jetty.servlet.ServletHolder.handle(ServletHolder.java:799)
	at org.eclipse.jetty.servlet.ServletHandler$ChainEnd.doFilter(ServletHandler.java:1626)
	at org.eclipse.jetty.websocket.server.WebSocketUpgradeFilter.doFilter(WebSocketUpgradeFilter.java:228)
	at org.eclipse.jetty.servlet.FilterHolder.doFilter(FilterHolder.java:193)
	at org.eclipse.jetty.servlet.ServletHandler$Chain.doFilter(ServletHandler.java:1601)
	at org.eclipse.jetty.servlet.ServletHandler.doHandle(ServletHandler.java:548)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
	at org.eclipse.jetty.server.session.SessionHandler.doHandle(SessionHandler.java:1624)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextHandle(ScopedHandler.java:233)
	at org.eclipse.jetty.server.handler.ContextHandler.doHandle(ContextHandler.java:1435)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:188)
	at org.eclipse.jetty.servlet.ServletHandler.doScope(ServletHandler.java:501)
	at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1594)
	at org.eclipse.jetty.server.handler.ScopedHandler.nextScope(ScopedHandler.java:186)
	at org.eclipse.jetty.server.handler.ContextHandler.doScope(ContextHandler.java:1350)
	at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
	at org.eclipse.jetty.server.handler.gzip.GzipHandler.handle(GzipHandler.java:763)
	at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:127)
	at org.eclipse.jetty.server.Server.handle(Server.java:516)
	at com.inet.webserver.b.handle(SourceFile:414)
	at org.eclipse.jetty.server.HttpChannel.lambda$handle$1(HttpChannel.java:388)
	at org.eclipse.jetty.server.HttpChannel.dispatch(HttpChannel.java:633)
	at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:380)
	at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:277)
	at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:311)
	at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:105)
	at org.eclipse.jetty.io.ChannelEndPoint$1.run(ChannelEndPoint.java:104)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.runTask(EatWhatYouKill.java:338)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:315)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.tryProduce(EatWhatYouKill.java:173)
	at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131)
	at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:383)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:882)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1036)
	at java.base/java.lang.Thread.run(Unknown Source)

@Horcrux7 Horcrux7 added the Bug For general bugs on Jetty side label Jun 24, 2021
@Horcrux7
Copy link
Author

More debugging on the problem it look like that the follow stacktrace put a readonly buffer back to the pool:

	at org.eclipse.jetty.io.ArrayByteBufferPool.release(ArrayByteBufferPool.java:141)
	at org.eclipse.jetty.websocket.common.message.MessageInputStream.close(MessageInputStream.java:166)
	at com.inet.lib.io.UTF8StreamReader.close(UTF8StreamReader.java:144)
	at com.inet.lib.json.EncodedReader.close(EncodedReader.java:135)
	at com.inet.http.websocket.WebSocketEventHandler.handleEvent(WebSocketEventHandler.java:324)
	at com.inet.http.websocket.WebSocketEndpoint$2.onMessage(WebSocketEndpoint.java:234)
	at com.inet.http.websocket.WebSocketEndpoint$2.onMessage(WebSocketEndpoint.java:1)
	at org.eclipse.jetty.websocket.jsr356.endpoints.JsrEndpointEventDriver.lambda$onBinaryFrame$0(JsrEndpointEventDriver.java:98)
	at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:882)
	at org.eclipse.jetty.util.thread.QueuedThreadPool$Runner.run(QueuedThreadPool.java:1036)
	at java.base/java.lang.Thread.run(Thread.java:834)

The value seems to be empty java.nio.HeapByteBufferR[pos=0 lim=0 cap=0]

@gamma
Copy link

gamma commented Jun 30, 2021

This issue is preventing us from upgrading to the latest release including a recent CVE fix.

@lachlan-roberts lachlan-roberts self-assigned this Jun 30, 2021
lachlan-roberts added a commit that referenced this issue Jun 30, 2021
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
@gregw gregw added this to To do in Jetty 9.4.43 FROZEN via automation Jun 30, 2021
@gregw gregw added this to To do in Jetty 10.0.6/11.0.6 FROZEN via automation Jun 30, 2021
@gregw gregw removed this from To do in Jetty 10.0.6/11.0.6 FROZEN Jun 30, 2021
lachlan-roberts added a commit that referenced this issue Jun 30, 2021
Signed-off-by: Lachlan Roberts <lachlan@webtide.com>
lachlan-roberts added a commit that referenced this issue Jun 30, 2021
…reamEOF

Issue #6470 - prevent EOF being released back into pool in MessageInputStream
@lachlan-roberts
Copy link
Contributor

This has been fixed with PR #6486 and will be in the upcoming 9.4.43 release.

Jetty 9.4.43 FROZEN automation moved this from To do to Done Jun 30, 2021
@joakime
Copy link
Contributor

joakime commented Jun 30, 2021

Shouldn't ByteBufferPool.release(ByteBuffer) always throw an exception on an attempt to release nonsense buffers? (read-only, zero length, memory-mapped, etc)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug For general bugs on Jetty side
Projects
No open projects
Development

Successfully merging a pull request may close this issue.

4 participants