[m-rev.] for review: more specific errors when file sizes exceed maximum buffer sizes

Julien Fischer jfischer at opturion.com
Mon Oct 28 11:44:06 AEDT 2019


On Fri, 25 Oct 2019, Julien Fischer wrote:

> More specific errors when file sizes exceed maximum buffer sizes.
>
> Predicates such as read_file_as_string and read_binary_input_as_bitmap, use
> buffers that are backend by Mercury arrays.  Since Mercury arrays are indexed
> using the int type, it is possible to cause the buffer index to overflow when
> reading large files on 32-bit platforms.  Detect this situation and throw an
> exception that is specific to it.  Currently, the behaviour we get depends on
> how much the overflowing index wraps around.
>
> As part of the above, fix the XXXs where we were casting 64-bit stream file
> sizes to ints; file stream files sizes are now always returned as int64s.

Any takers to review this one?  (Note: there are some additional
problems on Windows not addressed by this diff, namely that we need to
be calling _fstat64 rather than _fstat; I'll address that separately.)

Julien.


More information about the reviews mailing list