Opened 6 years ago

Closed 6 years ago

#777 closed defect (fixed)

i2psnark: java.lang.IndexOutOfBoundsException

Reported by: killyourtv Owned by: zzz
Priority: minor Milestone: 0.9.4
Component: apps/i2psnark Version: 0.9.3
Keywords: Cc: zab@…
Parent Tickets:

Description

{{{I2P version: 0.9.3-5-deb1
Java version: Oracle Corporation 1.7.0_03 (OpenJDK Runtime Environment 1.7.0_03-b21)
Wrapper version: 3.5.16
Server version: 6.1.26
Servlet version: Jasper JSP 2.1 Engine
Platform: Linux amd64 3.2.0-4-amd64
}}}

11/12/12 18:32:52.380 ERROR [ AwMD@OthNk2] g.klomp.snark.PeerConnectionIn: Error talking with AwMD@OthNk2 30814
     java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
     at java.util.ArrayList.rangeCheck(ArrayList.java:604)
     at java.util.ArrayList.get(ArrayList.java:382)
     at org.klomp.snark.PeerState.getOutstandingRequest(PeerState.java:375)
     at org.klomp.snark.PeerConnectionIn.run(PeerConnectionIn.java:150)
     at org.klomp.snark.Peer.runConnection(Peer.java:301)
     at org.klomp.snark.PeerCoordinator$1.run(PeerCoordinator.java:592)
     at java.lang.Thread.run(Thread.java:722)
     at net.i2p.util.I2PThread.run(I2PThread.java:85)

Subtickets

Change History (4)

comment:1 Changed 6 years ago by zzz

  • Status changed from new to accepted

Another one-in-a-million find. Thanks for the report. Probably dates back to 2005.

Just have to fix up some synchronization.

comment:2 Changed 6 years ago by zab

  • Cc zab@… added

just moves the sync up a little, half of the diff is indentation

#
# old_revision [9e8c854128fdc99ccfc2bd2a245d76660de57a09]
#
# patch "apps/i2psnark/java/src/org/klomp/snark/PeerState.java"
#  from [c3023bb696764cd5ab41d20f9211e8d78649e12b]
#    to [407d55e5bf263ec92238fc113823f9170f08606d]
#
============================================================
--- apps/i2psnark/java/src/org/klomp/snark/PeerState.java       c3023bb696764cd5ab41d20f9211e8d78649e12b
+++ apps/i2psnark/java/src/org/klomp/snark/PeerState.java       407d55e5bf263ec92238fc113823f9170f08606d
@@ -356,22 +356,22 @@ class PeerState implements DataLoader
                   + piece + "," + begin + "," + length + ") from "
                   + peer);
 
-    int r = getFirstOutstandingRequest(piece);
+    Request req;
+    synchronized(this)
+    {
+        int r = getFirstOutstandingRequest(piece);
 
-    // Unrequested piece number?
-    if (r == -1)
-      {
-        if (_log.shouldLog(Log.INFO))
-          _log.info("Unrequested 'piece: " + piece + ", "
-                      + begin + ", " + length + "' received from "
-                      + peer);
-        return null;
-      }
+        // Unrequested piece number?
+        if (r == -1)
+        {
+            if (_log.shouldLog(Log.INFO))
+                _log.info("Unrequested 'piece: " + piece + ", "
+                        + begin + ", " + length + "' received from "
+                        + peer);
+            return null;
+        }
 
-    // Lookup the correct piece chunk request from the list.
-    Request req;
-    synchronized(this)
-      {
+        // Lookup the correct piece chunk request from the list.
         req = outstandingRequests.get(r);
         while (req.getPiece() == piece && req.off != begin
                && r < outstandingRequests.size() - 1)

comment:3 Changed 6 years ago by zzz

ack. I have exactly the same thing coded and queued up for testing.

comment:4 Changed 6 years ago by zzz

  • Resolution set to fixed
  • Status changed from accepted to closed

Fixed in 0.9.3-7

Note: See TracTickets for help on using tickets.