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

Crash when passing empty string in stdin #78

Open
ipvych opened this issue Jun 2, 2023 · 0 comments
Open

Crash when passing empty string in stdin #78

ipvych opened this issue Jun 2, 2023 · 0 comments

Comments

@ipvych
Copy link

ipvych commented Jun 2, 2023

Steps to reproduce:

echo "" | RUST_BACKTRACE=full statix check -s

Results in

[E00] Error: Syntax error
thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', /build/statix-0.5.6-vendor.tar.gz/ariadne/src/source.rs:109:25
stack backtrace:
   0:     0x55be76e9309c - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf2ea00d5f3b53d9f
   1:     0x55be76ec4c1e - core::fmt::write::ha076a7e65c6b1874
   2:     0x55be76ea51e1 - std::io::Write::write_fmt::h9630bb3b0fe886f5
   3:     0x55be76ead0b5 - std::panicking::default_hook::{{closure}}::h64163197f96398c1
   4:     0x55be76eacd12 - std::panicking::default_hook::h92625161492e6b48
   5:     0x55be76ead5d1 - std::panicking::rust_panic_with_hook::hfdd7d6bb6788c6c2
   6:     0x55be76e933d7 - std::panicking::begin_panic_handler::{{closure}}::he81a60a7ef84ad4a
   7:     0x55be76e931b4 - std::sys_common::backtrace::__rust_end_short_backtrace::h62801bf9780239e6
   8:     0x55be76ead282 - rust_begin_unwind
   9:     0x55be76d07cc3 - core::panicking::panic_fmt::hfd221b9f37504b4a
  10:     0x55be76d07c02 - core::panicking::panic_bounds_check::hd62ce49e2c7e15d6
  11:     0x55be76d6ba3c - ariadne::source::Source::get_offset_line::hff6557d6c6989d76
  12:     0x55be76d0fa9d - ariadne::write::<impl ariadne::Report<S>>::write::h6d21c3b3fc711aae
  13:     0x55be76d1c0bd - statix::traits::write_stderr::hf326e6e9162805f2
  14:     0x55be76d366e0 - statix::lint::main::main::h02d93095411c466b
  15:     0x55be76d0b3b1 - statix::main::h75b6529e2c6a3a28
  16:     0x55be76d09243 - std::sys_common::backtrace::__rust_begin_short_backtrace::hd0a11a681f67d665
  17:     0x55be76d09d29 - std::rt::lang_start::{{closure}}::h4151b7edf354832b
  18:     0x55be76e9e6b5 - std::rt::lang_start_internal::h09bcc9fffd987f14
  19:     0x55be76d0b5c2 - main
  20:     0x7f184c42924e - __libc_start_call_main
  21:     0x7f184c429309 - __libc_start_main_alias_1
  22:     0x55be76d07f05 - _start
  23:                0x0 - <unknown>

Expected result:
Should return

[E00] Error: Syntax error
   ╭─[<stdin>:1:1]
   │
 1 │
   · │
   · ╰─ Unexpected end of file
───╯

as passing empty file would.

Additional context:
Providing empty empty file as input (not stdin) works, stdin with a single space character works as well.

Output of statix --version:

statix 0.5.6
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

1 participant