Repository navigation
Conversation
…hitespace Signed-off-by: Iason Krommydas <iason.krom@gmail.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Rationale for this change
Closes #37757
Until recently I used to maintain https://github.com/scikit-hep/awkward and and now I maintain a fork of it https://github.com/CoffeaTeam/awkward-lite and the original issue report game from
awkward. The issue is still present to this day in CI where we get sporadic failures that are fixed by a rerun.When a run of whitespace reaches the end of a string,
utf8_split_whitespacedecodes the next code point before checkingi < end, so it reads past the string (and before its start in reverse). The result then depends on that byte: a valid byte adds an extra"", an invalid one leaves a stray" ". For the last value of an array the byte is uninitialized memory, which is why the results in #37757 are sporadic.ascii_split_whitespacehas the same out-of-bounds read, although its output does not depend on the byte read.What changes are included in this PR?
SplitWhitespaceUtf8Finder::Find/FindReverse: check the bounds before decoding, so a separator extends to the string boundary without reading outside the string.SplitWhitespaceAsciiFinder::Find/FindReverse: check the bounds before dereferencing.Are these changes tested?
Yes. New tests cover whitespace runs at the start and end of strings, and values surrounded by invalid UTF-8 bytes or by the ends of an exactly sized buffer (the latter fails under ASAN without the fix).
Are there any user-facing changes?
Yes. For strings that start or end with two or more whitespace characters,
utf8_split_whitespacenow returns the same result asascii_split_whitespace, e.g." abc "gives["", "abc", ""]instead of["", "abc", "", ""]or["", "abc", " "].Was AI used for this PR?
An AI model was used to find the cause of the bug. Then the model was used to find the appropriate locations to add the tests cause I've never worked with the arrow project source code. The PR description and all communication is done by a human.
PR code and description written by:
Reviewed before submission by:
split_whitespacesporadically produces different results on MacOS #37757