dustinblackman / oatmeal.nvim

Terminal UI to chat with large language models (LLM) using different model backends, and with a plugin for Neovim!
https://github.com/dustinblackman/oatmeal
MIT License
82 stars 3 forks source link

Capacity Overflow panic #4

Closed marshallformula closed 10 months ago

marshallformula commented 10 months ago

Love oatmeal! Thank you for creating this!!

I'm pretty regularly getting the error below I launch Oatmeal from the neovim plugin. It looks like the error is spawning from the oatmeal rust code, so I wasn't sure if the issue should be filed there, but I only get the error running from neovim.

Environment: OS: Macos Sonomoa Arch: M1 with 64 GB memory Neovim: v0.9.4

Error:


❌❯ RUST_BACKTRACE=full oatmeal --editor neovim --backend ollama --model codellama:latest
Backtrace (most recent call first):
  File "<unknown>", line 0, in alloc::raw_vec::capacity_overflow
  File "<unknown>", line 0, in alloc::slice::<impl [T]>::repeat
  File "<unknown>", line 0, in core::ops::function::impls::<impl core::ops::function::FnOnce<A> f
or &mut F>::call_once
  File "<unknown>", line 0, in <core::iter::adapters::flatten::FlatMap<I,U,F> as core::iter::trai
ts::iterator::Iterator>::next
  File "<unknown>", line 0, in oatmeal::domain::services::bubble_list::BubbleList::set_messages
  File "<unknown>", line 0, in ratatui::terminal::Terminal<B>::draw
  File "<unknown>", line 0, in <tokio::future::poll_fn::PollFn<F> as core::future::future::Future
>::poll
  File "<unknown>", line 0, in oatmeal::main::{{closure}}::h0fa4a3f33451786e.13931
  File "<unknown>", line 0, in oatmeal::main
  File "<unknown>", line 0, in std::sys_common::backtrace::__rust_begin_short_backtrace
  File "<unknown>", line 0, in _main

The application panicked (crashed).
  capacity overflow
in library/alloc/src/raw_vec.rs, line 534
thread: main

I would say I get this error about 90% of the times I've launched the :Oatmeal command from neovim.

Let me know what other information you need. I'm not a rust developer so I'm afraid I wouldn't be much help implementing a fix. But I love oatmeal - getting it to work in my Neovim setup would be amazing!

dustinblackman commented 10 months ago

Wow 90%? That's nuts. I haven't had it crash on me once so far, so I'm curious how you're getting there! I got a few questions to help get to the bottom of it.

  1. Are you selecting code in visual mode before running :Oatmeal, or running it from normal mode?
  2. Do you happen to have a file you can publicly share that's causing the crash?

Some stuff that could also help me debug:

  1. I've started uploading debug symbols for each release. This helps provide more indepth stack traces. If you got a few moments free, would you mind giving it a shot? https://github.com/dustinblackman/oatmeal#report-an-issue
  2. v0.7.1 has introduced debug logging for the neovim editor integration. You can enable logging by prefixing your command with RUST_LOG=oatmeal, with the file being accessible by running cat $(oatmeal sessions dir)/../debug.log | grep oatmeal. Seeing what's going under the hood would help a lot.

Thanks!

marshallformula commented 10 months ago

Sure thing.

Questions:

  1. It happens in both instances, but I'm usually just running it from normal mode.
  2. It seems to be happening no matter the file I try with. I've added it as a gist here if it's helpful

Homebrew doesn't have 0.71 yet, so I removed it and built oatmeal from source and installed in /usr/local/bin and followed the steps to add the DEBUG symbols.

I ran it again with the RUST_LOG and RUST_BACKTRACE env vars. The stacktrace looks about the same as above. The debug.log file isn't very big so I'm attaching it here

Let me know what else I can do to help troubleshoot things!

debug.log

dustinblackman commented 10 months ago

Nice, thank you! I got a repro. The terminal split that's opening, is it really small?

marshallformula commented 10 months ago

No not particularly. It splits right at 50%

CleanShot 2023-12-06 at 17 11 20@2x

dustinblackman commented 10 months ago

Weird, but hopefully I got it figured out. I've just released v0.7.2. Lemme know if it works for you :)

marshallformula commented 10 months ago

It's working like a champ! Thanks for all the hard work!