From a029983e95768e46635c847f4892f33ed0237114 Mon Sep 17 00:00:00 2001 From: jjenista Date: Tue, 4 Oct 2011 15:46:35 +0000 Subject: [PATCH] A test that exposed the bug that I just fixed --- .../out-of-context-reach-convert/makefile | 64 +++++++++++++++ .../out-of-context-reach-convert/test.java | 77 +++++++++++++++++++ 2 files changed, 141 insertions(+) create mode 100644 Robust/src/Tests/disjoint/out-of-context-reach-convert/makefile create mode 100644 Robust/src/Tests/disjoint/out-of-context-reach-convert/test.java diff --git a/Robust/src/Tests/disjoint/out-of-context-reach-convert/makefile b/Robust/src/Tests/disjoint/out-of-context-reach-convert/makefile new file mode 100644 index 00000000..fffc8031 --- /dev/null +++ b/Robust/src/Tests/disjoint/out-of-context-reach-convert/makefile @@ -0,0 +1,64 @@ +PROGRAM=Test + +SOURCE_FILES=test.java + +BUILDSCRIPT=../../../buildscript + +COREPROFOVERFLOW= #-coreprof-checkoverflow +USECOREPROF= #-coreprof $(COREPROFOVERFLOW) \ + -coreprof-eventwords 1024*1024*128 \ + -coreprof-enable cpe_main \ + -coreprof-enable cpe_runmalloc \ + -coreprof-enable cpe_runfree \ + -coreprof-enable cpe_count_poolalloc \ + -coreprof-enable cpe_count_poolreuse \ + -coreprof-enable cpe_workschedgrab \ + -coreprof-enable cpe_taskdispatch \ + -coreprof-enable cpe_taskexecute \ + -coreprof-enable cpe_taskretire +# -coreprof-enable cpe_taskstallvar \ +# -coreprof-enable cpe_taskstallmem + + +DISJOINT= -disjoint -disjoint-k 1 -enable-assertions -disjoint-dvisit-stack-callees-on-top +# -disjoint-debug-callsite Test.context2 Test.context1 1 500 true +# -disjoint-debug-callsite Test.context1 Test.innerMain 1 500 true +# -disjoint-write-initial-contexts \ +# -disjoint-debug-snap-method Test.context1 1 100 true \ +#-disjoint-desire-determinism + +USEOOO= #-ooojava 24 2 -ooodebug -squeue +USERCR= #-ooojava 23 2 -rcr -ooodebug -squeue + +BSFLAGS= -justanalyze -mainclass $(PROGRAM) -heapsize-mb 1024 -garbagestats -noloop -joptimize -debug #-ooodebug-disable-task-mem-pool -64bit + + +all: ooo + + +single: + $(BUILDSCRIPT) $(BSFLAGS) -thread -o $(PROGRAM)s -builddir sing $(SOURCE_FILES) + + +ooo: $(PROGRAM)p.bin + +$(PROGRAM)p.bin: $(SOURCE_FILES) makefile + $(BUILDSCRIPT) $(BSFLAGS) $(USECOREPROF) $(USEOOO) $(DISJOINT) -o $(PROGRAM)p -builddir par $(SOURCE_FILES) + +rcr: $(PROGRAM)r.bin + +$(PROGRAM)r.bin: $(SOURCE_FILES) makefile + $(BUILDSCRIPT) $(BSFLAGS) $(USECOREPROF) $(USERCR) $(DISJOINT) -o $(PROGRAM)r -builddir rcr $(SOURCE_FILES) + + +clean: + rm -f $(PROGRAM)p.bin $(PROGRAM)r.bin $(PROGRAM)s.bin + rm -fr par rcr sing + rm -f *~ + rm -f *.dot + rm -f *.png + rm -f *.txt + rm -f aliases.txt + rm -f mlpReport*txt + rm -f results*txt + rm -f coreprof.dat diff --git a/Robust/src/Tests/disjoint/out-of-context-reach-convert/test.java b/Robust/src/Tests/disjoint/out-of-context-reach-convert/test.java new file mode 100644 index 00000000..4ac3a598 --- /dev/null +++ b/Robust/src/Tests/disjoint/out-of-context-reach-convert/test.java @@ -0,0 +1,77 @@ +/////////////////////////////////////////////////////////////////// +// +// THIS BUG IS FIXED, the graphs created from the genreach statements +// in this example program show that (particularly var x2 in the innerMain method) +// the objects retain the correct reachability states throughout the contexts. +// +/////////////////////////////////////////////////////////////////// + + + + + +public class Foo { + public Foo f; +} + + +public class Test { + + static public void main( String args[] ) { + // The initial context is special in the sense that it gets + // tinkered with by the analysis even though it is not special + // semantically. When probing the analysis for bugs, it can't + // hurt to just always skip this context. + innerMain(); + } + + static public void innerMain() { + Foo z = get1(); + Foo x = new Foo(); + z.f = x; + + Foo z2 = get1(); + Foo x2 = new Foo(); + z2.f = x2; + + genreach context0before; + context1( x, x2 ); + // BOOM! Right now this shows nodes/edges downstream of x + // lose their reach states!! + genreach context0post; + + System.out.println( "" + z + x + z2 + x2 ); + } + + static public void context1( Foo x, Foo x2 ) { + // x is reachable from z (site 1), but z is out of the callee + // context. Watch what happens to z's out-of-callEE context name + // when we allocate another object from site 1 in this context. + genreach context1before; + Foo y = get1(); + genreach context1mid; + context2( x2 ); + genreach context1post; + + // consume x and y to prevent optimizing them away + System.out.println( "" + x + y + x2 ); + } + + static public void context2( Foo q ) { + // I think whatever you pass in here will accidentally lose its + // out-of-context edge information after applying the effects of + // this call, even though it does nothing. + // YES, THAT IS TRUE + genreach context2before; + context3( q ); + genreach context2post; + } + + static public void context3( Foo q ) { + genreach context3; + } + + static public Foo get1() { + return disjoint F1 new Foo(); + } +} -- 2.34.1