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

Panicked at 'byte index 18446744073709551615 is out of bounds of ik0loc, ik1, ik2 = ', crates/ruff_python_parser/src/string.rs:321:30 #7049

Closed
qarmin opened this issue Sep 1, 2023 · 4 comments

Comments

@qarmin
Copy link

qarmin commented Sep 1, 2023

Ruff 0.0.287 (latest changes from main branch)

ruff  *.py --select ALL,NURSERY --no-cache

file content:

                                # print(f"{ik0loc, ik1, ik2 = }; {ik1c, ik2c = }")

error:

https://github.com/astral-sh/ruff/issues/new?title=%5BLinter%20panic%5D

with the relevant file contents, the `pyproject.toml` settings, and the following stack trace, we'd be very appreciative!

panicked at 'byte index 18446744073709551615 is out of bounds of `ik0loc, ik1, ik2 = `', crates/ruff_python_parser/src/string.rs:321:30
Backtrace:    0: ruff_cli::panic::catch_unwind::{{closure}}
   1: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/alloc/src/boxed.rs:2007:9
   2: std::panicking::rust_panic_with_hook
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:709:13
   3: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:597:13
   4: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/sys_common/backtrace.rs:151:18
   5: rust_begin_unwind
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/std/src/panicking.rs:593:5
   6: core::panicking::panic_fmt
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/panicking.rs:67:14
   7: core::str::slice_error_fail_rt
   8: core::str::slice_error_fail
             at /rustc/5680fa18feaa87f3ff04063800aec256c3d4b4be/library/core/src/str/mod.rs:87:9
   9: <alloc::string::String as core::ops::index::Index<core::ops::range::RangeTo<usize>>>::index
  10: ruff_python_parser::string::StringParser::parse_fstring
  11: ruff_python_parser::string::parse_strings
  12: ruff_python_parser::python::__action708
  13: ruff_python_parser::python::__parse__Top::__reduce
  14: ruff_python_parser::parser::parse_tokens
  15: ruff_python_parser::parser::parse_suite
  16: ruff::checkers::tokens::check_tokens
  17: ruff::linter::check_path
  18: ruff::linter::lint_fix
  19: ruff_cli::diagnostics::lint_path
  20: rayon::iter::plumbing::bridge_producer_consumer::helper
  21: ruff_cli::commands::check::check
  22: ruff_cli::check
  23: ruff_cli::run
  24: ruff::main
  25: std::sys_common::backtrace::__rust_begin_short_backtrace
  26: main
  27: __libc_start_call_main
             at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  28: __libc_start_main_impl
             at ./csu/../csu/libc-start.c:360:3
  29: _start

39205396.py.zip

@MichaReiser
Copy link
Member

Lol, that's a good one. CC: @dhruvmanila

@dhruvmanila
Copy link
Member

This is same as #6831 and is fixed with the new f-string parser. Closing this in favor of that issue.

@dhruvmanila dhruvmanila closed this as not planned Won't fix, can't repro, duplicate, stale Sep 2, 2023
@qarmin
Copy link
Author

qarmin commented Sep 2, 2023

Quite strange that this crashes also when code is commented.

@dhruvmanila
Copy link
Member

That's a good point. It's because of https://beta.ruff.rs/docs/rules/commented-out-code/ (ERA001) which has a heuristic to parse the commented out code minus the # character:

// Finally, compile the source code.
parse_suite(&line, "<filename>").is_ok()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants