Strange bug inside jetty at shenandoah/jdk8u

Kirill A. Korinsky kirill at korins.ky
Thu Dec 14 17:52:11 UTC 2017


Good day!

I've tried use shenandoah on real application and found strange behaviour.

The application is usual java-http-server (jgroup, spring, jetty, etc) that listen to port and responses to request.

If remove from arguments all `-D[application settings]` the start command looks like:
> java -server -Duser.timezone=UTC -XX:-OmitStackTraceInFastThrow -Xmx4096 -Xms4096 -server ${GC_OPTIONS} -Djava.net.preferIPv4Stack=true -Djava.security.auth.login.config=/opt/server/conf/jaas.conf -jar /path/to/shade.jar


It runs inside docker container and I tried use shipilev/openjdk:8-shenandoah and openjdk-8 from fedora:27 but it has same behaviour.

When I run tests over ab I had strange error inside jetty:

> 2017-12-14 11:30:08 WARN  HttpParser: - parse exception: java.lang.IndexOutOfBoundsException: 32 for HttpChannelOverHttp at 779b4be{r=152,c=false,a=IDLE,uri=null}
> java.lang.IndexOutOfBoundsException: 32
> at java.nio.HeapByteBuffer.get(HeapByteBuffer.java:139) ~[?:1.8.0_151]
> at org.eclipse.jetty.http.HttpParser.parseLine(HttpParser.java:785) ~[jetty-http-9.3.22.v20171030.jar:9.3.22.v20171030]
> at org.eclipse.jetty.http.HttpParser.parseNext(HttpParser.java:1328) ~[jetty-http-9.3.22.v20171030.jar:9.3.22.v20171030]
> at org.eclipse.jetty.server.HttpConnection.parseRequestBuffer(HttpConnection.java:351) ~[jetty-server-9.3.22.v20171030.jar:9.3.22.v20171030]
> at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:234) ~[jetty-server-9.3.22.v20171030.jar:9.3.22.v20171030]

The code near this get() bellow

> if (version!=null)
> {
>     int pos = buffer.position()+version.asString().length()-1;
>     if (pos<buffer.limit())
>     {
>         byte n=buffer.get(pos);
>         if (n==HttpTokens.CARRIAGE_RETURN)

it is crashed at line `buffer.get(pos)`

If we checked `buffer.get(...)` code we will see

> public byte get(int i) {
>     return hb[ix(checkIndex(i))];
> }

and if checked `checkIndex()`

> final int checkIndex(int i) {                       // package-private
>     if ((i < 0) || (i >= limit))
>         throw new IndexOutOfBoundsException();
>     return i;
> }

but `IndexOutOfBoundsException()` trhows at `get()`, not at `checkIndex()` :(

Anyway, if I remove `-XX:+UseShenandoahGC` everything works well.

I can't run it at shipilev/openjdk:8-shenandoah-fastdebug because JVM crashed without logs

I attached gc log that I got when run this application with options: `-XX:+UseShenandoahGC -XX:+ShenandoahVerify -XX:ShenandoahGCHeuristics=aggressive -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps` but it didn't start, just worked sometime and crashed without any exception or error at application level.

--
wbr, Kirill



More information about the shenandoah-dev mailing list