arunsahabytes opened a new pull request, #55843:
URL: https://github.com/apache/arrow/pull/55843

   ### Rationale for this change
   
   `split_pattern_regex` loops forever when the pattern matches the empty 
string (e.g. `""`, `"a*"`), see #55842.
   
   ### What changes are included in this PR?
   
   In the forward split loop, an empty separator directly after another empty 
separator is skipped and the search restarts one character later (one codepoint 
for UTF-8, one byte for binary). This matches Python's `re.split`, e.g. `""` on 
`"abc"` gives `["", "a", "b", "c", ""]`. Other split kernels never produce 
empty separators, so they are unaffected.
   
   ### Are these changes tested?
   
   Yes, new C++ tests (`SplitRegexEmptyMatch`, `SplitRegexEmptyMatchUtf8`) and 
a Python test. I also checked the new loop logic against `re.split` with a 
Python simulation over a few thousand pattern/string/max_splits cases. I could 
not build Arrow C++ locally (Windows), so CI is the first full build.
   
   ### Are there any user-facing changes?
   
   Yes: these calls now return instead of hanging.
   
   **This PR contains a "Critical Fix".** It fixes a bug that causes an 
infinite loop and unbounded memory growth.
   
   
   I used Claude while writing the fix and tests. I reviewed the change, 
reproduced the hang myself, and checked the results against Python's `re.split`.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to