Re: [5] IndexOutOfBoundsException from CharChunk

2003-10-15 Thread Remy Maucherat
Kin-Man Chung wrote:
I don't know much about the test; it is one of stress test we have, but it
should not affect CharChunk this way, right, even if it has something
weird?  Like I said, this happens only in this test, and not always
reproducible, so I am not surprised that nobody noticed it in 4.1.  I
thought it might be thread related, but each thread should have its own
CharChunk instance, so I can't see how.  I look into this more and report
back.
Bug 23805 could be related to this, and I'm awaiting more details. At 
least, the offset numbers do match, which is too big a coincidence ;-)

Remy



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


Re: [5] IndexOutOfBoundsException from CharChunk

2003-10-15 Thread Kin-Man Chung
I believe 23805 is unrelated to my problem, and may even be invalid.
Mine comes from CharChunk.  To refresh the memory, the stack trace is

Servlet.service() for servlet jsp threw exception
java.lang.IndexOutOfBoundsException
at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:132)
at java.io.OutputStreamWriter.write(OutputStreamWriter.java:191)
at org.apache.tomcat.util.buf.WriteConvertor.write(C2BConverter.java:228
)
at org.apache.tomcat.util.buf.C2BConverter.convert(C2BConverter.java:120
)
at org.apache.coyote.tomcat5.OutputBuffer.realWriteChars(OutputBuffer.ja
va:606)
at org.apache.tomcat.util.buf.CharChunk.flushBuffer(CharChunk.java:463)
at org.apache.coyote.tomcat5.OutputBuffer.flush(OutputBuffer.java:357)
at org.apache.coyote.tomcat5.CoyoteWriter.flush(CoyoteWriter.java:117)
at org.apache.jasper.runtime.JspWriterImpl.flush(JspWriterImpl.java:203)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary
.java:990)
...

In my case, it's not the offset, but end that is too big.  It got the value
of 16384 when limit is only 8192.

I have looked into this more without getting more insight.  I use jdb to
catch IndexOutOfBoundsException but couldn't figure out what caused end
to get this big.  Since this happens randomly, I cannot stop a thread and
follow its progress.  Inserting prints in CharChunk was also not useful,
since values for end in threads appear normal until the exception
occurs, as if its value were clobbered by a strayed pointer (like in C).
The print did show that in some cases, the value for end is 16384 after
write(char[]) was invoked, though that didn't cause any exception for some
reason.

This turns out to be more elusive that it appears.  I might have to give
this up as another mystery of the universe.  :-)

-Kin-man

 Date: Wed, 15 Oct 2003 10:36:01 +0200
 From: Remy Maucherat [EMAIL PROTECTED]
 Subject: Re: [5] IndexOutOfBoundsException from CharChunk
 To: Tomcat Developers List [EMAIL PROTECTED]
 
 Kin-Man Chung wrote:
  I don't know much about the test; it is one of stress test we have, but it
  should not affect CharChunk this way, right, even if it has something
  weird?  Like I said, this happens only in this test, and not always
  reproducible, so I am not surprised that nobody noticed it in 4.1.  I
  thought it might be thread related, but each thread should have its own
  CharChunk instance, so I can't see how.  I look into this more and report
  back.
 
 Bug 23805 could be related to this, and I'm awaiting more details. At 
 least, the offset numbers do match, which is too big a coincidence ;-)
 
 Remy
 
 
 
 -
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 


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



[5] IndexOutOfBoundsException from CharChunk

2003-10-08 Thread Kin-Man Chung
I am getting a sporadic IndexOutOfBoundsException and it seems to come from
org.apache.tomcat.util.buf.CharChunk.flushBuffer.  The trace is

Servlet.service() for servlet jsp threw exception
java.lang.IndexOutOfBoundsException
at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:132)
at java.io.OutputStreamWriter.write(OutputStreamWriter.java:191)
at org.apache.tomcat.util.buf.WriteConvertor.write(C2BConverter.java:228
)
at org.apache.tomcat.util.buf.C2BConverter.convert(C2BConverter.java:120
)
at org.apache.coyote.tomcat5.OutputBuffer.realWriteChars(OutputBuffer.ja
va:606)
at org.apache.tomcat.util.buf.CharChunk.flushBuffer(CharChunk.java:463)
at org.apache.coyote.tomcat5.OutputBuffer.flush(OutputBuffer.java:357)
at org.apache.coyote.tomcat5.CoyoteWriter.flush(CoyoteWriter.java:117)
at org.apache.jasper.runtime.JspWriterImpl.flush(JspWriterImpl.java:203)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary
.java:990)
...

In CharChunk, 

public void flushBuffer()
throws IOException
{
//assert out!=null
if( out==null ) {
throw new IOException( Buffer overflow, no sink  + limit +   +
   buff.length  );
}
out.realWriteChars( buff, start, end - start );
end=start;
}

when realWriteChars is called, the value for start is 0, end is 16384, and
buff.length is 8192, hence the exception.

Does anyone knows how end can go beyond 8192?  This only hapeens very
rarely, under heavy load.

-Kin-man





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



Re: [5] IndexOutOfBoundsException from CharChunk

2003-10-08 Thread Remy Maucherat
Kin-Man Chung wrote:

I am getting a sporadic IndexOutOfBoundsException and it seems to come from
org.apache.tomcat.util.buf.CharChunk.flushBuffer.  The trace is
Servlet.service() for servlet jsp threw exception
java.lang.IndexOutOfBoundsException
at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:132)
at java.io.OutputStreamWriter.write(OutputStreamWriter.java:191)
at org.apache.tomcat.util.buf.WriteConvertor.write(C2BConverter.java:228
)
at org.apache.tomcat.util.buf.C2BConverter.convert(C2BConverter.java:120
)
at org.apache.coyote.tomcat5.OutputBuffer.realWriteChars(OutputBuffer.ja
va:606)
at org.apache.tomcat.util.buf.CharChunk.flushBuffer(CharChunk.java:463)
at org.apache.coyote.tomcat5.OutputBuffer.flush(OutputBuffer.java:357)
at org.apache.coyote.tomcat5.CoyoteWriter.flush(CoyoteWriter.java:117)
at org.apache.jasper.runtime.JspWriterImpl.flush(JspWriterImpl.java:203)
at org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary
.java:990)
...
In CharChunk, 

public void flushBuffer()
throws IOException
{
//assert out!=null
if( out==null ) {
throw new IOException( Buffer overflow, no sink  + limit +   +
   buff.length  );
}
out.realWriteChars( buff, start, end - start );
end=start;
}
when realWriteChars is called, the value for start is 0, end is 16384, and
buff.length is 8192, hence the exception.
Does anyone knows how end can go beyond 8192?  This only hapeens very
rarely, under heavy load.
I don't know. I suppose limit is 8192 also. Are you sure your test is 
clean, and without anything weird ? (somehow, I doubt it)
I've changed a bit the algorithm in ByteChunk, and it seems better, but 
the CharChunk algorithm is identical in 4.1's ByteChunk and CharChunk. 
We would have noticed anything bad, I think.

Remy



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


Re: [5] IndexOutOfBoundsException from CharChunk

2003-10-08 Thread Kin-Man Chung

 Date: Wed, 08 Oct 2003 21:22:07 +0200
 From: Remy Maucherat [EMAIL PROTECTED]
 Subject: Re: [5] IndexOutOfBoundsException from CharChunk
 To: Tomcat Developers List [EMAIL PROTECTED]
 
 Kin-Man Chung wrote:
 
  I am getting a sporadic IndexOutOfBoundsException and it seems to come from
  org.apache.tomcat.util.buf.CharChunk.flushBuffer.  The trace is
  
  Servlet.service() for servlet jsp threw exception
  java.lang.IndexOutOfBoundsException
  at sun.nio.cs.StreamEncoder.write(StreamEncoder.java:132)
  at java.io.OutputStreamWriter.write(OutputStreamWriter.java:191)
  at 
org.apache.tomcat.util.buf.WriteConvertor.write(C2BConverter.java:228
  )
  at 
org.apache.tomcat.util.buf.C2BConverter.convert(C2BConverter.java:120
  )
  at 
org.apache.coyote.tomcat5.OutputBuffer.realWriteChars(OutputBuffer.ja
  va:606)
  at 
org.apache.tomcat.util.buf.CharChunk.flushBuffer(CharChunk.java:463)
  at 
org.apache.coyote.tomcat5.OutputBuffer.flush(OutputBuffer.java:357)
  at 
org.apache.coyote.tomcat5.CoyoteWriter.flush(CoyoteWriter.java:117)
  at 
org.apache.jasper.runtime.JspWriterImpl.flush(JspWriterImpl.java:203)
  at 
org.apache.jasper.runtime.JspRuntimeLibrary.include(JspRuntimeLibrary
  .java:990)
  ...
  
  In CharChunk, 
  
  public void flushBuffer()
  throws IOException
  {
  //assert out!=null
  if( out==null ) {
  throw new IOException( Buffer overflow, no sink  + limit +   
+
 buff.length  );
  }
  out.realWriteChars( buff, start, end - start );
  end=start;
  }
  
  when realWriteChars is called, the value for start is 0, end is 16384, and
  buff.length is 8192, hence the exception.
  
  Does anyone knows how end can go beyond 8192?  This only hapeens very
  rarely, under heavy load.
 
 I don't know. I suppose limit is 8192 also. Are you sure your test is 
 clean, and without anything weird ? (somehow, I doubt it)
 I've changed a bit the algorithm in ByteChunk, and it seems better, but 
 the CharChunk algorithm is identical in 4.1's ByteChunk and CharChunk. 
 We would have noticed anything bad, I think.
 

I don't know much about the test; it is one of stress test we have, but it
should not affect CharChunk this way, right, even if it has something
weird?  Like I said, this happens only in this test, and not always
reproducible, so I am not surprised that nobody noticed it in 4.1.  I
thought it might be thread related, but each thread should have its own
CharChunk instance, so I can't see how.  I look into this more and report
back.

-Kin-man

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


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