I’m running a few dumb divide-and-conquer tests to find out why the code is blocking (that’s generally how debugging this stuff works). Initially, I commented out everything in SyncPointRecorder.add(), and not surprisingly, everything worked. I wasn’t getting any data, of course, but the slave didn’t hang.
Now I commented out just the statement that adds the synchronization point to the list:
1 2 3 4 5 6 | public static synchronized void add(ISyncPoint sp) { if (_syncPoints==null) { _syncPoints = new ArrayList<ISyncPoint>(); } // _syncPoints.add(sp); } |
Interestingly enough, now it hangs. I guess now I’ll venture into ArrayList to look for a reason.
Update
The constructor of ArrayList doesn’t seem to do anything but a new Object[10]
, so there isn’t a lot of interesting stuff to see. I wrote a quick hack to see if array allocation is the problem and replaced the ArrayList with a biiiig array (and assume that it never fills up, or I’d lose lots of data). The JPDA monitor reads out the array and resets the write index to 0.
1 2 3 4 5 6 7 8 9 10 | public class SyncPointRecorder { private static final int SIZE = 2 << 12; private static volatile ISyncPoint[] _syncPoints = new ISyncPoint[SIZE]; private static volatile int _index = 0; public static synchronized void add(ISyncPoint sp) { _syncPoints[_index] = sp; // hangs here _index = (_index + 1) & (SIZE-1); } } |
However, that’s not the issue either. Now the program hangs in line 6. What can go wrong in assigning a reference to an array entry? Huhumm…