UnitTestBot / UnitTestBot/usvm

Incorrect setting collection field to null leads to further problems with iterator

Open
#111 0 comments 0 reactions 1 assignee View on GitHub

@Saloed is already working on this.

Since Nov 16, 2023.

bug
Dominant language
Kotlin
Stars
33
Forks
27
Avg merge
4d 3h
Merged PRs (30d)
15

Description

Generate tests in the following configuration:

timeLimit=60
methodFilter = "org.usvm.samples.arrays.ArrayStoreExceptionExamples.*"
projectFilter = listOf("samples")

An failing test:

@Test
    public void testFillWithTreeSet1() throws Exception  {
        ArrayStoreExceptionExamples arrayStoreExceptionExamples = new ArrayStoreExceptionExamples();
        TreeSet treeSet = ((TreeSet) createInstance("java.util.TreeSet"));
        setField(treeSet, "java.util.TreeSet", "m", null);
        
        java.lang.Object[] actual = arrayStoreExceptionExamples.fillWithTreeSet(treeSet);
        
        java.lang.Object[] expected = new java.lang.Object[1];
        TreeSet treeSet1 = ((TreeSet) createInstance("java.util.TreeSet"));
        Object present = createInstance("java.lang.Object");
        setField(treeSet1, "java.util.TreeSet", "PRESENT", present);
        setField(treeSet1, "java.util.TreeSet", "serialVersionUID", -2479143000061671589L);
        setField(treeSet1, "java.util.AbstractCollection", "MAX_ARRAY_SIZE", 2147483639);
        expected[0] = ((Object) treeSet1);
        
        int expectedSize = expected.length;
        assertEquals(expectedSize, actual.length);
        assertTrue(deepEquals(expected, actual));
    }

Let's pay attention to the line: setField(treeSet, "java.util.TreeSet", "m", null);
During the deepEquals method call, NullPointerException occurs.

image
image

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.