You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by "Hoss Man (JIRA)" <ji...@apache.org> on 2014/09/02 21:48:21 UTC
[jira] [Updated] (SOLR-6457) LBHttpSolrServer: AIOOBE risk if
counter overflows
[ https://issues.apache.org/jira/browse/SOLR-6457?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Hoss Man updated SOLR-6457:
---------------------------
Description:
org.apache.solr.client.solrj.impl.LBHttpSolrServer
line 442
int count = counter.incrementAndGet();
ServerWrapper wrapper = serverList[count % serverList.length];
when counter overflows, the mod operation of
"count % serverList.length" will start trying to use negative numbers as array indexes.
suggess to fixup it ,eg:
//keep count is greater than 0
int count = counter.incrementAndGet() & 0x7FFFFFF;
was:
org.apache.solr.client.solrj.impl.LBHttpSolrServer
line 442
int count = counter.incrementAndGet();
ServerWrapper wrapper = serverList[count % serverList.length];
when count > Integer.MAX_VALUE
count % serverList.length will loop by 0,-1,0,-1..........
suggess to fixup it ,eg:
//keep count is greater than 0
int count = counter.incrementAndGet() & 0x7FFFFFF;
Summary: LBHttpSolrServer: AIOOBE risk if counter overflows (was: loadblance will not work when count > Integer.MAX_VALUE)
clarified summary & description to better explain hte problem (counter is an AtomicInteger, so the count can never be greater then Integer.MAX_VALUE -- the problem is what happens when it overflows to negative numbers.
additional questions i have when looking at this code:
* why is a counter being used here instead of picking a random element?
* why is the counter an int instead of a long (do we really care about saving a few bytes in this?)
> LBHttpSolrServer: AIOOBE risk if counter overflows
> --------------------------------------------------
>
> Key: SOLR-6457
> URL: https://issues.apache.org/jira/browse/SOLR-6457
> Project: Solr
> Issue Type: Bug
> Components: clients - java
> Affects Versions: 4.0, 4.1, 4.2, 4.2.1, 4.3, 4.3.1, 4.4, 4.5, 4.5.1, 4.6, 4.6.1, 4.7, 4.7.1, 4.7.2, 4.8, 4.8.1, 4.9
> Reporter: longkeyy
> Labels: patch
>
> org.apache.solr.client.solrj.impl.LBHttpSolrServer
> line 442
> int count = counter.incrementAndGet();
> ServerWrapper wrapper = serverList[count % serverList.length];
> when counter overflows, the mod operation of
> "count % serverList.length" will start trying to use negative numbers as array indexes.
> suggess to fixup it ,eg:
> //keep count is greater than 0
> int count = counter.incrementAndGet() & 0x7FFFFFF;
--
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