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 when deal with @ operator #3137

Closed
syheliel opened this issue Aug 14, 2022 · 2 comments · Fixed by #3162
Closed

panic when deal with @ operator #3137

syheliel opened this issue Aug 14, 2022 · 2 comments · Fixed by #3162
Assignees
Labels
bug Something isn't working

Comments

@syheliel
Copy link

Describe the bug

thread 'main' panicked at 'byte index 2 is out of bounds of `@`', library/core/src/str/mod.rs:107:9

To Reproduce
main.rs

use async_std;
use datafusion;
use datafusion::prelude::*;
fn main() {

    let data = "SElECT @=   X#=?!~ 5";
    let a = async {
        let ctx = SessionContext::new();
        let df = ctx.sql(data).await;
    };
    async_std::task::block_on(a);
}

Cargo.toml

[package]
name = "crash-example"
version = "0.1.0"
edition = "2021"

# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html

[dependencies]
datafusion = "10"
async-std = "1"

Expected behavior
return an Error instead of panic.

@syheliel syheliel added the bug Something isn't working label Aug 14, 2022
@syheliel
Copy link
Author

In src/execution/context.rs:1444-1448, the program doesn't check the length of variable_names[0](in my cause the value is "@") and lead to fetching invalid address for variable_names[0][0..2].

        let provider_type = if &variable_names[0][0..2] == "@@" {
            VarType::System
        } else {
            VarType::UserDefined
        };

@alamb alamb changed the title panic when deal with @ panic when deal with @ operator Aug 15, 2022
@alamb alamb self-assigned this Aug 15, 2022
@alamb
Copy link
Contributor

alamb commented Aug 15, 2022

Thanks @syheliel -- I'll take a look at this

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