OMNeT++/OMNEST Bug Tracker - OMNeT++
View Issue Details
0000964OMNeT++simulation kernelpublic2016-07-15 08:572016-07-15 08:57
x86_64Ubuntu16.04 (xenial)
0000964: Integer saturation in when when input value range is very large
When working with a custom PER calculation model, I found a bug within chistogram::setupRangeInteger ( line 333). The calculated PER value would exceed 1.0 by far, which would cause an integer overflow when calculating cellSize for non-fixed ranges. With a maximum recorded value of 2,32e+291 (long)ceil(rangeMax - rangeMin/200.0) would result in a negative value for numCels (0x8000000000000000), since (long) and not (unsigned long) is used.
This causes an error in cHistogram::transform() ( line 129):
cellv = new unsigned[numCells];
which results in: std::bad_array_new_length.

Changing the lines to cast to unsigned long instead, does not generate a negative value for numCells, but still results in std::bad_array_new_length. It seems as in this case some other limit is active.

It seems that a maximum or minimum check before the creation of the new array should be introduced avoiding the array creation failure.
- Use histogram in integer mode
- record very large value
No tags attached.
Issue History
2016-07-15 08:57pfefferkNew Issue

There are no notes attached to this issue.