You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@arrow.apache.org by "dmitry-chirkov-dremio (via GitHub)" <gi...@apache.org> on 2026/03/09 02:29:59 UTC
[I] Functions substring_index and truncate crash with extreme integer values [arrow]
dmitry-chirkov-dremio opened a new issue, #49470:
URL: https://github.com/apache/arrow/issues/49470
### Describe the bug, including details regarding any error messages, version, and platform.
Two Gandiva functions crash when called with extreme integer values:
1. **`substring_index(VARCHAR, VARCHAR, INT)` crashes with `INT_MIN` count parameter**
- Calling `substring_index("a.b.c", ".", INT_MIN)` causes SIGBUS crash
- Root cause: Uses `abs(cnt)` which triggers undefined behavior when `cnt == INT_MIN` (abs(INT_MIN) overflows in 32-bit signed integers)
2. **`truncate(BIGINT, INT)` crashes with extreme scale values**
- Calling `truncate(12345, INT_MAX)` or `truncate(12345, INT_MIN)` causes SIGSEGV
- Root cause: Passes extreme scale values directly to `GetScaleMultiplier`, which only has array entries for scales 0-38, causing out-of-bounds array access
### Expected behavior
Both functions should handle extreme integer values gracefully without crashing:
- `substring_index` should safely compute absolute value of count parameter
- `truncate` should validate scale parameter before array access
### Actual behavior
- `substring_index`: SIGBUS crash due to integer overflow in `abs(INT_MIN)`
- `truncate`: SIGSEGV crash due to out-of-bounds array access
### How to reproduce
```cpp
// substring_index crash
gdv_fn_substring_index(ctx, "a.b.c", 5, ".", 1, INT_MIN, &out_len);
// truncate crash
truncate_int64_int32(12345, INT_MAX);
truncate_int64_int32(12345, INT_MIN);
### Component(s)
C++, Gandiva
--
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: issues-unsubscribe@arrow.apache.org.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [C++][Gandiva] Functions substring_index and truncate crash with extreme integer values [arrow]
Posted by "zanmato1984 (via GitHub)" <gi...@apache.org>.
zanmato1984 commented on issue #49470:
URL: https://github.com/apache/arrow/issues/49470#issuecomment-4063976841
Issue resolved by pull request 49471
https://github.com/apache/arrow/pull/49471
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [C++][Gandiva] Functions substring_index and truncate crash with extreme integer values [arrow]
Posted by "zanmato1984 (via GitHub)" <gi...@apache.org>.
zanmato1984 closed issue #49470: [C++][Gandiva] Functions substring_index and truncate crash with extreme integer values
URL: https://github.com/apache/arrow/issues/49470
--
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: issues-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [C++][Gandiva] Functions substring_index and truncate crash with extreme integer values [arrow]
Posted by "dmitry-chirkov-dremio (via GitHub)" <gi...@apache.org>.
dmitry-chirkov-dremio commented on issue #49470:
URL: https://github.com/apache/arrow/issues/49470#issuecomment-4020723372
mine
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [I] [C++][Gandiva] Functions substring_index and truncate crash with extreme integer values [arrow]
Posted by "dmitry-chirkov-dremio (via GitHub)" <gi...@apache.org>.
dmitry-chirkov-dremio commented on issue #49470:
URL: https://github.com/apache/arrow/issues/49470#issuecomment-4020698223
mine
--
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: github-unsubscribe@arrow.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org