Hello Tomcat users,
We are encountering a problem in a site running tomcat 4.0.6.
Every now and then (at least once a week) the server crashes complaining of an
ArrayIndexOutOfBoundsException in SocketInputStream, logs following (IPs masked for privacy :) )

2003-02-14 11:02:23 HttpProcessor[8080][0] An incoming request is being assigned
2003-02-14 11:02:23 HttpProcessor[8080][0] The incoming request has been awaited
2003-02-14 11:02:23 HttpProcessor[8080][0] parseConnection: address=xx.xxx.xx.xx/xx.xxx.xx.xx, port=8080
2003-02-14 11:02:23 HttpProcessor[8080][0] Normalized: '/myapp/MyApp/pages/login.jsp' to '/myapp/MyApp/pages/login.jsp'
2003-02-14 11:02:23 HttpProcessor[8080][0] Request is 'GET' for '/myapp/MyApp/pages/login.jsp' with protocol 'HTTP/1.0'
2003-02-14 11:02:23 HttpProcessor[8080][0] Header accept = image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*
2003-02-14 11:02:23 HttpProcessor[8080][0] Header referer = http://xxx.xxx.xxx.xx:8080/myapp/pages/login.jsp;jsessionid=4CF6BD25491A6BC1789C312ED4714927
2003-02-14 11:02:23 HttpProcessor[8080][0] Header accept-language = fr
2003-02-14 11:02:23 HttpProcessor[8080][0] Adding locale 'fr'
2003-02-14 11:02:23 HttpProcessor[8080][0] Header pd =
2003-02-14 11:02:23 HttpProcessor[8080][0] Header connection = Keep-Alive
2003-02-14 11:02:23 HttpProcessor[8080][0] Header user-agent = Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)
2003-02-14 11:02:23 HttpProcessor[8080][0] Header host = xxx.xxx.xxx.xx:8080
2003-02-14 11:02:23 HttpProcessor[8080][0] Header pragma = no-cache
2003-02-14 11:02:23 HttpProcessor[8080][0] Header cookie = JSESSIONID=4CF6BD25491A6BC1789C312ED4714927
2003-02-14 11:02:23 HttpProcessor[8080][0] Requested cookie session id is 4CF6BD25491A6BC1789C312ED4714927
2003-02-14 11:02:23 HttpProcessor[8080][0] Adding cookie JSESSIONID=4CF6BD25491A6BC1789C312ED4714927
2003-02-14 11:02:24 HttpProcessor[8080][0] An incoming request is being assigned
2003-02-14 11:02:24 HttpProcessor[8080][0] The incoming request has been awaited
2003-02-14 11:02:24 HttpProcessor[8080][0] parseConnection: address=xx.xxx.xx.xx/xx.xxx.xx.xx, port=8080
2003-02-14 11:02:24 HttpProcessor[8080][0] Normalized: '/myapp/MyApp/home.jsp' to '/myapp/MyApp/home.jsp'
2003-02-14 11:02:24 HttpProcessor[8080][0] Request is 'GET' for '/myapp/MyApp/home.jsp' with protocol 'HTTP/1.0'
2003-02-14 11:02:24 HttpProcessor[8080][0] Header accept = image/gif, image/x-xbitmap, image/jpeg, image/pjpeg, application/vnd.ms-powerpoint, application/vnd.ms-excel, application/msword, */*
2003-02-14 11:02:24 HttpProcessor[8080][0] Header referer = http://xxx.xxx.xxx.xx:8080/myapp/pages/login.jsp;jsessionid=4CF6BD25491A6BC1789C312ED4714927
2003-02-14 11:02:24 HttpProcessor[8080][0] process.parse
java.lang.ArrayIndexOutOfBoundsException
at org.apache.catalina.connector.http.SocketInputStream.readHeader(SocketInputStream.java:487)
at org.apache.catalina.connector.http.HttpProcessor.parseHeaders(HttpProcessor.java:579)
at org.apache.catalina.connector.http.HttpProcessor.process(HttpProcessor.java:977)
at org.apache.catalina.connector.http.HttpProcessor.run(HttpProcessor.java:1125)
at java.lang.Thread.run(Thread.java:479)

Looking into the offending SocketInputStream I found this code snippet:


while (!eol) {
// if the buffer is full, extend it
if (readCount >= maxRead) {
if ((2 * maxRead) <= HttpHeader.MAX_VALUE_SIZE) {
char[] newBuffer = new char[2 * maxRead];
System.arraycopy(header.value, 0, newBuffer, 0,
maxRead);
header.value = newBuffer;
maxRead = header.value.length;
} else {
throw new IOException
(sm.getString("requestStream.readline.toolong"));
} } // We're at the end of the internal buffer
if (pos >= count) {
// Copying part (or all) of the internal buffer to the line
// buffer
int val = read();
if (val == -1)
throw new IOException
(sm.getString("requestStream.readline.error"));
pos = 0;
readStart = 0;
} if (buf[pos] == CR) {
} else if (buf[pos] == LF) {
eol = true;
} else {
// FIXME : Check if binary conversion is working fine
int ch = buf[pos] & 0xff;
header.value[readCount] = (char) ch; // LINE CAUSING THE PROBLEM
readCount++;
} pos++; }

Am i wrong in saying that if a the buffer ends with a CR this code tries to read after it without incrementing readCount ?

The funny thing is that the error is caused always when a connection comes from the proxy server (I don't know the exact details of it, I'm waiting for info
about the server configuration, software, ... )

The ugly thing is that after this request tomcat seems to refuse any other request because any other request is handled by thread [0] which is
in error (maybe error state is not cleaned)


Any hint ?


Thank you for your help

Vincenzo







--

I don't need to compromise my principles, because they don't have the
slightest bearing on what happens to me anyway. -- Calvin
-----------------------------------------------------
Vincenzo Marchese
ARSRETIA S.r.l.
Via D. Sansotta, 97
00144 Roma (IT)
e-mail: [EMAIL PROTECTED]
Tel.: +39 06 52270097
Fax: +39 06 52272313



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to