We observed this problem on boost 1.71, but it is also present in 1.81.
Problem description
On a system with 4-byte int and an INT_MAX of 2147483647, attempting to store more than that in a basic_vectorbuf causes problems due to converting a larger type (std::char_traits::off_type or std::vector::difference_type) to an int:
std::streambuf::pbump and std::streambuf::gbump both implicitly convert to int,
- passing more than
INT_MAX to these functions moves pptr/gptr before pbase/eback - access causes segmentation fault;
- there are a couple of other type casts to
int which would also produce negative offsets due to overflow.
How to reproduce
The problem is fully reproducible by
- storing more than
INT_MAX elements in a basic_vectorbuf, or
- using
reserve() to allocate more than INT_MAX elements, and then calling seekoff or tellp() once the write position has advanced past INT_MAX.