hc-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Nhan Thuan Nguyen (JIRA)" <j...@apache.org>
Subject [jira] [Closed] (HTTPCORE-430) Unsafe decrement LengthDelimitedEncoder's remaining value.
Date Fri, 05 Aug 2016 19:10:20 GMT

     [ https://issues.apache.org/jira/browse/HTTPCORE-430?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]

Nhan Thuan Nguyen closed HTTPCORE-430.
--------------------------------------
    Resolution: Duplicate

Just found out that it has been resolved in 4.4.5 version, referencing to ticket HTTPCORE-417
Infinite loop in LengthDelimitedEncoder due to negative return from SSLIOSession.writePlain()

> Unsafe decrement LengthDelimitedEncoder's remaining value.
> ----------------------------------------------------------
>
>                 Key: HTTPCORE-430
>                 URL: https://issues.apache.org/jira/browse/HTTPCORE-430
>             Project: HttpComponents HttpCore
>          Issue Type: Bug
>          Components: HttpCore NIO
>    Affects Versions: 4.4.5
>         Environment: Linux 2.6.32-642.1.1.el6.x86_64
>            Reporter: Nhan Thuan Nguyen
>         Attachments: Screenshot_during_debugging.png
>
>
> Durring a large HTTP POST if the SSLIOSession.writePlain "this.status" become not equal
to ACTIVE (0) then it will return "-1" to LengthDelimitedEncoder. The "write" loop test for
"this.remaining > 0" will always be true, and the loop will never exit.
> In LengthDelimitedEncoder.write() (line 100)
> while (src.hasRemaining() && this.remaining > 0) {
>             if (this.buffer.hasData() || this.fragHint > 0) {
>                 final int chunk = nextChunk(src);
>                 if (chunk <= this.fragHint) {
>                     final int capacity = this.fragHint - this.buffer.length();
>                     if (capacity > 0) {
>                         final int limit = Math.min(capacity, chunk);
>                         final int bytesWritten = writeToBuffer(src, limit);
>                         this.remaining -= bytesWritten;
>                         total += bytesWritten;
>                     }
>                 }
>             }
>             if (this.buffer.hasData()) {
>                 final int chunk = nextChunk(src);
>                 if (this.buffer.length() >= this.fragHint || chunk > 0) {
>                     final int bytesWritten = flushToChannel();
>                     if (bytesWritten == 0) {
>                         break;
>                     }
>                 }
>             }
>             if (!this.buffer.hasData()) {
>                 final int chunk = nextChunk(src);
>                 if (chunk > this.fragHint) {
>                     final int bytesWritten = writeToChannel(src, chunk);
>                     this.remaining -= bytesWritten;
>                     total += bytesWritten;
>                     if (bytesWritten == 0) { //PROPOSAL:  can this change to <= 0
instead == 0?
>                         break;
>                     }
>                 }
>             }
>         }
> Version: 
> httpcore-nio-4.4.1.jar
> Stack trace:
> "I/O dispatcher 587" #3550 prio=5 os_prio=0 tid=0x00007f365e664000 nid=0xec0 runnable
[0x00007f364aad4000]
>    java.lang.Thread.State: RUNNABLE
>         at ch.qos.logback.classic.Logger.callAppenders(Logger.java:256)
>         at ch.qos.logback.classic.Logger.buildLoggingEventAndAppend(Logger.java:421)
>         at ch.qos.logback.classic.Logger.filterAndLog_0_Or3Plus(Logger.java:383)
>         at ch.qos.logback.classic.Logger.log(Logger.java:765)
>         at org.apache.commons.logging.impl.SLF4JLocationAwareLog.debug(SLF4JLocationAwareLog.java:131)
>         at org.apache.http.impl.nio.conn.LoggingIOSession$LoggingByteChannel.write(LoggingIOSession.java:222)
>         at org.apache.http.impl.nio.codecs.AbstractContentEncoder.doWriteChunk(AbstractContentEncoder.java:173)
>         at org.apache.http.impl.nio.codecs.AbstractContentEncoder.doWriteChunk(AbstractContentEncoder.java:166)
>         at org.apache.http.impl.nio.codecs.AbstractContentEncoder.writeToChannel(AbstractContentEncoder.java:140)
>         at org.apache.http.impl.nio.codecs.LengthDelimitedEncoder.write(LengthDelimitedEncoder.java:132)
>         at org.apache.http.nio.entity.NByteArrayEntity.produceContent(NByteArrayEntity.java:137)
>         at org.apache.http.nio.protocol.BasicAsyncRequestProducer.produceContent(BasicAsyncRequestProducer.java:125)
>         at org.apache.http.impl.nio.client.MainClientExec.produceContent(MainClientExec.java:262)
>         at org.apache.http.impl.nio.client.DefaultClientExchangeHandlerImpl.produceContent(DefaultClientExchangeHandlerImpl.java:136)
>         at org.apache.http.nio.protocol.HttpAsyncRequestExecutor.outputReady(HttpAsyncRequestExecutor.java:229)
>         at org.apache.http.impl.nio.client.InternalRequestExecutor.outputReady(InternalRequestExecutor.java:96)
>         at org.apache.http.impl.nio.DefaultNHttpClientConnection.produceOutput(DefaultNHttpClientConnection.java:292)
>         at org.apache.http.impl.nio.client.InternalIODispatch.onOutputReady(InternalIODispatch.java:86)
>         at org.apache.http.impl.nio.client.InternalIODispatch.onOutputReady(InternalIODispatch.java:39)
>         at org.apache.http.impl.nio.reactor.AbstractIODispatch.outputReady(AbstractIODispatch.java:154)
>         at org.apache.http.impl.nio.reactor.BaseIOReactor.writable(BaseIOReactor.java:190)
>         at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvent(AbstractIOReactor.java:343)
>         at org.apache.http.impl.nio.reactor.AbstractIOReactor.processEvents(AbstractIOReactor.java:317)
>         at org.apache.http.impl.nio.reactor.AbstractIOReactor.execute(AbstractIOReactor.java:278)
>         at org.apache.http.impl.nio.reactor.BaseIOReactor.execute(BaseIOReactor.java:106)
>         at org.apache.http.impl.nio.reactor.AbstractMultiworkerIOReactor$Worker.run(AbstractMultiworkerIOReactor.java:590)
>         at java.lang.Thread.run(Thread.java:745)



--
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


Mime
View raw message