Dumb Divide-and-Conquer Debugging

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:

public static synchronized void add(ISyncPoint sp) {
if (_syncPoints==null) {
_syncPoints = new ArrayList();
// _syncPoints.add(sp);

Interestingly enough, now it hangs. I guess now I’ll venture into ArrayList to look for a reason.


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.

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...


About Mathias

Software development engineer. Principal developer of DrJava. Recent Ph.D. graduate from the Department of Computer Science at Rice University.
This entry was posted in Concurrent Unit Testing. Bookmark the permalink.

Leave a Reply