Closed ArtemUntila closed 2 years ago
Issue.java:
Issue.java
1. public class Issue { 2. 3. public static void main(String[] args) { 4. if (args.length != 1) 5. throw new IllegalArgumentException(); 6. Integer length = getLength(args[0]); 7. String output = "Empty"; 8. if (length != null) { 9. output = "Not " + output; 10. } 11. System.out.println(output); 12. } 13. 14. private static Integer getLength(String s) { 15. int length = s.length(); 16. if (length == 0) { 17. return null; 18. } 19. return length; 20. } 21. 22. }
Running Slicer4J w.r.t. Issue:11 line:
Issue:11
cd scripts python3 slicer4j.py -j ../issue.jar -o ../issue -b Issue:11 -m "Issue something"
And it fails with:
Slicing from line Issue:11 Traceback (most recent call last): ... UnboundLocalError: local variable 'sc' referenced before assignment
https://github.com/resess/Slicer4J/blob/235b4661dbfc414cd8d629d127d2c5984d933ebe/scripts/slicer4j.py#L117 The reason is that trace.log_icdg.log does not contain jimple-statement println() and statement with LINENO:11:FILE:Issue at all. If we remove some of the statements if (args.length != 1), if (javaFiles != null) or method call with parameter args[0] – getLength(args[0]), it will work fine.
trace.log_icdg.log
println()
LINENO:11:FILE:Issue
if (args.length != 1)
if (javaFiles != null)
args[0]
getLength(args[0])
Thank you for bringing this to my attention. Fixed in latest commit in the dynamic slicing core. Added this issue as a test case.
Issue.java
:Running Slicer4J w.r.t.
Issue:11
line:And it fails with:
https://github.com/resess/Slicer4J/blob/235b4661dbfc414cd8d629d127d2c5984d933ebe/scripts/slicer4j.py#L117 The reason is that
trace.log_icdg.log
does not contain jimple-statementprintln()
and statement withLINENO:11:FILE:Issue
at all. If we remove some of the statementsif (args.length != 1)
,if (javaFiles != null)
or method call with parameterargs[0]
–getLength(args[0])
, it will work fine.