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

Attempt to divide by zero when changing scale factor #2221

Closed
floflo0 opened this issue Dec 29, 2023 · 1 comment · Fixed by #2307
Closed

Attempt to divide by zero when changing scale factor #2221

floflo0 opened this issue Dec 29, 2023 · 1 comment · Fixed by #2307
Labels
bug Something isn't working

Comments

@floflo0
Copy link

floflo0 commented Dec 29, 2023

Describe the bug
When the scale factor is set to a too small value, neovide crash.

To Reproduce
Steps to reproduce the behavior:

  1. launch neovide
  2. set the scale factor : lua vim.g.neovide_scale_factor = 0.01

Expected behavior
No crash

Screenshots
If applicable, add screenshots to help explain your problem.

Desktop (please complete the following information):

  • OS: Pop OS! 22.04
  • Neovide Version 0.12.0
  • Neovim Version 0.10.0-dev

Please run neovide --log and paste the contents of the .log file created in the current directory here:

2023-12-29 15:31:33 - Neovide panicked with the message 'attempt to divide by zero'. (File: src/dimensions.rs; Line: 132, Column: 27)
   0: neovide::main::{{closure}}
             at src/main.rs:78:25
   1: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/alloc/src/boxed.rs:2021:9
      std::panicking::rust_panic_with_hook
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:783:13
   2: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:649:13
   3: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:170:18
   4: rust_begin_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:645:5
   5: core::panicking::panic_fmt
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:72:14
   6: core::panicking::panic
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/panicking.rs:127:5
   7: <neovide::dimensions::Dimensions as core::ops::arith::Div>::div
             at src/dimensions.rs:132:27
   8: neovide::renderer::grid_renderer::GridRenderer::convert_physical_to_grid
             at src/renderer/grid_renderer.rs:59:9
   9: neovide::window::window_wrapper::WinitWindowWrapper::get_grid_size_from_window
             at src/window/window_wrapper.rs:523:25
  10: neovide::window::window_wrapper::WinitWindowWrapper::update_grid_size_from_window
             at src/window/window_wrapper.rs:537:25
  11: neovide::window::window_wrapper::WinitWindowWrapper::prepare_frame
             at src/window/window_wrapper.rs:465:17
  12: neovide::window::update_loop::UpdateLoop::step
             at src/window/update_loop.rs:215:47
  13: neovide::window::main_loop::{{closure}}
             at src/window/mod.rs:293:44
  14: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:294:13
  15: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:294:13
  16: winit::platform_impl::platform::x11::EventLoop<T>::single_iteration
             at /home/floris/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.4/src/platform_impl/linux/x11/mod.rs:616:13
  17: winit::platform_impl::platform::x11::EventLoop<T>::poll_events_with_timeout
             at /home/floris/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.4/src/platform_impl/linux/x11/mod.rs:543:9
  18: winit::platform_impl::platform::x11::EventLoop<T>::pump_events
             at /home/floris/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.4/src/platform_impl/linux/x11/mod.rs:449:13
  19: winit::platform_impl::platform::x11::EventLoop<T>::run_on_demand
             at /home/floris/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.4/src/platform_impl/linux/x11/mod.rs:410:19
  20: winit::platform_impl::platform::EventLoop<T>::run_on_demand
             at /home/floris/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.4/src/platform_impl/linux/mod.rs:821:56
  21: winit::platform_impl::platform::EventLoop<T>::run
             at /home/floris/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.4/src/platform_impl/linux/mod.rs:814:9
  22: winit::event_loop::EventLoop<T>::run
             at /home/floris/.cargo/registry/src/index.crates.io-6f17d22bba15001f/winit-0.29.4/src/event_loop.rs:249:9
  23: neovide::window::main_loop
             at src/window/mod.rs:284:5
  24: neovide::main
             at src/main.rs:98:13
  25: core::ops::function::FnOnce::call_once
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:250:5
  26: std::sys_common::backtrace::__rust_begin_short_backtrace
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/sys_common/backtrace.rs:154:18
  27: std::rt::lang_start::{{closure}}
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:167:18
  28: core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/core/src/ops/function.rs:284:13
      std::panicking::try::do_call
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
      std::panicking::try
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
      std::panic::catch_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
      std::rt::lang_start_internal::{{closure}}
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:148:48
      std::panicking::try::do_call
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:552:40
      std::panicking::try
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panicking.rs:516:19
      std::panic::catch_unwind
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/panic.rs:142:14
      std::rt::lang_start_internal
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:148:20
  29: std::rt::lang_start
             at /rustc/82e1608dfa6e0b5569232559e3d385fea5a93112/library/std/src/rt.rs:166:17
  30: main
  31: __libc_start_call_main
             at ./csu/../sysdeps/nptl/libc_start_call_main.h:58:16
  32: __libc_start_main_impl
             at ./csu/../csu/libc-start.c:392:3
  33: _start

Additional context
No crash happended when the scale factor is set to exactly 0.0.
The samllest value possible before crash change with my personal config or with no config at all but the bug is still there.

@floflo0 floflo0 added the bug Something isn't working label Dec 29, 2023
@fredizzimo
Copy link
Member

I can’t fix it myself due to not having access to a development environment. But I believe this should be fixed in the font renderer, we should not allow the size to be less than one pixel, neither the width nor height.

We could possibly additionally set limits on the minimum and maximum scale factor allowed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants