rust-analyzer / rowan

Apache License 2.0
715 stars 60 forks source link

assertion `left == right` failed #172

Closed milianw closed 1 month ago

milianw commented 1 month ago

Hey all,

it seems like my recent optimization is unsound, consider reverting the patch that introduced the to_next_sibling_or_token optimization for now, until I figure out the problem to remedy it.

But I suddenly run into the following crash, which points at my code.

assertion `left == right` failed
  left: 1
 right: 0
stack backtrace:
   0: rust_begin_unwind
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/std/src/panicking.rs:662:5
   1: core::panicking::panic_fmt
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/panicking.rs:74:14
   2: core::panicking::assert_failed_inner
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/panicking.rs:412:17
   3: core::panicking::assert_failed
             at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/panicking.rs:367:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Program received signal SIGABRT, Aborted.
0x00007ffff64a53f4 in ?? () from /usr/lib/libc.so.6
(gdb) bt
#0  0x00007ffff64a53f4 in ?? () from /usr/lib/libc.so.6
#1  0x00007ffff644c120 in raise () from /usr/lib/libc.so.6
#2  0x00007ffff64334c3 in abort () from /usr/lib/libc.so.6
#3  0x000055555813356a in panic_abort::__rust_start_panic::abort () at panic_abort/src/lib.rs:48
#4  0x0000555558133559 in panic_abort::__rust_start_panic () at panic_abort/src/lib.rs:43
#5  0x000055555811f1ce in std::panicking::rust_panic () at std/src/panicking.rs:858
#6  0x000055555811f000 in std::panicking::rust_panic_with_hook () at std/src/panicking.rs:822
#7  0x000055555811ec77 in std::panicking::begin_panic_handler::{closure#0} () at std/src/panicking.rs:671
#8  0x000055555811da79 in std::sys::backtrace::__rust_end_short_backtrace<std::panicking::begin_panic_handler::{closure_env#0}, !> () at std/src/sys/backtrace.rs:170
#9  0x000055555811e904 in std::panicking::begin_panic_handler () at std/src/panicking.rs:662
#10 0x0000555558148893 in core::panicking::panic_fmt () at core/src/panicking.rs:74
#11 0x0000555558148cfe in core::panicking::assert_failed_inner () at core/src/panicking.rs:412
#12 0x0000555557fcbc3e in core::panicking::assert_failed<u32, u32> (kind=core::panicking::AssertKind::Eq, left=0x7ffffffef918, right=0x555556076810 <.Lanon.cbb18ae902c3613d9d96979b4a4255ab.793>, 
    args=<error reading variable: Cannot access memory at address 0x7>) at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/panicking.rs:367
#13 0x0000555557fc98e5 in rowan::cursor::free (data=...) at src/cursor.rs:192
#14 0x0000555557fd6718 in rowan::cursor::{impl#8}::to_next_sibling_or_token::{closure#1} () at src/cursor.rs:1237
#15 0x0000555557fd827c in core::option::Option<rowan::utility_types::NodeOrToken<rowan::cursor::SyntaxNode, rowan::cursor::SyntaxToken>>::or_else<rowan::utility_types::NodeOrToken<rowan::cursor::SyntaxNode, rowan::cursor::SyntaxToken>, rowan::cursor::{impl#8}::to_next_sibling_or_token::{closure_env#1}> (self=..., f=...) at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/option.rs:1545
#16 0x0000555557fd5a94 in rowan::utility_types::NodeOrToken<rowan::cursor::SyntaxNode, rowan::cursor::SyntaxToken>::to_next_sibling_or_token (self=...) at src/cursor.rs:1219
#17 0x0000555557fd6857 in rowan::cursor::{impl#24}::next::{closure#0} (next=...) at src/cursor.rs:1455
#18 0x0000555557fd8666 in core::option::Option<rowan::utility_types::NodeOrToken<rowan::cursor::SyntaxNode, rowan::cursor::SyntaxToken>>::and_then<rowan::utility_types::NodeOrToken<rowan::cursor::SyntaxNode, rowan::cursor::SyntaxToken>, rowan::utility_types::NodeOrToken<rowan::cursor::SyntaxNode, rowan::cursor::SyntaxToken>, rowan::cursor::{impl#24}::next::{closure_env#0}> (self=..., f=...) at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/option.rs:1445
#19 0x0000555557fcb41b in rowan::cursor::{impl#24}::next (self=0x7ffffffefd38) at src/cursor.rs:1455
#20 0x0000555557d8633e in rowan::api::{impl#11}::next<i_slint_compiler::parser::Language> (self=0x7ffffffefd38) at /mnt/data1/milian/kdab/rowan/src/api.rs:461
#21 0x00005555579fc925 in core::iter::adapters::map::{impl#2}::next<i_slint_compiler::parser::NodeOrToken, rowan::api::SyntaxElementChildren<i_slint_compiler::parser::Language>, i_slint_compiler::parser::{impl#8}::children_with_tokens::{closure_env#0}> (self=0x7ffffffefd38) at /rustc/f6e511eec7342f59a25f7c0534f1dbea00d01b14/library/core/src/iter/adapters/map.rs:107