UShortSet not storing values correctly

Issue #46 resolved
Daniel Klauer created an issue

When storing certain values into a UShortSet, it will sometimes end up containing entries with the value 65535 (0xFFFF) instead of the values that were inserted, and it will even have more entries than the amount of performed insert operations. For example:

object TestUShortSet {
    def main(args: Array[String]) {
        var set: UShortSet = UShortSet.empty

        set += 61149
        set += 61154
        set += 61158

        println(set.size)
        println(set)
    }
}

The output I'm seeing from this

4
UShortSet(61149,61154,65535,65535)

but I'm expecting the following:

3
UShortSet(61149,61154,61158)

This is causing issues for FindRealBugs' UninitializedFieldAccessDuringStaticInitialization analyses which uses RecordReturnFromMethodInstructions in its custom Domain. RecordReturnFromMethodInstructions uses a UShortSet in order to collect the PCs of all return instructions. However, the UShortSet it uses to hold these PCs ends up containing incorrect values; specifically lots of 65535 at the end instead of the real expected values.

This happens (only) with a certain class file from the argouml project from the Qualitas Corpus containing a huge <clinit> method with 41033 instructions, and the last instruction at PC 61158. There is only one returnVoid at the end, but RecordReturnFromMethodInstructions still collects a lot of PCs due to abruptMethodExecution. There are 10252 abruptMethodExecutions + 1 returnVoid, but the UShortSet ends up having 11445 entries. The first 10252 entries are the input data except that one PC (32789) is missing, the last 1193 entries are all 65535.

Comments (5)

  1. Log in to comment