Skip to content

Commit 5cdf508

Browse files
committed
Using maybe unsound jumps to saturate edge set
1 parent bef1465 commit 5cdf508

File tree

2 files changed

+28
-3
lines changed

2 files changed

+28
-3
lines changed

src/main/java/it/unipr/EVMLiSA.java

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,8 @@
3535
import org.apache.commons.cli.Option;
3636
import org.apache.commons.cli.Options;
3737
import org.apache.commons.cli.ParseException;
38+
import org.apache.commons.collections4.SetUtils;
39+
import org.apache.commons.collections4.SetUtils.SetView;
3840
import org.apache.logging.log4j.LogManager;
3941
import org.apache.logging.log4j.Logger;
4042

@@ -696,18 +698,22 @@ private static Set<Statement> getSoundlySolvedJumps(JumpSolver checker, LiSA lis
696698
fixpoint = false;
697699
EVMCFG cfg = checker.getComputedCFG();
698700
Set<Statement> jumpdestNodes = cfg.getAllJumpdest();
699-
for (Statement unsoundNode : checker.getUnsoundJumps())
701+
Set<Statement> unsoundJumps = checker.getUnsoundJumps();
702+
Set<Statement> maybeUnsoundJumps = checker.getMaybeUnsoundJumps();
703+
Set<Statement> unsound = unsoundJumps == null ? Collections.emptySet() : unsoundJumps;
704+
unsound = maybeUnsoundJumps == null ? unsound : SetUtils.union(unsound, maybeUnsoundJumps);
705+
for (Statement unsoundNode : unsound)
700706
if (!soundlySolved.contains(unsoundNode)) {
701707
fixpoint = true;
702708
for (Statement jumpdest : jumpdestNodes)
703709
cfg.addEdge(new SequentialEdge(unsoundNode, jumpdest));
704710
}
705711

706-
soundlySolved.addAll(checker.getUnsoundJumps());
712+
soundlySolved.addAll(unsound);
707713

708714
program.addCodeMember(cfg);
709715
lisa.run(program);
710-
} while (fixpoint && checker.getUnsoundJumps() != null && ++currentIteration < MAX_ITER);
716+
} while (fixpoint && ++currentIteration < MAX_ITER);
711717
}
712718
return soundlySolved;
713719
}

src/main/java/it/unipr/checker/JumpSolver.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,18 +75,37 @@ public EVMCFG getComputedCFG() {
7575
return cfgToAnalyze;
7676
}
7777

78+
/**
79+
* Yields the jumps where the whole value state is bottom (i.e., the jump is
80+
* unreachable).
81+
* @return the set of unreachable jumps
82+
*/
7883
public Set<Statement> getUnreachableJumps() {
7984
return unreachableJumps;
8085
}
8186

87+
/**
88+
* Yields the jumps where the whole value state is top (i.e., the jump is
89+
* maybe unsound).
90+
* @return the set of maybe unsound jumps
91+
*/
8292
public Set<Statement> getMaybeUnsoundJumps() {
8393
return maybeUnsoundJumps;
8494
}
8595

96+
/**
97+
* Yields the jumps where at least one of the top stack values is top (i.e., the jump is
98+
* unsound).
99+
* @return the set of unsound jumps
100+
*/
86101
public Set<Statement> getUnsoundJumps() {
87102
return unsoundJumps;
88103
}
89104

105+
/**
106+
* The set of top stack values per jump. This only exists for jumps that are
107+
* not in {@link #getMaybeUnsoundJumps()} and {@link #getUnreachableJumps()}.
108+
*/
90109
public Set<StackElement> getTopStackValuesPerJump(Statement node) {
91110
return topStackValuesPerJump.get(node);
92111
}

0 commit comments

Comments
 (0)