You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@tomcat.apache.org by Yuri de Wit <yd...@gmail.com> on 2007/01/14 14:38:53 UTC

is there a hard coded size limit to mod_jk response headers?

I am getting a buffer overflow while using my webapp deployed to
Apache2, mod_jk1.2 and Tomcat5.5.17.

I am basically trying to send an HTTP response back to the browser
with a custom json header (X-JSON header) containing more than 8Kb
since this is the default way to send json state back to the browser
using Prototype.js.

My basic question is this: is there a hard-coded limit of 8Kb for HTTP
response headers?

If the answer is yes I could see this being a serious problem in a
world of AJAX where we not only want to send a XHTML snipped back to
the browser in the entity body, but also piggyback additional state in
the response.

I browsed the source code for Tomcat5.5.17 and found out that AJP13
sends 8Kb packets back to apachelib-mod_jk. For the response entity
body any number of 8Kb packets are sent, but for the response entity
header it seems that always only one 8Kb packet is sent.

I also found a post to this mailing list that although asked a similar
question, did end up providing a definite answer aside from how to
better log the problem
(http://www.mail-archive.com/tomcat-dev@jakarta.apache.org/msg73387.html).


And this is the exception I am seeing:
--------------------------------------------------------------------------------------
Jan 4, 2007 9:08:11 PM org.apache.jk.common.MsgAjp cpBytes
SEVERE: Buffer overflow: buffer.len=8192 pos=25 data=215738
Jan 4, 2007 9:08:11 PM org.apache.jk.common.MsgAjp cpBytes
SEVERE: Overflow
java.lang.Throwable
        at org.apache.jk.common.MsgAjp.cpBytes(MsgAjp.java:172)
        at org.apache.jk.common.MsgAjp.appendByteChunk(MsgAjp.java:146)
        at org.apache.jk.common.MsgAjp.appendBytes(MsgAjp.java:132)
        at org.apache.jk.common.JkInputStream.appendHead(JkInputStream.java:302)
        at org.apache.jk.core.MsgContext.action(MsgContext.java:258)
        at org.apache.coyote.Response.action(Response.java:182)
        at org.apache.coyote.Response.sendHeaders(Response.java:378)
        at org.apache.jk.common.JkInputStream.doWrite(JkInputStream.java:126)
        at org.apache.coyote.Response.doWrite(Response.java:559)
        at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:361)
        at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:433)
        at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:314)
        at org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:278)
        at org.apache.catalina.connector.Response.finishResponse(Response.java:476)
        at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
        at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)
        at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
        at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:754)
        at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:684)
        at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:876)
        at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
        at java.lang.Thread.run(Thread.java:595)
--------------------------------------------------------------------------------------

thanks,

-- yuri

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


RE: is there a hard coded size limit to mod_jk response headers?

Posted by "Fisher, Mitchell L" <Mi...@unisys.com>.
Hi, could you elaborate?  Will a matching mod_jk update be needed?

-Mitch

-----Original Message-----
From: Takayuki Kaneko [mailto:kanekotky@gmail.com] 
Sent: Tuesday, January 16, 2007 3:45 AM
To: Tomcat Developers List
Subject: Re: is there a hard coded size limit to mod_jk response
headers?

Hi Yuri,

You will be able to configure the packetSize at standard coyote AJP Jk
handler on Tomcat 5.5.21.

http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/webapps/docs/chang
elog.xml?r1=483339&r2=485795&diff_format=h

-Takayuki

On 1/14/07, Yuri de Wit <yd...@gmail.com> wrote:
> I am getting a buffer overflow while using my webapp deployed to
> Apache2, mod_jk1.2 and Tomcat5.5.17.
>
> I am basically trying to send an HTTP response back to the browser
> with a custom json header (X-JSON header) containing more than 8Kb
> since this is the default way to send json state back to the browser
> using Prototype.js.
>
> My basic question is this: is there a hard-coded limit of 8Kb for HTTP
> response headers?
>
> If the answer is yes I could see this being a serious problem in a
> world of AJAX where we not only want to send a XHTML snipped back to
> the browser in the entity body, but also piggyback additional state in
> the response.
>
> I browsed the source code for Tomcat5.5.17 and found out that AJP13
> sends 8Kb packets back to apachelib-mod_jk. For the response entity
> body any number of 8Kb packets are sent, but for the response entity
> header it seems that always only one 8Kb packet is sent.
>
> I also found a post to this mailing list that although asked a similar
> question, did end up providing a definite answer aside from how to
> better log the problem
>
(http://www.mail-archive.com/tomcat-dev@jakarta.apache.org/msg73387.html
).
>
>
> And this is the exception I am seeing:
>
------------------------------------------------------------------------
--------------
> Jan 4, 2007 9:08:11 PM org.apache.jk.common.MsgAjp cpBytes
> SEVERE: Buffer overflow: buffer.len=8192 pos=25 data=215738
> Jan 4, 2007 9:08:11 PM org.apache.jk.common.MsgAjp cpBytes
> SEVERE: Overflow
> java.lang.Throwable
>         at org.apache.jk.common.MsgAjp.cpBytes(MsgAjp.java:172)
>         at
org.apache.jk.common.MsgAjp.appendByteChunk(MsgAjp.java:146)
>         at org.apache.jk.common.MsgAjp.appendBytes(MsgAjp.java:132)
>         at
org.apache.jk.common.JkInputStream.appendHead(JkInputStream.java:302)
>         at org.apache.jk.core.MsgContext.action(MsgContext.java:258)
>         at org.apache.coyote.Response.action(Response.java:182)
>         at org.apache.coyote.Response.sendHeaders(Response.java:378)
>         at
org.apache.jk.common.JkInputStream.doWrite(JkInputStream.java:126)
>         at org.apache.coyote.Response.doWrite(Response.java:559)
>         at
org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.j
ava:361)
>         at
org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:433)
>         at
org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:314
)
>         at
org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:278)
>         at
org.apache.catalina.connector.Response.finishResponse(Response.java:476)
>         at
org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:1
51)
>         at
org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)
>         at
org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
>         at
org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:754)
>         at
org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:
684)
>         at
org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.
java:876)
>         at
org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool
.java:684)
>         at java.lang.Thread.run(Thread.java:595)
>
------------------------------------------------------------------------
--------------
>
> thanks,
>
> -- yuri
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: is there a hard coded size limit to mod_jk response headers?

Posted by Yuri de Wit <yd...@gmail.com>.
Hi Takayuki,

Would that mean that still a single packet will be sent for HTTP
response headers?

In my case, the state I need to return in the entity header could be
in the order of 250K (the extreme case) and if I configure the packet
size to be ~300K, would that mean that all packets, including entity
body packets would take that size? I am sure there is a reason why 8K
size was choosen (not sure what 300K will mean to the performance).

Would it be better to send entity headers in the same way that entity
bodies are sent, i.e. N*8K? I understand that for 5.5.x this (if it
makes sense of course) is a bigger change, but maybe in 6.0?

thanks,

- yuri


On 1/16/07, Takayuki Kaneko <ka...@gmail.com> wrote:
> Hi Yuri,
>
> You will be able to configure the packetSize at standard coyote AJP Jk
> handler on Tomcat 5.5.21.
>
> http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/webapps/docs/changelog.xml?r1=483339&r2=485795&diff_format=h
>
> -Takayuki
>
> On 1/14/07, Yuri de Wit <yd...@gmail.com> wrote:
> > I am getting a buffer overflow while using my webapp deployed to
> > Apache2, mod_jk1.2 and Tomcat5.5.17.
> >
> > I am basically trying to send an HTTP response back to the browser
> > with a custom json header (X-JSON header) containing more than 8Kb
> > since this is the default way to send json state back to the browser
> > using Prototype.js.
> >
> > My basic question is this: is there a hard-coded limit of 8Kb for HTTP
> > response headers?
> >
> > If the answer is yes I could see this being a serious problem in a
> > world of AJAX where we not only want to send a XHTML snipped back to
> > the browser in the entity body, but also piggyback additional state in
> > the response.
> >
> > I browsed the source code for Tomcat5.5.17 and found out that AJP13
> > sends 8Kb packets back to apachelib-mod_jk. For the response entity
> > body any number of 8Kb packets are sent, but for the response entity
> > header it seems that always only one 8Kb packet is sent.
> >
> > I also found a post to this mailing list that although asked a similar
> > question, did end up providing a definite answer aside from how to
> > better log the problem
> > (http://www.mail-archive.com/tomcat-dev@jakarta.apache.org/msg73387.html).
> >
> >
> > And this is the exception I am seeing:
> > --------------------------------------------------------------------------------------
> > Jan 4, 2007 9:08:11 PM org.apache.jk.common.MsgAjp cpBytes
> > SEVERE: Buffer overflow: buffer.len=8192 pos=25 data=215738
> > Jan 4, 2007 9:08:11 PM org.apache.jk.common.MsgAjp cpBytes
> > SEVERE: Overflow
> > java.lang.Throwable
> >         at org.apache.jk.common.MsgAjp.cpBytes(MsgAjp.java:172)
> >         at org.apache.jk.common.MsgAjp.appendByteChunk(MsgAjp.java:146)
> >         at org.apache.jk.common.MsgAjp.appendBytes(MsgAjp.java:132)
> >         at org.apache.jk.common.JkInputStream.appendHead(JkInputStream.java:302)
> >         at org.apache.jk.core.MsgContext.action(MsgContext.java:258)
> >         at org.apache.coyote.Response.action(Response.java:182)
> >         at org.apache.coyote.Response.sendHeaders(Response.java:378)
> >         at org.apache.jk.common.JkInputStream.doWrite(JkInputStream.java:126)
> >         at org.apache.coyote.Response.doWrite(Response.java:559)
> >         at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:361)
> >         at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:433)
> >         at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:314)
> >         at org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:278)
> >         at org.apache.catalina.connector.Response.finishResponse(Response.java:476)
> >         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
> >         at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)
> >         at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
> >         at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:754)
> >         at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:684)
> >         at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:876)
> >         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
> >         at java.lang.Thread.run(Thread.java:595)
> > --------------------------------------------------------------------------------------
> >
> > thanks,
> >
> > -- yuri
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> > For additional commands, e-mail: dev-help@tomcat.apache.org
> >
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org


Re: is there a hard coded size limit to mod_jk response headers?

Posted by Takayuki Kaneko <ka...@gmail.com>.
Hi Yuri,

You will be able to configure the packetSize at standard coyote AJP Jk
handler on Tomcat 5.5.21.

http://svn.apache.org/viewvc/tomcat/container/tc5.5.x/webapps/docs/changelog.xml?r1=483339&r2=485795&diff_format=h

-Takayuki

On 1/14/07, Yuri de Wit <yd...@gmail.com> wrote:
> I am getting a buffer overflow while using my webapp deployed to
> Apache2, mod_jk1.2 and Tomcat5.5.17.
>
> I am basically trying to send an HTTP response back to the browser
> with a custom json header (X-JSON header) containing more than 8Kb
> since this is the default way to send json state back to the browser
> using Prototype.js.
>
> My basic question is this: is there a hard-coded limit of 8Kb for HTTP
> response headers?
>
> If the answer is yes I could see this being a serious problem in a
> world of AJAX where we not only want to send a XHTML snipped back to
> the browser in the entity body, but also piggyback additional state in
> the response.
>
> I browsed the source code for Tomcat5.5.17 and found out that AJP13
> sends 8Kb packets back to apachelib-mod_jk. For the response entity
> body any number of 8Kb packets are sent, but for the response entity
> header it seems that always only one 8Kb packet is sent.
>
> I also found a post to this mailing list that although asked a similar
> question, did end up providing a definite answer aside from how to
> better log the problem
> (http://www.mail-archive.com/tomcat-dev@jakarta.apache.org/msg73387.html).
>
>
> And this is the exception I am seeing:
> --------------------------------------------------------------------------------------
> Jan 4, 2007 9:08:11 PM org.apache.jk.common.MsgAjp cpBytes
> SEVERE: Buffer overflow: buffer.len=8192 pos=25 data=215738
> Jan 4, 2007 9:08:11 PM org.apache.jk.common.MsgAjp cpBytes
> SEVERE: Overflow
> java.lang.Throwable
>         at org.apache.jk.common.MsgAjp.cpBytes(MsgAjp.java:172)
>         at org.apache.jk.common.MsgAjp.appendByteChunk(MsgAjp.java:146)
>         at org.apache.jk.common.MsgAjp.appendBytes(MsgAjp.java:132)
>         at org.apache.jk.common.JkInputStream.appendHead(JkInputStream.java:302)
>         at org.apache.jk.core.MsgContext.action(MsgContext.java:258)
>         at org.apache.coyote.Response.action(Response.java:182)
>         at org.apache.coyote.Response.sendHeaders(Response.java:378)
>         at org.apache.jk.common.JkInputStream.doWrite(JkInputStream.java:126)
>         at org.apache.coyote.Response.doWrite(Response.java:559)
>         at org.apache.catalina.connector.OutputBuffer.realWriteBytes(OutputBuffer.java:361)
>         at org.apache.tomcat.util.buf.ByteChunk.flushBuffer(ByteChunk.java:433)
>         at org.apache.catalina.connector.OutputBuffer.doFlush(OutputBuffer.java:314)
>         at org.apache.catalina.connector.OutputBuffer.close(OutputBuffer.java:278)
>         at org.apache.catalina.connector.Response.finishResponse(Response.java:476)
>         at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:151)
>         at org.apache.jk.server.JkCoyoteHandler.invoke(JkCoyoteHandler.java:199)
>         at org.apache.jk.common.HandlerRequest.invoke(HandlerRequest.java:282)
>         at org.apache.jk.common.ChannelSocket.invoke(ChannelSocket.java:754)
>         at org.apache.jk.common.ChannelSocket.processConnection(ChannelSocket.java:684)
>         at org.apache.jk.common.ChannelSocket$SocketConnection.runIt(ChannelSocket.java:876)
>         at org.apache.tomcat.util.threads.ThreadPool$ControlRunnable.run(ThreadPool.java:684)
>         at java.lang.Thread.run(Thread.java:595)
> --------------------------------------------------------------------------------------
>
> thanks,
>
> -- yuri
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: dev-help@tomcat.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@tomcat.apache.org
For additional commands, e-mail: dev-help@tomcat.apache.org