Skip to content

ark: Rust panic while reading the document state #681

@DavisVaughan

Description

@DavisVaughan

I hit a panic while working in an R file (a named one, like already saved to disk). It occurred during one of the following, I couldn't tell which:

  • I saved
  • I clicked in the document to highlight some text

This is what was in the document, and it happened when I tried highlighting the lm() call

globalCallingHandlers(error = handle_error)
# globalCallingHandlers(NULL)

stop("oh no")
rlang::abort("oh no")

fn <- function() {
    stop("oh no")
}

fn()

lm("x")

Relevant snippet of the traceback:

   3: core::result::Result<T,E>::unwrap
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/result.rs:1113:23
   4: ropey::rope::Rope::byte_to_char
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/ropey-1.6.0/src/rope.rs:635:9
   5: ark::lsp::documents::Document::update
             at ./crates/ark/src/lsp/documents.rs:191:19
   6: ark::lsp::documents::Document::on_did_change
             at ./crates/ark/src/lsp/documents.rs:140:37
   7: <ark::lsp::backend::Backend as tower_lsp::LanguageServer>::did_change::{{closure}}
             at ./crates/ark/src/lsp/backend.rs:290:29
thread 'ark-lsp' panicked at 'called `Result::unwrap()` on an `Err` value: Byte index out of bounds: byte index 163, Rope/RopeSlice byte length 162', /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/ropey-1.6.0/src/rope.rs:635:41
stack backtrace:
   0: rust_begin_unwind
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/std/src/panicking.rs:575:5
   1: core::panicking::panic_fmt
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/panicking.rs:65:14
   2: core::result::unwrap_failed
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/result.rs:1791:5
   3: core::result::Result<T,E>::unwrap
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/result.rs:1113:23
   4: ropey::rope::Rope::byte_to_char
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/ropey-1.6.0/src/rope.rs:635:9
   5: ark::lsp::documents::Document::update
             at ./crates/ark/src/lsp/documents.rs:191:19
   6: ark::lsp::documents::Document::on_did_change
             at ./crates/ark/src/lsp/documents.rs:140:37
   7: <ark::lsp::backend::Backend as tower_lsp::LanguageServer>::did_change::{{closure}}
             at ./crates/ark/src/lsp/backend.rs:290:29
   8: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/future/mod.rs:91:19
   9: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/future/future.rs:124:9
  10: tower_lsp::generated::register_lsp_methods::did_change::{{closure}}
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/tower-lsp-0.19.0/src/lib.rs:112:1
  11: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/future/mod.rs:91:19
  12: tower_lsp::jsonrpc::router::Router<S,E>::method::{{closure}}::{{closure}}::{{closure}}
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/tower-lsp-0.19.0/src/jsonrpc/router.rs:58:63
  13: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/future/mod.rs:91:19
  14: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/future/future.rs:124:9
  15: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/futures-util-0.3.28/src/future/future/map.rs:55:37
  16: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/futures-util-0.3.28/src/lib.rs:91:13
  17: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/future/future.rs:124:9
  18: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/future/future.rs:124:9
  19: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/future/future.rs:124:9
  20: <tower_lsp::service::LspService<S> as tower_service::Service<tower_lsp::jsonrpc::Request>>::call::{{closure}}
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/tower-lsp-0.19.0/src/service.rs:124:31
  21: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/future/mod.rs:91:19
  22: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/future/future.rs:124:9
  23: <F as futures_core::future::TryFuture>::try_poll
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/futures-core-0.3.28/src/future.rs:82:9
  24: <futures_util::future::try_future::into_future::IntoFuture<Fut> as core::future::future::Future>::poll
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/futures-util-0.3.28/src/future/try_future/into_future.rs:34:9
  25: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/futures-util-0.3.28/src/future/future/map.rs:55:37
  26: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/futures-util-0.3.28/src/lib.rs:91:13
  27: <futures_util::future::try_future::UnwrapOrElse<Fut,F> as core::future::future::Future>::poll
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/futures-util-0.3.28/src/lib.rs:91:13
  28: <futures_util::stream::futures_unordered::FuturesUnordered<Fut> as futures_core::stream::Stream>::poll_next
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/futures-util-0.3.28/src/stream/futures_unordered/mod.rs:518:17
  29: futures_util::stream::stream::StreamExt::poll_next_unpin
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/futures-util-0.3.28/src/stream/stream/mod.rs:1632:9
  30: <futures_util::stream::stream::buffer_unordered::BufferUnordered<St> as futures_core::stream::Stream>::poll_next
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/futures-util-0.3.28/src/stream/stream/buffer_unordered.rs:75:15
  31: <futures_util::stream::stream::filter_map::FilterMap<St,Fut,F> as futures_core::stream::Stream>::poll_next
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/futures-util-0.3.28/src/stream/stream/filter_map.rs:79:47
  32: <futures_util::stream::stream::map::Map<St,F> as futures_core::stream::Stream>::poll_next
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/futures-util-0.3.28/src/stream/stream/map.rs:58:26
  33: <futures_util::stream::stream::fuse::Fuse<S> as futures_core::stream::Stream>::poll_next
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/futures-util-0.3.28/src/stream/stream/fuse.rs:53:27
  34: <futures_util::stream::stream::forward::Forward<St,Si,Item> as core::future::future::Future>::poll
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/futures-util-0.3.28/src/stream/stream/forward.rs:59:19
  35: <futures_util::stream::stream::Forward<St,Si> as core::future::future::Future>::poll
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/futures-util-0.3.28/src/lib.rs:91:13
  36: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/futures-util-0.3.28/src/future/future/map.rs:55:37
  37: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/futures-util-0.3.28/src/lib.rs:91:13
  38: <futures_util::future::maybe_done::MaybeDone<Fut> as core::future::future::Future>::poll
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/futures-util-0.3.28/src/future/maybe_done.rs:95:38
  39: tower_lsp::transport::Server<I,O,L>::serve::{{closure}}::{{closure}}
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/futures-util-0.3.28/src/async_await/join_mod.rs:95:13
  40: <futures_util::future::poll_fn::PollFn<F> as core::future::future::Future>::poll
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/futures-util-0.3.28/src/future/poll_fn.rs:56:9
  41: tower_lsp::transport::Server<I,O,L>::serve::{{closure}}
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/tower-lsp-0.19.0/src/transport.rs:163:9
  42: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/future/mod.rs:91:19
  43: ark::lsp::backend::start_lsp::{{closure}}
             at ./crates/ark/src/lsp/backend.rs:635:52
  44: <core::future::from_generator::GenFuture<T> as core::future::future::Future>::poll
             at /rustc/69f9c33d71c871fc16ac445211281c6e7a340943/library/core/src/future/mod.rs:91:19
  45: tokio::runtime::park::CachedParkThread::block_on::{{closure}}
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/tokio-1.28.1/src/runtime/park.rs:283:63
  46: tokio::runtime::coop::with_budget
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/tokio-1.28.1/src/runtime/coop.rs:107:5
  47: tokio::runtime::coop::budget
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/tokio-1.28.1/src/runtime/coop.rs:73:5
  48: tokio::runtime::park::CachedParkThread::block_on
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/tokio-1.28.1/src/runtime/park.rs:283:31
  49: tokio::runtime::context::BlockingRegionGuard::block_on
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/tokio-1.28.1/src/runtime/context.rs:315:13
  50: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/tokio-1.28.1/src/runtime/scheduler/multi_thread/mod.rs:66:9
  51: tokio::runtime::runtime::Runtime::block_on
             at /Users/davis/.cargo/registry/src/github.zerozr99.workers.dev-1ecc6299db9ec823/tokio-1.28.1/src/runtime/runtime.rs:304:45
  52: ark::lsp::backend::start_lsp
             at ./crates/ark/src/lsp/backend.rs:636:5
  53: <ark::lsp::handler::Lsp as amalthea::language::lsp_handler::LspHandler>::start::{{closure}}
             at ./crates/ark/src/lsp/handler.rs:59:13
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions