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 checking file #8355

Closed
qarmin opened this issue Oct 30, 2023 · 3 comments
Closed

Panic when checking file #8355

qarmin opened this issue Oct 30, 2023 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@qarmin
Copy link

qarmin commented Oct 30, 2023

Ruff 0.1.3 (latest changes from main branch)

ruff  *.py --select B008 --no-cache --fix --preview

file content:

class Color:
    BOLD      = '\038[1m'

error


error: Panicked while linting /home/rafal/test/tmp_folder/F_NAME_12939160140977752549.py: This indicates a bug in Ruff. If you could open an issue at:

    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 crates/ruff_python_parser/src/string.rs:129:55:
called `Result::unwrap()` on an `Err` value: ParseIntError { kind: InvalidDigit }
Backtrace:    0: ruff_cli::panic::catch_unwind::{{closure}}
             at /home/rafal/test/ruff/crates/ruff_cli/src/panic.rs:31:25
   1: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/alloc/src/boxed.rs:2021:9
   2: std::panicking::rust_panic_with_hook
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:711:13
   3: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:599:13
   4: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/sys_common/backtrace.rs:170:18
   5: rust_begin_unwind
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:595:5
   6: core::panicking::panic_fmt
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/panicking.rs:67:14
   7: core::result::unwrap_failed
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/result.rs:1652:5
   8: core::result::Result<T,E>::unwrap
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/result.rs:1077:23
   9: ruff_python_parser::string::StringParser::parse_octet
             at /home/rafal/test/ruff/crates/ruff_python_parser/src/string.rs:129:21
  10: ruff_python_parser::string::StringParser::parse_escaped_char
             at /home/rafal/test/ruff/crates/ruff_python_parser/src/string.rs:174:30
  11: ruff_python_parser::string::StringParser::parse_string
             at /home/rafal/test/ruff/crates/ruff_python_parser/src/string.rs:301:17
  12: ruff_python_parser::string::StringParser::parse
             at /home/rafal/test/ruff/crates/ruff_python_parser/src/string.rs:316:13
  13: ruff_python_parser::string::parse_string_literal
             at /home/rafal/test/ruff/crates/ruff_python_parser/src/string.rs:334:5
  14: ruff_python_parser::python::__action214
             at /home/rafal/test/ruff/crates/ruff_python_parser/src/python.rs:36217:12
  15: ruff_python_parser::python::__action934
             at /home/rafal/test/ruff/crates/ruff_python_parser/src/python.rs:52579:5
  16: ruff_python_parser::python::__parse__Top::__reduce
             at /home/rafal/test/ruff/crates/ruff_python_parser/src/python.rs:17867:34
  17: <ruff_python_parser::python::__parse__Top::__StateMachine as lalrpop_util::state_machine::ParserDefinition>::reduce
             at /home/rafal/test/ruff/crates/ruff_python_parser/src/python.rs:5955:13
  18: lalrpop_util::state_machine::Parser<D,I>::reduce
             at /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lalrpop-util-0.20.0/src/state_machine.rs:594:9
  19: lalrpop_util::state_machine::Parser<D,I>::parse
             at /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lalrpop-util-0.20.0/src/state_machine.rs:264:43
  20: lalrpop_util::state_machine::Parser<D,I>::drive
             at /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/lalrpop-util-0.20.0/src/state_machine.rs:218:9
  21: ruff_python_parser::python::__parse__Top::TopParser::parse
             at /home/rafal/test/ruff/crates/ruff_python_parser/src/python.rs:11857:13
  22: ruff_python_parser::parser::parse_filtered_tokens
             at /home/rafal/test/ruff/crates/ruff_python_parser/src/parser.rs:258:5
  23: ruff_python_parser::parser::parse_tokens
             at /home/rafal/test/ruff/crates/ruff_python_parser/src/parser.rs:223:5
  24: ruff_python_parser::parse_program_tokens
             at /home/rafal/test/ruff/crates/ruff_python_parser/src/lib.rs:158:11
  25: ruff_linter::linter::check_path
             at /home/rafal/test/ruff/crates/ruff_linter/src/linter.rs:145:15
  26: ruff_linter::linter::lint_fix
             at /home/rafal/test/ruff/crates/ruff_linter/src/linter.rs:494:22
  27: ruff_cli::diagnostics::lint_path
             at /home/rafal/test/ruff/crates/ruff_cli/src/diagnostics.rs:272:14
  28: ruff_cli::commands::check::lint_path::{{closure}}
             at /home/rafal/test/ruff/crates/ruff_cli/src/commands/check.rs:197:9
  29: std::panicking::try::do_call
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:502:40
  30: std::panicking::try
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panicking.rs:466:19
  31: std::panic::catch_unwind
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/panic.rs:142:14
  32: ruff_cli::panic::catch_unwind
             at /home/rafal/test/ruff/crates/ruff_cli/src/panic.rs:40:18
  33: ruff_cli::commands::check::lint_path
             at /home/rafal/test/ruff/crates/ruff_cli/src/commands/check.rs:196:18
  34: ruff_cli::commands::check::check::{{closure}}
             at /home/rafal/test/ruff/crates/ruff_cli/src/commands/check.rs:98:17
  35: <rayon::iter::filter_map::FilterMapFolder<C,P> as rayon::iter::plumbing::Folder<T>>::consume
             at /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.8.0/src/iter/filter_map.rs:123:36
  36: rayon::iter::plumbing::Folder::consume_iter
             at /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.8.0/src/iter/plumbing/mod.rs:179:20
  37: rayon::iter::plumbing::Producer::fold_with
             at /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.8.0/src/iter/plumbing/mod.rs:110:9
  38: rayon::iter::plumbing::bridge_producer_consumer::helper
             at /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.8.0/src/iter/plumbing/mod.rs:438:13
  39: rayon::iter::plumbing::bridge_producer_consumer
             at /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.8.0/src/iter/plumbing/mod.rs:397:12
  40: <rayon::iter::plumbing::bridge::Callback<C> as rayon::iter::plumbing::ProducerCallback<I>>::callback
             at /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.8.0/src/iter/plumbing/mod.rs:373:13
  41: <rayon::slice::Iter<T> as rayon::iter::IndexedParallelIterator>::with_producer
             at /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.8.0/src/slice/mod.rs:732:9
  42: rayon::iter::plumbing::bridge
             at /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.8.0/src/iter/plumbing/mod.rs:357:12
  43: <rayon::slice::Iter<T> as rayon::iter::ParallelIterator>::drive_unindexed
             at /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.8.0/src/slice/mod.rs:708:9
  44: <rayon::iter::filter_map::FilterMap<I,P> as rayon::iter::ParallelIterator>::drive_unindexed
             at /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.8.0/src/iter/filter_map.rs:46:9
  45: <rayon::iter::fold::Fold<I,ID,F> as rayon::iter::ParallelIterator>::drive_unindexed
             at /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.8.0/src/iter/fold.rs:59:9
  46: rayon::iter::reduce::reduce
             at /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.8.0/src/iter/reduce.rs:15:5
  47: rayon::iter::ParallelIterator::reduce
             at /home/rafal/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rayon-1.8.0/src/iter/mod.rs:991:9
  48: ruff_cli::commands::check::check
             at /home/rafal/test/ruff/crates/ruff_cli/src/commands/check.rs:169:10
  49: ruff_cli::check
             at /home/rafal/test/ruff/crates/ruff_cli/src/lib.rs:397:13
  50: ruff_cli::run
             at /home/rafal/test/ruff/crates/ruff_cli/src/lib.rs:188:33
  51: ruff::main
             at /home/rafal/test/ruff/crates/ruff_cli/src/bin/ruff.rs:49:11
  52: core::ops::function::FnOnce::call_once
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/core/src/ops/function.rs:250:5
  53: std::sys_common::backtrace::__rust_begin_short_backtrace
             at /rustc/cc66ad468955717ab92600c770da8c1601a4ff33/library/std/src/sys_common/backtrace.rs:154:18
  54: main
  55: __libc_start_call_main
             at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  56: __libc_start_main_impl
             at ./csu/../csu/libc-start.c:360:3
  57: _start


python_compressed.zip

Looks that this is ~1 day old regression

konstin added a commit that referenced this issue Oct 30, 2023
**Summary** The digits for an octal escape are 0 to 7, not 0 to 8, fixing the panic in #8355

**Test plan** Regression test parser fixture
@konstin konstin self-assigned this Oct 30, 2023
@konstin konstin added the bug Something isn't working label Oct 30, 2023
konstin added a commit that referenced this issue Oct 30, 2023
**Summary** The digits for an octal escape are 0 to 7, not 0 to 8,
fixing the panic in #8355

**Test plan** Regression test parser fixture
@qarmin qarmin closed this as completed Oct 30, 2023
@qarmin qarmin reopened this Oct 30, 2023
@qarmin
Copy link
Author

qarmin commented Oct 30, 2023

Not sure, but looks that still crashes

@dhruvmanila
Copy link
Member

Can you provide the commit hash you're testing against? I can't reproduce it using 982ae6f

@qarmin
Copy link
Author

qarmin commented Oct 31, 2023

My script to update ruff was probably broken, because now I cannot reproduce problem

@qarmin qarmin closed this as completed Oct 31, 2023
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

No branches or pull requests

3 participants