[CoinUtils-tickets] [COIN-OR Common Utilities] #75: integer overflow in CoinArrayWithLength

COIN-OR Common Utilities coin-trac at coin-or.org
Mon Apr 2 14:54:41 EDT 2012


#75: integer overflow in CoinArrayWithLength
-----------------------+----------------
  Reporter:  mlubin    |     Owner:
      Type:  defect    |    Status:  new
  Priority:  critical  |   Version:
Resolution:            |  Keywords:
-----------------------+----------------

Comment (by patra):

 There are two different issues here:

 * The first issue is that as long as CoinBigIndex is 32 bit, no array can
 have more than 2^31^ entries. Changing CoinBigIndex to 64 bit has two
 drawbacks:

   a) some code like cbc does not always correctly differentiate between
 CoinBigIndex and int, so compilation becomes a bit of an issue when
 CoinBigIndex is changed

   b) nontrivial operations on 64-bit integers come at a performance
 penalty, so it might be a good to leave that choice to the user.

 * The second and more pressing issue is that anything derived from
 CoinArrayWithLength is not limited to 2^31^ entries but rather to 2^31^
 bytes. For a CoinDoubleArrayWithLength, this is a difference between 2
 GBytes and 16 GBytes. For my applications (with cbc), 2^31 entries is
 sufficient but 2^31 bytes is not.

 For this reason, I have modified the code to allow more than 2^31^ bytes
 while
 still being limited to 2^31^ entries. Since only trivial operations are
 done on
 the size field, I expect no performance degradation. In addition, this
 should minimise outside interference. I have attached the patch against
 CoinUtils that is part of the latest cbc release (see attached file).

 Unfortunately, CoinUtils has changed since the time that the fork for the
 cbc release was made. I have modified the patch to work with the current
 CoinUtils from the svn. It will pass the basic tests of "make test" but in
 the contrast to the cbc-coinutils patch, I have not used it for actual
 work. The c++ standard has a data type for indices, namely ptrdiff_t, so I
 put that in as a kind of "signed size_t".

-- 
Ticket URL: <https://projects.coin-or.org/ticket/75#comment:1>
COIN-OR Common Utilities <http://projects.coin-or.org/CoinUtils>
Common data structures and linear algebra functions for COIN-OR projects



More information about the CoinUtils-tickets mailing list