[Mono-bugs] [Bug 417833] BitVector32. CreateSection allows the creation of illegal sections

bugzilla_noreply at novell.com bugzilla_noreply at novell.com
Fri Aug 22 22:04:14 EDT 2008


https://bugzilla.novell.com/show_bug.cgi?id=417833

User lunchtimemama at gmail.com added comment
https://bugzilla.novell.com/show_bug.cgi?id=417833#c6





--- Comment #6 from Scott Peterson <lunchtimemama at gmail.com>  2008-08-22 20:04:13 MDT ---
Yes, the .NET implementation is also buggy. Given the following code:

using System;
using System.Collections.Specialized;

public class BitVector32Test {
    public static void Main() {
        var s1 = BitVector32.CreateSection(32767);
        var s2 = BitVector32.CreateSection(32767, s1);
        var s3 = BitVector32.CreateSection(4, s2);
        var bv = new BitVector32(0);
        bv[s3] = 4;
        Console.WriteLine(bv[s3]);
    }
}

The expected output is '4' but the actual output on .NET (and Mono, currently)
is '0'. It takes 15 bits to store the number 32767 and three bits to store the
number 4. Two 15-bit sections and one 3-bit section totals 33 bits. That's
obviously not going to fit in a BitVector32.

As for duplicating the .NET bug for compatibility, I don't know what the
standard protocol is for these sorts of things, but I imagine that fixing this
bug can't do any harm: there should not be any code which depends on this bug
since any code which encounters this bug is vulnerable to a logical error and
should be fixed, and the workaround is just to use sections whose sum total
length is <= 32.


-- 
Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the QA contact for the bug.


More information about the mono-bugs mailing list