Detecting stack overflow errors

34 views
Skip to first unread message

Michael Pradel

unread,
Feb 27, 2012, 4:17:54 AM2/27/12
to java-pa...@googlegroups.com
Hi,

running the following program with JPF leads to an out of memory error,
but I would expect a stack overflow error:

public class StackOverflow {
public static void main(String[] args) {
new StackOverflow().m();
}
public void m() {
m();
}
}


Is there a way to make JPF report a StackOverFlowError here? E.g. can I
set the maximal stack size in JPF, similar to -Xss for the Java HotSpot VM?


Thanks,
Michael

signature.asc

Tarciana Dias da Silva

unread,
Feb 27, 2012, 11:43:37 AM2/27/12
to java-pa...@googlegroups.com
--
Tarciana

Tarciana Dias da Silva

unread,
Feb 27, 2012, 12:16:16 PM2/27/12
to java-pa...@googlegroups.com
Hi Michael,
you have to add on comand line: java .... RunJPF.jar ... 

the parameter -Xmx1024m or like i did in mine: -Xmx4g
Then, probably the out of memory error will not occur.

On Mon, Feb 27, 2012 at 6:17 AM, Michael Pradel <mic...@binaervarianz.de> wrote:



--
Tarciana

Peter Mehlitz

unread,
Feb 27, 2012, 1:07:59 PM2/27/12
to java-pa...@googlegroups.com
The out-of-memory happens because from JPFs perspective there is no stack limit so far. While the vm.max_transition_length probably breaks transitions, the CFSerializer does not match states because of the different stack depths, so this keeps executing until the number of states grows too big.

A stack depth checker is pretty easy to implement as a methodEntered()/methodExited() listener. I might add it to the BudgetChecker.

-- Peter

Peter Mehlitz

unread,
Feb 27, 2012, 2:56:50 PM2/27/12
to java-pa...@googlegroups.com
now there is - gov.nasa.jpf.listener.StackDepthChecker.
10 lines of code

-- Peter

Michael Pradel

unread,
Feb 28, 2012, 12:49:41 AM2/28/12
to java-pa...@googlegroups.com
> now there is - gov.nasa.jpf.listener.StackDepthChecker.
> 10 lines of code

Thank you all for your help! The StackDepthChecker is exactly what I was
looking for.

Michael

signature.asc
Reply all
Reply to author
Forward
0 new messages