Hey Nathan, Nazir,

I've also reproduced the error and confirmed the patch addresses it
cleanly.

For anyone following along, the mechanism: commit e0a3a3fd53 added
CopyReadLineTextSIMDHelper, which refills the input buffer once fewer
than sizeof(Vector8) bytes remain:

  if (copy_buf_len - input_buf_ptr < sizeof(Vector8))   /* reads ahead */

whereas scalar CopyReadLineText only refills when actually empty:

  if (input_buf_ptr >= copy_buf_len || need_data)

That difference is the issue. CopyConvertBuf() deliberately tolerates an
invalid byte sequence after the \. end-of-copy marker (see the comment
near its convertedlen == 0 block), deferring the error.  But
CopyLoadInputBuf() raises it the moment input_reached_error is set. The
SIMD read-ahead reaches that raise before the scalar loop has consumed
\., so a file ending in \.\n<valid bytes><invalid byte> errors out where
the scalar path would have stopped cleanly at \.

+1 on adding the reproducer as a test and calling it good.

best,

-greg


Reply via email to