Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Panic in substring() scalar function (SQLancer) #12129

Closed
2010YOUY01 opened this issue Aug 23, 2024 · 1 comment · Fixed by #12141
Closed

Panic in substring() scalar function (SQLancer) #12129

2010YOUY01 opened this issue Aug 23, 2024 · 1 comment · Fixed by #12141
Labels
bug Something isn't working

Comments

@2010YOUY01
Copy link
Contributor

Describe the bug

It's expected to return an error instead of crash for bad input

See reproducer in datafusion-cli
(Run under latest main, compiled using cargo run, commit 00b3f3b)

DataFusion CLI v41.0.0
> select substring('foo', 9223372036854775807 + 1, 1);
thread 'main' panicked at /Users/yongting/Desktop/code/my_datafusion/arrow-datafusion/datafusion/functions/src/unicode/substr.rs:154:47:
attempt to subtract with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

To Reproduce

No response

Expected behavior

No response

Additional context

Found by SQLancer #11030

@2010YOUY01 2010YOUY01 added the bug Something isn't working label Aug 23, 2024
@findepi
Copy link
Member

findepi commented Aug 23, 2024

There are two bugs actually.

  1. 9223372036854775807 + 1 overflows Unchecked overflow in integer number addition #12140 handling overflow for the integer types #3520
  2. select substring('foo', -9223372036854775808, 1); panics (this issue)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants