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

cargo insta test crash (because of insta::assert_snapshot in a loop, perhaps?) #307

Closed
ilyagr opened this issue Nov 29, 2022 · 0 comments
Closed
Labels
bug Something isn't working

Comments

@ilyagr
Copy link

ilyagr commented Nov 29, 2022

What happened?

I was working with this repository state of the jj source code:
insta-bug.tar.gz

Update: I was editing tests/test_resolve_command.rs, so removing that file probably avoids the bug. I think it might have to do with having and insta test in a loop.

I'm sure there's some mistake there (still looking), but whatever it is, it shouldn't crash cargo insta.

Reproduction steps

$ cargo insta test
<Long compilation followed by a crash>
$ RUST_BACKTRACE=full cargo insta test
thread 'main' panicked at 'assertion failed: self.inline_snapshots.last().map_or(true, |x| x.end.0 <= line)', /home/ilyagr/.local/app/cargo/registry/src/github.com-1ecc6299db9ec823/cargo-insta-1.21.2/src/inline.rs:60:17
stack backtrace:
   0:     0x58331cd3add0 - std::backtrace_rs::backtrace::libunwind::trace::h535f593972886c4a
                               at /rustc/0040709e39bfa159d099ee14628ad4ac72f91406/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x58331cd3add0 - std::backtrace_rs::backtrace::trace_unsynchronized::hc07aee30adb12ed2
                               at /rustc/0040709e39bfa159d099ee14628ad4ac72f91406/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x58331cd3add0 - std::sys_common::backtrace::_print_fmt::h288d851a10fade54
                               at /rustc/0040709e39bfa159d099ee14628ad4ac72f91406/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x58331cd3add0 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::hf48670985ba46da7
                               at /rustc/0040709e39bfa159d099ee14628ad4ac72f91406/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x58331cd5f8be - core::fmt::write::h9a8f262a9d4fab37
                               at /rustc/0040709e39bfa159d099ee14628ad4ac72f91406/library/core/src/fmt/mod.rs:1209:17
   5:     0x58331cd37235 - std::io::Write::write_fmt::hff25107ec5a91f94
                               at /rustc/0040709e39bfa159d099ee14628ad4ac72f91406/library/std/src/io/mod.rs:1682:15
   6:     0x58331cd3ab95 - std::sys_common::backtrace::_print::hf4ea927ec69d76db
                               at /rustc/0040709e39bfa159d099ee14628ad4ac72f91406/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x58331cd3ab95 - std::sys_common::backtrace::print::h8d4f38058704f2ac
                               at /rustc/0040709e39bfa159d099ee14628ad4ac72f91406/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x58331cd3c43f - std::panicking::default_hook::{{closure}}::h60f3cc971dce4049
                               at /rustc/0040709e39bfa159d099ee14628ad4ac72f91406/library/std/src/panicking.rs:267:22
   9:     0x58331cd3c17a - std::panicking::default_hook::h49ab13cb92c8305a
                               at /rustc/0040709e39bfa159d099ee14628ad4ac72f91406/library/std/src/panicking.rs:286:9
  10:     0x58331cd3cb38 - std::panicking::rust_panic_with_hook::h5998c1f99bd48660
                               at /rustc/0040709e39bfa159d099ee14628ad4ac72f91406/library/std/src/panicking.rs:688:13
  11:     0x58331cd3c891 - std::panicking::begin_panic_handler::{{closure}}::hffd9ba00cc715478
                               at /rustc/0040709e39bfa159d099ee14628ad4ac72f91406/library/std/src/panicking.rs:577:13
  12:     0x58331cd3b27c - std::sys_common::backtrace::__rust_end_short_backtrace::h2c8c22e930bfc624
                               at /rustc/0040709e39bfa159d099ee14628ad4ac72f91406/library/std/src/sys_common/backtrace.rs:137:18
  13:     0x58331cd3c5f2 - rust_begin_unwind
                               at /rustc/0040709e39bfa159d099ee14628ad4ac72f91406/library/std/src/panicking.rs:575:5
  14:     0x58331ca2e133 - core::panicking::panic_fmt::h3ec290a32dbfc4e3
                               at /rustc/0040709e39bfa159d099ee14628ad4ac72f91406/library/core/src/panicking.rs:65:14
  15:     0x58331ca2e20d - core::panicking::panic::h7a6c7788e9d68fe5
                               at /rustc/0040709e39bfa159d099ee14628ad4ac72f91406/library/core/src/panicking.rs:115:5
  16:     0x58331ca89722 - cargo_insta::cargo::SnapshotContainer::load::h0651ab98f85f5441
  17:     0x58331ca85a4a - core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut::h66686ad15e3513f9
  18:     0x58331ca62449 - <core::iter::adapters::filter_map::FilterMap<I,F> as core::iter::traits::iterator::Iterator>::try_fold::h432aa17edbde61fe
  19:     0x58331ca6ad0b - cargo_insta::cli::load_snapshot_containers::h3f964b4cdb328126
  20:     0x58331ca6b6c4 - cargo_insta::cli::process_snapshots::h7edda77524653732
  21:     0x58331ca70dcb - cargo_insta::cli::run::hf09e1558096e1cbb
  22:     0x58331ca3dc5d - cargo_insta::main::h47a7bdf67085300d
  23:     0x58331ca81ff3 - std::sys_common::backtrace::__rust_begin_short_backtrace::hef880a4eb503cb34
  24:     0x58331ca310c9 - std::rt::lang_start::{{closure}}::h4011a0e636d6a898
  25:     0x58331cd31e0b - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::h8152bf5fe9c1962d
                               at /rustc/0040709e39bfa159d099ee14628ad4ac72f91406/library/core/src/ops/function.rs:286:13
  26:     0x58331cd31e0b - std::panicking::try::do_call::h0a77d2b19b9bf1c8
                               at /rustc/0040709e39bfa159d099ee14628ad4ac72f91406/library/std/src/panicking.rs:483:40
  27:     0x58331cd31e0b - std::panicking::try::h738e72d42098d11c
                               at /rustc/0040709e39bfa159d099ee14628ad4ac72f91406/library/std/src/panicking.rs:447:19
  28:     0x58331cd31e0b - std::panic::catch_unwind::h32003f0bfae4e470
                               at /rustc/0040709e39bfa159d099ee14628ad4ac72f91406/library/std/src/panic.rs:137:14
  29:     0x58331cd31e0b - std::rt::lang_start_internal::{{closure}}::h7e878a1171bacdd9
                               at /rustc/0040709e39bfa159d099ee14628ad4ac72f91406/library/std/src/rt.rs:148:48
  30:     0x58331cd31e0b - std::panicking::try::do_call::hb73576872774b424
                               at /rustc/0040709e39bfa159d099ee14628ad4ac72f91406/library/std/src/panicking.rs:483:40
  31:     0x58331cd31e0b - std::panicking::try::h0f64828074f19d68
                               at /rustc/0040709e39bfa159d099ee14628ad4ac72f91406/library/std/src/panicking.rs:447:19
  32:     0x58331cd31e0b - std::panic::catch_unwind::he5193a67e5cb3336
                               at /rustc/0040709e39bfa159d099ee14628ad4ac72f91406/library/std/src/panic.rs:137:14
  33:     0x58331cd31e0b - std::rt::lang_start_internal::h5e87e3c0ffa71a7a
                               at /rustc/0040709e39bfa159d099ee14628ad4ac72f91406/library/std/src/rt.rs:148:20
  34:     0x58331ca3dde5 - main
  35:     0x7948fd5e3d0a - __libc_start_main
  36:     0x58331ca2e58a - _start
  37:                0x0 - <unknown>

Insta Version

1.21.2

rustc Version

rustc 1.66.0-beta.2 (0040709e3 2022-11-20)

What did you expect?

No crash

@ilyagr ilyagr added the bug Something isn't working label Nov 29, 2022
@ilyagr ilyagr changed the title I managed to crash cargo insta test cargo insta test crash (because of insta::assert_snapshot in a loop, perhaps?) Nov 29, 2022
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

1 participant