[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Exception while retrieving the body



    vranganath> I am using soot 2.1.0 and I get the following
    vranganath> exception when retrieving the body for the
    vranganath> attached class. I used jikes to compile the
    vranganath> attached source.

This turned out to be a simple off-by-one error that caused the
part of Soot which initially turns bytecode into jimple to ignore
the last non-default choice in a tableswitch when it fixes up
references to inlined jsr subroutines. 

I've checked the fix into the development version of Soot.  I'll
append a one-line (really one-character) patch to fix the problem
in soot 2.1.0.

Just in case anybody at Sable lab ever wants to maintain a
collection of regression tests for fixed bugs, I'm also attaching
a very simple class file that triggers the bug, along with the
Java source from which jikes 1.18 produced the class file.

--- src/soot/coffi/CFG.java	2004-08-14 09:13:04.000000000 -0600
+++ /tmp/CFG.java	2004-08-14 09:13:34.000000000 -0600
@@ -924,7 +924,7 @@
 		    newdefault.labelled = true;
 		}
 
-		for (int i=0; i<switchinsn.high-switchinsn.low; i++)
+		for (int i=0; i<=switchinsn.high-switchinsn.low; i++)
 		{
 		    Instruction newtgt = 
 			(Instruction)replacedInsns.get(switchinsn.jump_insts[i]);
// Attempt to produce a simple test case that triggers the bug
// reported by Venkatesh Prasad Ranganath to soot-list on 9 August 2004.
//
// For this code to trigger the bug, it must be compiled by jikes (so that
// the switch is implemented with a tableswitch), rather
// than javac (which would use a lookupswitch).

class TableswitchBug {
    private static int excuseForFinally = 0;

    public static void bugTickler(int d) {
	excuseForFinally = 1;
	try {
	    switch (d) {
	    case 7: return;
	    }
	} finally {
	    excuseForFinally = 0;
	}
    }
}

Attachment: TableswitchBug.class
Description: Class that triggers Soot-2.1.0's tableswitch to jsr bug