Open benharsh opened 10 months ago
I'm throwing a "user issue" label on here since it was motivated by a case that PSath ran afoul of.
That sounds good to me. For anyone else following along, my initial investigation into this issue spawned more questions, and made me realize that this was more complex than I had initially expected. I'll be working on a proposal to address the problem in this issue, and some related problems.
https://github.com/chapel-lang/chapel/pull/23958 fixes a couple of bugs, but does not address some of the core usability issues (i.e. checking return value of fileReader.read
), so at the moment it is still somewhat easy to silently fail to notice that an array wasn't fully read.
The following program fails to throw an error when reading an array that is too large for the designated file region:
Throwing an error here is not only appropriate, but can help users to diagnose surprising off-by-one issues where the program silently fails to read the last element.
This issue also manifests for the version of
readBinary
that takes ac_ptr
, and forfileReader.read
when using abinaryDeserializer
.This issue is less clear for the
c_ptr
case, which also accepts a max number of bytes to read, and so it's not immediately obvious the caller wanted to read a specific number of bytes.A possible related question is "should reading past a file region manifest as an EOF, or some other kind of error?".
Related futures: