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

ark: investigate panic when updating internal document state #271

Closed
kevinushey opened this issue Mar 11, 2023 · 1 comment
Closed

ark: investigate panic when updating internal document state #271

kevinushey opened this issue Mar 11, 2023 · 1 comment
Milestone

Comments

@kevinushey
Copy link
Contributor

I saw this when editing near the end of the document, but haven't been able to reliably reproduce.

thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Char range out of bounds: char range 83..110, Rope/RopeSlice char length 97', /Users/kevin/.cargo/registry/src/github.com-1ecc6299db9ec823/ropey-1.6.0/src/rope.rs:546:37

stack backtrace:

   0: rust_begin_unwind
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/std/src/panicking.rs:575:5

   1: core::panicking::panic_fmt
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/panicking.rs:64:14
   2: core::result::unwrap_failed
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/result.rs:1790:5

   3: core::result::Result<T,
E>::unwrap
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/result.rs:1112:23

   4: ropey::rope::Rope::remove
             at 
./.cargo/registry/src/github.com-1ecc6299db9ec823/ropey-1.6.0/src/rope.rs:546:9


   5: ark::lsp::documents::Document::update
             at ./positron/extensions/positron-r/amalthea/crates/ark/src/lsp/documents.rs:128:9

   6: <ark::lsp::backend::Backend as tower_lsp::LanguageServer>::did_change::{{closure}}
             at ./positron/extensions/positron-r/amalthea/crates/ark/src/lsp/backend.rs:284:33

   7: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/future/future.rs:125:9


   8: tower_lsp::generated::register_lsp_methods::did_change::
{{closure
}}
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tower-lsp-0.19.0/src/lib.rs:112:1

   9: tower_lsp::jsonrpc::router::Router<S,E>::method::{{closure}}::{{closure}}::{{closure}
}
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tower-lsp-0.19.0/src/jsonrpc/router.rs:58:63
  10: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/future/future.rs:125:9

  11: <futures_util::future::future::map
::Map<Fut,F> 
as core::
future::future::Future
>::poll

             at ./
.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.26/src/future/future/map.rs:55:
37

  12: <futures_util::future::future::Map<Fut,F>
 as core::future::
future::Future>::poll
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.26/src/lib.rs:91:
13
  13: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/future/future.rs:125:9
  14: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/future/future.rs:125:9
  15: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/future/future.rs:125:9
  16: <tower_lsp::service::LspService<S> as tower_service::Service<tower_lsp::jsonrpc::Request>>::call::{{closure}}
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tower-lsp-0.19.0/src/service.rs:124:31
  17: <core::pin::Pin<P> as core::future::future::Future>::poll
             at /rustc/2c8cc343237b8f7d5a3c3703e3a87f2eb2c54a74/library/core/src/future/future.rs:125:9
  18: <F as futures_core::future::TryFuture>::try_poll
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures
-core-0.3.26/src/future.rs:82:9
  19: <futures_util::future::try_future::into_future::IntoFuture<Fut> as core::future::future::Future>::poll
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.26/src/future/try_future/into_future.rs:34:9
  20: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.26/src/future/future/map.rs:55:37
  21: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.26/src/lib.rs:91:13
  22: <futures_util::future::try_future::UnwrapOrElse<Fut,F> as core::future::future::Future>::poll
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.26/src/lib.rs:91:13
  23: <futures_util::stream::futures_unordered::FuturesUnordered<Fut> as futures_core::stream::Stream>::poll_next
             at ./.cargo/registry/src/g
ithub.com-1ecc6299db9ec823/futures-util-0.3.26/src/stream/futures_unordered/mod.rs:518:17
  24: futures_util::stream::stream::StreamExt::poll_next_unpin
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.26/src/stream/stream/mod.rs:1625:9
  25: <futures_util::stream::stream::buffer_unordered::BufferUnordered<St> as futures_core::stream::Stream>::poll_next
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.26/src/stream/stream/buffer_unordered.rs:75:15
  26: <futures_util::stream::stream::filter_map::FilterMap<St,Fut,F> as futures_core::stream::Stream>::poll_next
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.26/src/stream/stream/filter_map.rs:79:47
  27: <futures_util::stream::stream::map::Map<St,F> as futures_core::stream::Stream>::poll_next
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.26/src/stream/stream/map.rs:58:26
  28: <futures_util::stream::stream::fuse::Fuse<S> as 
futures_core::stream::Stream>::poll_next
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.26/src/stream/stream/fuse.rs:53:27
  29: <futures_util::stream::stream::forward::Forward<St,Si,Item> as core::future::future::Future>::poll
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.26/src/stream/stream/forward.rs:59:19
  30: <futures_util::stream::stream::Forward<St,Si> as core::future::future::Future>::poll
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.26/src/lib.rs:91:13
  31: <futures_util::future::future::map::Map<Fut,F> as core::future::future::Future>::poll
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.26/src/future/future/map.rs:55:37
  32: <futures_util::future::future::Map<Fut,F> as core::future::future::Future>::poll
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.26/src/lib.rs:91:13
  33: <futures_util::future::maybe_done::Maybe
Done<Fut> as core::future::future::Future>::poll
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.26/src/future/maybe_done.rs:95:38
  34: tower_lsp::transport::Server<I,O,L>::serve::{{closure}}::{{closure}}
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.26/src/async_await/join_mod.rs:95:13
  35: <futures_util::future::poll_fn::PollFn<F> as core::future::future::Future>::poll
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/futures-util-0.3.26/src/future/poll_fn.rs:56:9
  36: tower_lsp::transport::Server<I,O,L>::serve::{{closure}}
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tower-lsp-0.19.0/src/transport.rs:163:9
  37: ark::lsp::backend::start_lsp::{{closure}}
             at ./positron/extensions/positron-r/amalthea/crates/ark/src/lsp/backend.rs:609:52
  38: tokio::runtime::park::CachedParkThread::block_on::{{closure}}
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.26.0/src/r
untime/park.rs:283:63
  39: tokio::runtime::coop::with_budget
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.26.0/src/runtime/coop.rs:107:5
  40: tokio::runtime::coop::budget
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.26.0/src/runtime/coop.rs:73:5
  41: tokio::runtime::park::CachedParkThread::block_on
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.26.0/src/runtime/park.rs:283:31
  42: tokio::runtime::context::BlockingRegionGuard::block_on
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.26.0/src/runtime/context.rs:315:13
  43: tokio::runtime::scheduler::multi_thread::MultiThread::block_on
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.26.0/src/runtime/scheduler/multi_thread/mod.rs:66:9
  44: tokio::runtime::runtime::Runtime::block_on
             at ./.cargo/registry/src/github.com-1ecc6299db9ec823/tokio-1.26.0/src/runtime/runtime.rs:304:45
  45: ark::lsp::backend::start_lsp

             at ./positron/extensions/positron-r/amalthea/crates/ark/src/lsp/backend.rs:610:5
  46: <ark::lsp::handler::Lsp as amalthea::language::lsp_handler::LspHandler>::start::{{closure}}
             at ./positron/extensions/positron-r/amalthea/crates/ark/src/lsp/handler.rs:51:31
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
@kevinushey
Copy link
Contributor Author

Should now be fixed; this was caused by the document update events sent via VSCode being out-of-sync in some occasions. We now explicitly check the document version we receive, and delay applying those deltas if there appears to be a more recent update to be applied.

@kevinushey kevinushey removed their assignment May 30, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 7, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants