You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Luc Vanlerberghe (JIRA)" <ji...@apache.org> on 2015/04/10 16:14:12 UTC
[jira] [Comment Edited] (LUCENE-6409) LongBitSet.ensureCapacity
overflows on numBits > Integer.MaxValue
[ https://issues.apache.org/jira/browse/LUCENE-6409?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14489470#comment-14489470 ]
Luc Vanlerberghe edited comment on LUCENE-6409 at 4/10/15 2:13 PM:
-------------------------------------------------------------------
I added testBits2Words on TestLongBitSet with various values, concentrating on boundary cases
I found some more issues that may cause spurious side effects.
While trying to correct them, it turns out that the tests do 'illegal' things (like setting bits outside the [0, numBits[ range by manipulating the backing array directly)
This should cause things like cardinality() to fail (because it doesn't use a mask for the last long, probably for performance), but apparently that's never tested.
I propose that creating a new Long-/FixedBitSet based on an existing backing array should assert (in debug mode) that all the 'ghost' bits with index >= numBits should be clear.
Perhaps I should create a new issue for this to allow the ensureCapacity bug to be closed first.
was (Author: lvl):
I added testBits2Words on TestLongBitSet with various values, concentrating on boundary cases
I found some more issues that may cause spurious side effects.
While trying to correct them, it turns out that the tests do 'illegal' things causing (like setting bits outside the [0, numBits[ range by manipulating the backing array directly)
This should cause things like cardinality() to fail (because it doesn't use a mask for the last long, probably for performance), but apparently that's never tested.
I propose that creating a new Long-/FixedBitSet based on an existing backing array should assert (in debug mode) that all the 'ghost' bits with index >= numBits should be clear.
Perhaps I should create a new issue for this to allow the ensureCapacity bug to be closed first.
> LongBitSet.ensureCapacity overflows on numBits > Integer.MaxValue
> -------------------------------------------------------------------
>
> Key: LUCENE-6409
> URL: https://issues.apache.org/jira/browse/LUCENE-6409
> Project: Lucene - Core
> Issue Type: Bug
> Components: core/other
> Reporter: Luc Vanlerberghe
>
> LongBitSet.ensureCapacity calculates the number of longs required to store the number of bits correctly and allocates a long[] accordingly, but then shifts the array length (which is an int!) left by 6 bits. The int should be cast to long *before* performing the shift.
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)
---------------------------------------------------------------------
To unsubscribe, e-mail: dev-unsubscribe@lucene.apache.org
For additional commands, e-mail: dev-help@lucene.apache.org