rust-lang / rust-lang/rustfmt

crash: #[path="/dev/null"] attr

Open
#4,587 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

A-modules C-bug P-low
Dominant language
Rust
Stars
7k
Forks
1.1k
Avg merge
2d 13h
Merged PRs (30d)
24

Description

This code causes rustfmt to crash

#[path="/dev/null"]
pub mod null;
thread 'main' panicked at 'path is expected to be under the root', /cargo/registry/src/github.com-1ecc6299db9ec823/ignore-0.4.16/src/gitignore.rs:227:9
stack backtrace:
   0:     0x5587c3e2eaa7 - std::backtrace_rs::backtrace::libunwind::trace::h746c3e9529d524bc
                               at /rustc/2225ee1b62ff089917434aefd9b2bf509cfa087f/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x5587c3e2eaa7 - std::backtrace_rs::backtrace::trace_unsynchronized::h86340908ff889faa
                               at /rustc/2225ee1b62ff089917434aefd9b2bf509cfa087f/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x5587c3e2eaa7 - std::sys_common::backtrace::_print_fmt::h43f85f9b18230404
                               at /rustc/2225ee1b62ff089917434aefd9b2bf509cfa087f/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x5587c3e2eaa7 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hc132ae1a5b5aa7cd
                               at /rustc/2225ee1b62ff089917434aefd9b2bf509cfa087f/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x5587c3e5283c - core::fmt::write::hdf023a0036d2a25f
                               at /rustc/2225ee1b62ff089917434aefd9b2bf509cfa087f/library/core/src/fmt/mod.rs:1078:17
   5:     0x5587c3e2b462 - std::io::Write::write_fmt::h8580846154bcb66a
                               at /rustc/2225ee1b62ff089917434aefd9b2bf509cfa087f/library/std/src/io/mod.rs:1519:15
   6:     0x5587c3e30a75 - std::sys_common::backtrace::_print::h7ee55fed88d107a3
                               at /rustc/2225ee1b62ff089917434aefd9b2bf509cfa087f/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x5587c3e30a75 - std::sys_common::backtrace::print::h54a7d3e52a524177
                               at /rustc/2225ee1b62ff089917434aefd9b2bf509cfa087f/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x5587c3e30a75 - std::panicking::default_hook::{{closure}}::h60921e857bf55a40
                               at /rustc/2225ee1b62ff089917434aefd9b2bf509cfa087f/library/std/src/panicking.rs:208:50
   9:     0x5587c3e305ca - std::panicking::default_hook::hf0f9afb1017317fc
                               at /rustc/2225ee1b62ff089917434aefd9b2bf509cfa087f/library/std/src/panicking.rs:225:9
  10:     0x5587c3e31211 - std::panicking::rust_panic_with_hook::h8d66bf42b407aaea
                               at /rustc/2225ee1b62ff089917434aefd9b2bf509cfa087f/library/std/src/panicking.rs:591:17
  11:     0x5587c3ae67c4 - std::panicking::begin_panic::{{closure}}::hbe262b95ef2ff8f9
  12:     0x5587c3ae66bc - std::sys_common::backtrace::__rust_end_short_backtrace::hd70d74b6b6dc38ff
  13:     0x5587c3a2ddac - std::panicking::begin_panic::h998094cd3d11af60
  14:     0x5587c3a5e258 - ignore::gitignore::Gitignore::matched_path_or_any_parents::h687892c59c3a1cae
  15:     0x5587c3b66149 - rustfmt_nightly::syntux::session::ParseSess::ignore_file::h60741d92df2c771d
  16:     0x5587c39bfae0 - rustfmt_nightly::formatting::format_project::h75f3cb078ea2edba
  17:     0x5587c39c93ee - scoped_tls::ScopedKey<T>::set::h46570b94864b4223
  18:     0x5587c39c3789 - rustfmt_nightly::Session<T>::format::h16e5c985cca65c6b
  19:     0x5587c39d38fb - rustfmt::format_and_emit_report::h34b4f1b50145fd6f
  20:     0x5587c39c309d - rustfmt_nightly::Session<T>::override_config::h588d4c0abb82dcad
  21:     0x5587c39d0f8d - rustfmt::execute::hbead43f61fce9ab6
  22:     0x5587c39cd9fd - rustfmt::main::hdc579be80dab480f
  23:     0x5587c39c58b3 - std::sys_common::backtrace::__rust_begin_short_backtrace::h425146d795f70aec
  24:     0x5587c39c5c09 - std::rt::lang_start::{{closure}}::h1a880688683e8956
  25:     0x5587c3e31727 - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h54c39b9b8451875a
                               at /rustc/2225ee1b62ff089917434aefd9b2bf509cfa087f/library/core/src/ops/function.rs:259:13
  26:     0x5587c3e31727 - std::panicking::try::do_call::hcdfba51a06e21b42
                               at /rustc/2225ee1b62ff089917434aefd9b2bf509cfa087f/library/std/src/panicking.rs:379:40
  27:     0x5587c3e31727 - std::panicking::try::hb36953ccd24f930d
                               at /rustc/2225ee1b62ff089917434aefd9b2bf509cfa087f/library/std/src/panicking.rs:343:19
  28:     0x5587c3e31727 - std::panic::catch_unwind::hbb374cd03beb3824
                               at /rustc/2225ee1b62ff089917434aefd9b2bf509cfa087f/library/std/src/panic.rs:396:14
  29:     0x5587c3e31727 - std::rt::lang_start_internal::h97dca9624db2aa85
                               at /rustc/2225ee1b62ff089917434aefd9b2bf509cfa087f/library/std/src/rt.rs:51:25
  30:     0x5587c39d4552 - main
  31:     0x7f0254b48152 - __libc_start_main
  32:     0x5587c39b9f59 - <unknown>

rustfmt 1.4.29-nightly (70ce182 2020-12-04)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the crash with the #[path="/dev/null"] module shown in the issue, then trace rustfmt_nightly::syntux::session::ParseSess::ignore_file and rustfmt_nightly::formatting::format_project from the stack trace. Done means rustfmt handles this input without panicking.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.