Return-Path: X-Original-To: apmail-hc-dev-archive@www.apache.org Delivered-To: apmail-hc-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 8FC7F1803C for ; Wed, 20 Jan 2016 18:48:42 +0000 (UTC) Received: (qmail 57561 invoked by uid 500); 20 Jan 2016 18:48:40 -0000 Delivered-To: apmail-hc-dev-archive@hc.apache.org Received: (qmail 57491 invoked by uid 500); 20 Jan 2016 18:48:40 -0000 Mailing-List: contact dev-help@hc.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: "HttpComponents Project" Delivered-To: mailing list dev@hc.apache.org Received: (qmail 57466 invoked by uid 99); 20 Jan 2016 18:48:40 -0000 Received: from arcas.apache.org (HELO arcas) (140.211.11.28) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 20 Jan 2016 18:48:40 +0000 Received: from arcas.apache.org (localhost [127.0.0.1]) by arcas (Postfix) with ESMTP id EAFB42C1F55 for ; Wed, 20 Jan 2016 18:48:39 +0000 (UTC) Date: Wed, 20 Jan 2016 18:48:39 +0000 (UTC) From: "Oleg Kalnichevski (JIRA)" To: dev@hc.apache.org Message-ID: In-Reply-To: References: Subject: [jira] [Commented] (HTTPCORE-417) Infinite loop in LengthDelimitedEncoder due to negative return from SSLIOSession.writePlain() MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-JIRA-FingerPrint: 30527f35849b9dde25b450d4833f0394 [ https://issues.apache.org/jira/browse/HTTPCORE-417?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15109120#comment-15109120 ] Oleg Kalnichevski commented on HTTPCORE-417: -------------------------------------------- Miles Could you please test this patch locally and let me know if that fixes the problem for you? https://github.com/ok2c/httpcore/commit/02fad7338c843f76232fa11b2a8252c055e61805 Oleg > Infinite loop in LengthDelimitedEncoder due to negative return from SSLIOSession.writePlain() > --------------------------------------------------------------------------------------------- > > Key: HTTPCORE-417 > URL: https://issues.apache.org/jira/browse/HTTPCORE-417 > Project: HttpComponents HttpCore > Issue Type: Bug > Components: HttpCore NIO > Affects Versions: 4.4.4 > Reporter: Miles Spielberg > Assignee: Oleg Kalnichevski > Priority: Critical > > SSLIOSession.InternalByteChannel.write(ByteBuffer) does not obey the WriteableByteChannel contract. In writePlain(), if the channel is closed, -1 is returned, but WriteableByteChannel should throw ClosedChannelException in this case, and should certainly never return a negative value. > This leads to an infinite loop in LengthDelimitedEncoder.write(). AbstractContentEncoder.writeToChannel() returns the -1 from SSLIOSession.InternalByteChannel, and this causes remaining to grow without bound (https://hc.apache.org/httpcomponents-core-4.4.x/httpcore-nio/xref/org/apache/http/impl/nio/codecs/LengthDelimitedEncoder.html#133). > In my application, I see a stack trace similar to the following: > {code} > I/O dispatcher 2 tid=199 [RUNNABLE] > org.apache.http.nio.reactor.ssl.SSLIOSession.access$100(SSLIOSession, ByteBuffer) SSLIOSession.java:72 > org.apache.http.nio.reactor.ssl.SSLIOSession$InternalByteChannel.write(ByteBuffer) SSLIOSession.java:811 > org.apache.http.impl.nio.codecs.AbstractContentEncoder.doWriteChunk(ByteBuffer, boolean) AbstractContentEncoder.java:173 > org.apache.http.impl.nio.codecs.AbstractContentEncoder.doWriteChunk(ByteBuffer, int, boolean) AbstractContentEncoder.java:166 > org.apache.http.impl.nio.codecs.AbstractContentEncoder.writeToChannel(ByteBuffer, int) AbstractContentEncoder.java:140 > org.apache.http.impl.nio.codecs.LengthDelimitedEncoder.write(ByteBuffer) LengthDelimitedEncoder.java:132 > com.box.http.apacheasync.compat.request.ActorSubscriberContentProducer$ContentProducer$.produceContent(ContentEncoder, IOControl) ActorSubscriberContentProducer.scala:114 > com.box.http.apacheasync.compat.request.RequestConverter$$anon$1.produceContent(ContentEncoder, IOControl) RequestConverter.scala:78 > org.apache.http.nio.protocol.BasicAsyncRequestProducer.produceContent(ContentEncoder, IOControl) BasicAsyncRequestProducer.java:125 > org.apache.http.impl.nio.client.MainClientExec.produceContent(InternalState, ContentEncoder, IOControl) MainClientExec.java:262 > org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.produceContent(ContentEncoder, IOControl) DefaultClientExchangeHandlerImpl.java:136 > org.apache.http.nio.protocol.HttpAsyncRequestExecutor.outputReady(NHttpClientConnection, ContentEncoder) HttpAsyncRequestExecutor.java:229 > org.apache.http.impl.nio.DefaultNHttpClientConnection.produceOutput(NHttpClientEventHandler) DefaultNHttpClientConnection.java:292 > org.apache.http.impl.nio.client.InternalIODispatch.onOutputReady(DefaultNHttpClientConnection) InternalIODispatch.java:86 > org.apache.http.impl.nio.client.InternalIODispatch.onOutputReady(Object) InternalIODispatch.java:39 > org.apache.http.impl.nio.reactor.AbstractIODispatch.outputReady(IOSession) AbstractIODispatch.java:154 > org.apache.http.impl.nio.reactor.BaseIOReactor.writable(SelectionKey) BaseIOReactor.java:190 > org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(SelectionKey) AbstractIOReactor.java:343 > org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(Set) AbstractIOReactor.java:317 > org.apache.http.impl.nio.reactor.AbstractIOReactor.execute() AbstractIOReactor.java:278 > org.apache.http.impl.nio.reactor.BaseIOReactor.execute(IOEventDispatch) BaseIOReactor.java:106 > org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run() AbstractMultiworkerIOReactor.java:590 > java.lang.Thread.run() Thread.java:744 > {code} -- This message was sent by Atlassian JIRA (v6.3.4#6332) --------------------------------------------------------------------- To unsubscribe, e-mail: dev-unsubscribe@hc.apache.org For additional commands, e-mail: dev-help@hc.apache.org