UnitTestBot / UnitTestBot/usvm
NPE when using java.lang.System.out/java.lang.System.err
Nobody has claimed this yet.
- Dominant language
- Kotlin
- Stars
- 33
- Forks
- 27
- Avg merge
- 4d 3h
- Merged PRs (30d)
- 15
Description
I run USVM on the the following function (Java Juliet test suite)
public void bad() throws Throwable
{
byte data;
/* POTENTIAL FLAW: Use the maximum size of the data type */
data = Byte.MAX_VALUE;
/* POTENTIAL FLAW: if data == Byte.MAX_VALUE, this will overflow */
byte result = (byte)(data + 1);
IO.writeLine("result: " + result);
}
IO is implemented as follows.
There is an unexpected NPE during the USVM run.
Instruction: %0.println(arg$0)
Exception: JcException: Address: 0x15, type: java.lang.NullPointerException
Call stack (contains 2 frames):
0: UCallStackFrame(method=(id:73)javajuliet.testcase.CWE190_Integer_Overflow.CWE190_Integer_Overflow__byte_max_add_01#bad(), returnSite=null)
1: UCallStackFrame(method=(id:73)javajuliet.testcasesupport.IO#writeLine(java.lang.String), returnSite=javajuliet.testcasesupport.IO.writeLine(%7))
Assignments to null:
Instruction: java.lang.System.out = null
Call stack (contains 3 frames):
0: UCallStackFrame(method=(id:73)javajuliet.testcase.CWE190_Integer_Overflow.CWE190_Integer_Overflow__byte_max_add_01#bad(), returnSite=null)
1: UCallStackFrame(method=(id:73)javajuliet.testcasesupport.IO#writeLine(java.lang.String), returnSite=javajuliet.testcasesupport.IO.writeLine(%7))
2: UCallStackFrame(method=(id:1)java.lang.System#<clinit>(), returnSite=%0 = java.lang.System.out)
================================================================
Instruction: java.lang.System.err = null
Call stack (contains 3 frames):
0: UCallStackFrame(method=(id:73)javajuliet.testcase.CWE190_Integer_Overflow.CWE190_Integer_Overflow__byte_max_add_01#bad(), returnSite=null)
1: UCallStackFrame(method=(id:73)javajuliet.testcasesupport.IO#writeLine(java.lang.String), returnSite=javajuliet.testcasesupport.IO.writeLine(%7))
2: UCallStackFrame(method=(id:1)java.lang.System#<clinit>(), returnSite=%0 = java.lang.System.out)
And the final result is
20:08:04.945 |I| TestRunnerKt - 1 executions were found:
JcTest(method=org.jacodb.impl.types.JcTypedMethodImpl@7131da33, before=JcParametersState(thisInstance=javajuliet.testcase.CWE190_Integer_Overflow.CWE190_Integer_Overflow__byte_max_add_01@6a278584, parameters=[]), after=JcParametersState(thisInstance=javajuliet.testcase.CWE190_Integer_Overflow.CWE190_Integer_Overflow__byte_max_add_01@28f90752, parameters=[]), result=Failure(java.lang.NullPointerException), coverage=JcCoverage(targetClassToCoverage={}))
Extracted values:
[javajuliet.testcase.CWE190_Integer_Overflow.CWE190_Integer_Overflow__byte_max_add_01@6a278584, null]
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the Java Juliet bad() case through javajuliet.testcasesupport.IO.writeLine and inspect the java.lang.System.() trace, especially assignments to System.out and System.err. Compare the modeled initialization with the observed println call; done means the USVM run no longer fails with the reported NullPointerException for this reproducer.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, kotlin
- Domain
- devtools, testing-qa
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100