neovide: memory leak and crash

Describe the bug when i activate cursor vfx the “railgun” or “torpedo” , memory usage is constantly growing and eventually crash neovide, i think skia drawOval has memory leak and cause heap fragmentation. the drawRect has not this problem.

To Reproduce scroll up and down a large file while the cursor vfx is active

Desktop (please complete the following information):

  • Neovide Version 0.7.0 main branch
  • Neovim Version 0.5.0

Additional context stack backtrace:

(lldb) bt
* thread #1, name = 'neovide', stop reason = signal SIGABRT
  * frame #0: 0x00007ffff7939d22 libc.so.6`raise + 322
    frame #1: 0x00007ffff7923862 libc.so.6`abort + 278
    frame #2: 0x00005555558c74e7 neovide`std::sys::unix::abort_internal::hba19dccca7c1e209 at mod.rs:206:14
    frame #3: 0x00005555555fb756 neovide`std::process::abort::ha624dd3301924e69 at process.rs:1814:5
    frame #4: 0x00005555558f08fd neovide`rust_oom at alloc.rs:332:5
    frame #5: 0x000055555562c5f6 neovide`__rg_oom at alloc.rs:397:18
    frame #6: 0x000055555561d1c6 neovide`__rust_alloc_error_handler + 6
    frame #7: 0x00005555555e6026 neovide`alloc::alloc::handle_alloc_error::hc93896c0bb99c404 at alloc.rs:366:9
    frame #8: 0x000055555575790d neovide`neovide::renderer::fonts::font_loader::FontPair::new::h0cd287bced57cd41 at raw_vec.rs:200:27
    frame #9: 0x00005555557578e5 neovide`neovide::renderer::fonts::font_loader::FontPair::new::h0cd287bced57cd41 [inlined] alloc::raw_vec::RawVec$LT$T$C$A$GT$::with_capacity_zeroed_in::h50b2a0cae49d3417(capacity=1741792) at raw_vec.rs:143
    frame #10: 0x00005555557578e5 neovide`neovide::renderer::fonts::font_loader::FontPair::new::h0cd287bced57cd41 [inlined] _$LT$u8$u20$as$u20$alloc..vec..spec_from_elem..SpecFromElem$GT$::from_elem::hcc3ee8c42f5147d3(elem='\0', n=1741792) at spec_from_elem.rs:39
    frame #11: 0x00005555557578e5 neovide`neovide::renderer::fonts::font_loader::FontPair::new::h0cd287bced57cd41 [inlined] alloc::vec::from_elem::heeb3f047dc7b7428(elem='\0', n=1741792) at mod.rs:2250
    frame #12: 0x00005555557578e5 neovide`neovide::renderer::fonts::font_loader::FontPair::new::h0cd287bced57cd41 at typeface.rs:259
    frame #13: 0x00005555557578d9 neovide`neovide::renderer::fonts::font_loader::FontPair::new::h0cd287bced57cd41 at option.rs:694
    frame #14: 0x00005555557578d9 neovide`neovide::renderer::fonts::font_loader::FontPair::new::h0cd287bced57cd41 at typeface.rs:256
    frame #15: 0x00005555557578a9 neovide`neovide::renderer::fonts::font_loader::FontPair::new::h0cd287bced57cd41(skia_font=<unavailable>) at font_loader.rs:27
    frame #16: 0x000055555575637d neovide`neovide::renderer::fonts::font_loader::FontLoader::get_or_load::h465e793d50c5a128 at font_loader.rs:141:17
    frame #17: 0x0000555555755c4b neovide`neovide::renderer::fonts::font_loader::FontLoader::get_or_load::h465e793d50c5a128(self=0x00007fffffff8fc8, font_key=0x00007fffd40e4860) at font_loader.rs:163
    frame #18: 0x000055555581abef neovide`neovide::renderer::fonts::caching_shaper::CachingShaper::shape_cached::h3f1f1ed4703ed7fc at caching_shaper.rs:178:42
    frame #19: 0x00005555558162b7 neovide`neovide::renderer::fonts::caching_shaper::CachingShaper::shape_cached::h3f1f1ed4703ed7fc at caching_shaper.rs:233
    frame #20: 0x0000555555815b53 neovide`neovide::renderer::fonts::caching_shaper::CachingShaper::shape_cached::h3f1f1ed4703ed7fc(self=0x00007fffffff8fa8, cells=size=0, bold=false, italic=false) at caching_shaper.rs:278
    frame #21: 0x00005555557b25f0 neovide`neovide::window::window_wrapper::GlutinWindowWrapper::draw_frame::h46b1043dd65fc2b2 at mod.rs:194:21
    frame #22: 0x00005555557b20d9 neovide`neovide::window::window_wrapper::GlutinWindowWrapper::draw_frame::h46b1043dd65fc2b2 at rendered_window.rs:361
    frame #23: 0x00005555557b17d6 neovide`neovide::window::window_wrapper::GlutinWindowWrapper::draw_frame::h46b1043dd65fc2b2 at mod.rs:226
    frame #24: 0x00005555557ae76c neovide`neovide::window::window_wrapper::GlutinWindowWrapper::draw_frame::h46b1043dd65fc2b2 at mod.rs:278
    frame #25: 0x00005555557ae028 neovide`neovide::window::window_wrapper::GlutinWindowWrapper::draw_frame::h46b1043dd65fc2b2(self=0x00007fffffff8cd0, dt=2.66246708E-44) at mod.rs:183
    frame #26: 0x00005555557c78da neovide`neovide::window::window_wrapper::start_loop::_$u7b$$u7b$closure$u7d$$u7d$::h5e629bdb493485fb(e=<unavailable>, _window_target=<unavailable>, control_flow=0x00007fffffff8a58) at mod.rs:292:13
    frame #27: 0x000055555560ed2d neovide`winit::platform_impl::platform::wayland::event_loop::EventLoop$LT$T$GT$::run::h891ecfb027add525 at mod.rs:760:5
    frame #28: 0x000055555560ece0 neovide`winit::platform_impl::platform::wayland::event_loop::EventLoop$LT$T$GT$::run::h891ecfb027add525 at mod.rs:388
    frame #29: 0x000055555560dbcc neovide`winit::platform_impl::platform::wayland::event_loop::EventLoop$LT$T$GT$::run::h891ecfb027add525(self=EventLoop<()> @ 0x00007fffffff9450, callback=<unavailable>) at mod.rs:191
    frame #30: 0x00005555557c7558 neovide`winit::platform_impl::platform::EventLoop$LT$T$GT$::run::h9e03b7e6da455ff8(self=<unavailable>, callback=closure-0 @ 0x00007fffffffa0a8) at mod.rs:676:56
    frame #31: 0x00005555557be62c neovide`winit::event_loop::EventLoop$LT$T$GT$::run::hf796eba8c1e5cb74(self=<unavailable>, event_handler=<unavailable>) at event_loop.rs:154:9
    frame #32: 0x00005555557bd588 neovide`neovide::window::window_wrapper::start_loop::h6a221b2ffa95330c(batched_draw_command_receiver=Receiver<alloc::vec::Vec<neovide::editor::DrawCommand, alloc::alloc::Global>> @ 0x00007fffffffa978, window_command_receiver=Receiver<neovide::editor::WindowCommand> @ 0x00007fffffffa988, ui_command_sender=LoggingTx<neovide::bridge::ui_commands::UiCommand> @ 0x00007fffffffd2e0, running=<unavailable>) at mod.rs:275:5
    frame #33: 0x00005555557f1cec neovide`neovide::main::hf6004e134216c6f2 [inlined] neovide::window::create_window::h94e3928045b04ba1(batched_draw_command_receiver=<unavailable>, window_command_receiver=<unavailable>, running=strong=3, weak=0) at mod.rs:50:5
    frame #34: 0x00005555557f1caa neovide`neovide::main::hf6004e134216c6f2 at main.rs:198
    frame #35: 0x00005555557c2223 neovide`std::sys_common::backtrace::__rust_begin_short_backtrace::h08200308916b41c7 [inlined] core::ops::function::FnOnce::call_once::h32472cc38e97eb5d((null)=<unavailable>) at function.rs:227:5
    frame #36: 0x00005555557c2221 neovide`std::sys_common::backtrace::__rust_begin_short_backtrace::h08200308916b41c7(f=<unavailable>) at backtrace.rs:125
    frame #37: 0x00005555557ee161 neovide`main + 641
    frame #38: 0x00007ffff7924b25 libc.so.6`__libc_start_main + 213
    frame #39: 0x000055555560237e neovide`_start + 46

or

(lldb) bt
* thread #1, name = 'neovide', stop reason = signal SIGABRT
  * frame #0: 0x00007ffff7939d22 libc.so.6`raise + 322
    frame #1: 0x00007ffff7923862 libc.so.6`abort + 278
    frame #2: 0x000055555693fa37 neovide`std::sys::unix::abort_internal::hba19dccca7c1e209 + 7
    frame #3: 0x0000555556937df5 neovide`std::sys_common::util::abort::hdb6a53068e4d2b07 + 85
    frame #4: 0x00005555569381b1 neovide`__rust_foreign_exception + 65
    frame #5: 0x000055555694aa75 neovide`__rust_panic_cleanup + 69
    frame #6: 0x000055555570862d neovide`std::panicking::try::cleanup::h7034096a336683e6 + 13
    frame #7: 0x0000555556939658 neovide`std::rt::lang_start_internal::h4461fc58637f04f8 + 1128
    frame #8: 0x000055555576b240 neovide`std::rt::lang_start::hdf94a43163798a50(main=(neovide`neovide::main::h839e9e1586d46ccc at main.rs:48), argc=1, argv=0x00007fffffffd998) at rt.rs:48:5
    frame #9: 0x000055555578bb0c neovide`main + 28
    frame #10: 0x00007ffff7924b25 libc.so.6`__libc_start_main + 213
    frame #11: 0x0000555555709bfe neovide`_start + 46

(lldb) bt
* thread #10, name = 'neovide'
  * frame #0: 0x0000555555a79037 neovide`alloc::raw_vec::RawVec$LT$T$C$A$GT$::current_memory::h67f17ae05a29db8e(self=0x00007fffd40e00e0) at raw_vec.rs:0:23
    frame #1: 0x0000555555a79bab neovide`_$LT$alloc..raw_vec..RawVec$LT$T$C$A$GT$$u20$as$u20$core..ops..drop..Drop$GT$::drop::h4fb6165240971428(self=0x00007fffd40e00e0) at raw_vec.rs:508:38
    frame #2: 0x0000555555a7a71b neovide`core::ptr::drop_in_place$LT$alloc..raw_vec..RawVec$LT$u8$GT$$GT$::h0dd4c97b70c1a1ba((null)=0x00007fffd40e00e0) at mod.rs:192:1
    frame #3: 0x0000555555a7a642 neovide`core::ptr::drop_in_place$LT$alloc..vec..Vec$LT$u8$GT$$GT$::h8c937fc114b2ea6f((null)=0x00007fffd40e00e0) at mod.rs:192:1
    frame #4: 0x0000555555a7a53b neovide`core::ptr::drop_in_place$LT$alloc..string..String$GT$::hfb094f9b48db56de((null)=0x00007fffd40e00e0) at mod.rs:192:1
    frame #5: 0x0000555555865837 neovide`core::ptr::drop_in_place$LT$$LP$alloc..string..String$C$core..option..Option$LT$alloc..sync..Arc$LT$neovide..editor..style..Style$GT$$GT$$RP$$GT$::h481b75071b966db5((null)=0x00007fffd40e00e0) at mod.rs:192:1
    frame #6: 0x0000555555866180 neovide`core::ptr::drop_in_place$LT$$u5b$$LP$alloc..string..String$C$core..option..Option$LT$alloc..sync..Arc$LT$neovide..editor..style..Style$GT$$GT$$RP$$u5d$$GT$::h1617de9ee81eb789((null)=*mut [(alloc::string::String, core::option::Option<alloc::sync::Arc<neovide::editor::style::Style>>)] @ 0x00007ffff65b0ed8) at mod.rs:192:1
    frame #7: 0x0000555555906072 neovide`_$LT$alloc..vec..Vec$LT$T$C$A$GT$$u20$as$u20$core..ops..drop..Drop$GT$::drop::h02a80ec194b8d9e1(self=0x00007fffd4050ba0) at mod.rs:2667:13
    frame #8: 0x0000555555867313 neovide`core::ptr::drop_in_place$LT$alloc..vec..Vec$LT$$LP$alloc..string..String$C$core..option..Option$LT$alloc..sync..Arc$LT$neovide..editor..style..Style$GT$$GT$$RP$$GT$$GT$::h01ce64df7e920d31((null)=0x00007fffd4050ba0) at mod.rs:192:1
    frame #9: 0x00005555558705fe neovide`core::ptr::drop_in_place$LT$neovide..editor..grid..CharacterGrid$GT$::h0ca0385dd1ec8be8((null)=0x00007fffd4050b90) at mod.rs:192:1
    frame #10: 0x000055555586f1f7 neovide`core::ptr::drop_in_place$LT$neovide..editor..window..Window$GT$::h7f48955e4f1f3dad((null)=0x00007fffd4050b88) at mod.rs:192:1
    frame #11: 0x00005555558714ee neovide`core::ptr::drop_in_place$LT$$LP$u64$C$neovide..editor..window..Window$RP$$GT$::h9fff84150b0f7f4a((null)=0x00007fffd4050b80) at mod.rs:192:1
    frame #12: 0x000055555577081a neovide`core::ptr::mut_ptr::_$LT$impl$u20$$BP$mut$u20$T$GT$::drop_in_place::h8efcf45d4931a3c8(self=0x00007fffd4050b80) at mut_ptr.rs:995:18
    frame #13: 0x00005555559253dd neovide`hashbrown::raw::Bucket$LT$T$GT$::drop::h0d5461bbf00be821 + 29
    frame #14: 0x00005555559278ee neovide`hashbrown::raw::RawTable$LT$T$C$A$GT$::drop_elements::h4558c7a29e1af4a4 + 238
    frame #15: 0x000055555592309e neovide`_$LT$hashbrown..raw..RawTable$LT$T$C$A$GT$$u20$as$u20$core..ops..drop..Drop$GT$::drop::h177b314864a42715 + 46
    frame #16: 0x000055555587630a neovide`core::ptr::drop_in_place$LT$hashbrown..raw..RawTable$LT$$LP$u64$C$neovide..editor..window..Window$RP$$GT$$GT$::hafa30dd3fe40038c((null)=0x00007ffff65b1160) at mod.rs:192:1
    frame #17: 0x000055555586575e neovide`core::ptr::drop_in_place$LT$hashbrown..map..HashMap$LT$u64$C$neovide..editor..window..Window$C$std..collections..hash..map..RandomState$GT$$GT$::h90943c12a8b42f8c((null)=0x00007ffff65b1150) at mod.rs:192:1
    frame #18: 0x0000555555862c7a neovide`core::ptr::drop_in_place$LT$std..collections..hash..map..HashMap$LT$u64$C$neovide..editor..window..Window$GT$$GT$::h5a48ef9b604fe5b5((null)=0x00007ffff65b1150) at mod.rs:192:1
    frame #19: 0x000055555586df33 neovide`core::ptr::drop_in_place$LT$neovide..editor..Editor$GT$::h9ab338d4cfcc13ea((null)=0x00007ffff65b1150) at mod.rs:192:1
    frame #20: 0x000055555572e30d neovide`neovide::editor::start_editor::_$u7b$$u7b$closure$u7d$$u7d$::h50122407489ca798 at mod.rs:454:5
    frame #21: 0x0000555555827f83 neovide`std::sys_common::backtrace::__rust_begin_short_backtrace::ha5b5b970243cecab(f=<unavailable>) at backtrace.rs:125:18
    frame #22: 0x000055555582947c neovide`std::thread::Builder::spawn_unchecked::_$u7b$$u7b$closure$u7d$$u7d$::_$u7b$$u7b$closure$u7d$$u7d$::hb2298ae6df8a320f at mod.rs:481:17
    frame #23: 0x00005555558216a0 neovide`_$LT$std..panic..AssertUnwindSafe$LT$F$GT$$u20$as$u20$core..ops..function..FnOnce$LT$$LP$$RP$$GT$$GT$::call_once::hb8c51ecd91996d7d(self=<unavailable>, _args=<unavailable>) at panic.rs:344:9
    frame #24: 0x000055555589db7a neovide`std::panicking::try::do_call::h46fdfdf433bde4f5(data="") at panicking.rs:379:40
    frame #25: 0x00005555558b852d neovide`__rust_try + 45
    frame #26: 0x000055555589be57 neovide`std::panicking::try::h5b64119d5bc5fbc3(f=<unavailable>) at panicking.rs:343:19
    frame #27: 0x0000555555828590 neovide`std::panic::catch_unwind::hdd55d4f080e892e6(f=<unavailable>) at panic.rs:431:14
    frame #28: 0x0000555555829279 neovide`std::thread::Builder::spawn_unchecked::_$u7b$$u7b$closure$u7d$$u7d$::ha9319d9d53e61499 at mod.rs:480:30
    frame #29: 0x000055555586020e neovide`core::ops::function::FnOnce::call_once$u7b$$u7b$vtable.shim$u7d$$u7d$::hdc63cac8f2291501((null)=0x0000555559596d80, (null)=<unavailable>) at function.rs:227:5
    frame #30: 0x000055555693f47a neovide`std::sys::unix::thread::Thread::new::thread_start::hc238bac7748b195d + 42
    frame #31: 0x00007ffff7c16259 libpthread.so.0`start_thread + 233
    frame #32: 0x00007ffff79fb5e3 libc.so.6`__clone + 67

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 43 (23 by maintainers)

Most upvoted comments

I can throw something like this together pretty quickly sometime soon. Thanks for the in depth investigation

After some thought, I think the best way forward with this, is to make a minimal example program, which doesn’t do anything else than drawing ovals using skia, to see if the issue occurs with that as well. I won’t do that myself, since I rather concentrate on other things, but someone with good Rust knowledge can probably do it in an hour or so.

If that example has problems it could be sent upstream, and hopefully fixed there.

That could be the difference then. But I guess we need more testers with different hardware.

It seems no matter what I do, I can’t reproduce it here on my end. But after looking at the code I agree with @s0hey1, it looks like it’s a bug inside skia and draw_oval. It should be easy enough to verify by changing this https://github.com/neovide/neovide/blob/main/src/renderer/cursor_renderer/cursor_vfx.rs#L355 to draw_rect instead of draw_oval. Can you test that @dineshKumar777?

Can you also verify that you have the same version of skia as I have in the Cargo.lock file

name = "skia-bindings"
version = "0.42.1"

Yes, sorry for the confusion, it seems like neovim sends that event even if you don’t have multi-grid enabled although the documentation says it’s multigrid specific here https://neovim.io/doc/user/ui.html.

I tested without multigrid myself, and I get the same errors, but no memory leaks, so the error is unrelated like I suspected.

Not sure! I’ll have to look into it tomorrow. It’s very late here.

I tested some more with the fonts, and the :set guifont only seem to leak memory when specifying a non-nerd font based font, or very likely more specifically a font that’s lacking some glyphs on the screen. Manually adding a fallback font is enough to make it not leak memory.

Anyway, that sounds like it should be a quite easy fix. But I still haven’t managed to properly reproduce the cursor effect memory leak. @dineshKumar777 or someone else, could you provide the log file too? Maybe there’s something in there that gives a clue of what’s happening.

I managed to find time to do a quick test with the fonts.

Calling :set guifont= causes a memory leak of similar size per call. I don’t know why the cursor effect would load any font though