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

Divide by zero with some container actions #386

Closed
1 task done
kralverde opened this issue Dec 8, 2024 · 3 comments · Fixed by #393
Closed
1 task done

Divide by zero with some container actions #386

kralverde opened this issue Dec 8, 2024 · 3 comments · Fixed by #393
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@kralverde
Copy link
Contributor

kralverde commented Dec 8, 2024

I've searched existing issues and couldn't find a duplicate.

  • I confirm this is not a duplicate.

Operating System

Debian

Server Software Version/Commit

c7e02ec-modified

What happened?

Crash log from pumpkin.kralverde.dev

thread 'tokio-runtime-worker' panicked at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/num-traits-0.2.19/src/ops/euclid.rs:89:1:
attempt to divide by zero
stack backtrace:
   0: rust_begin_unwind
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:665:5
   1: core::panicking::panic_fmt
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/panicking.rs:74:14
   2: core::panicking::panic_const::panic_const_div_by_zero
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/panicking.rs:181:21
   3: core::num::<impl usize>::div_euclid
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/num/uint_macros.rs:2809:13
   4: <usize as num_traits::ops::euclid::Euclid>::div_euclid
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/num-traits-0.2.19/src/ops/euclid.rs:77:17
   5: num_traits::ops::euclid::Euclid::div_rem_euclid
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/num-traits-0.2.19/src/ops/euclid.rs:68:10
   6: pumpkin_inventory::drag_handler::DragHandler::apply_drag::{{closure}}
             at ./pumpkin-inventory/src/drag_handler.rs:125:21
   7: pumpkin::client::container::<impl pumpkin::entity::player::Player>::mouse_drag::{{closure}}
             at ./pumpkin/src/client/container.rs:463:22
   8: pumpkin::client::container::<impl pumpkin::entity::player::Player>::match_click_behaviour::{{closure}}
             at ./pumpkin/src/client/container.rs:265:22
   9: pumpkin::client::container::<impl pumpkin::entity::player::Player>::handle_click_container::{{closure}}
             at ./pumpkin/src/client/container.rs:173:10
  10: pumpkin::entity::player::Player::handle_play_packet::{{closure}}
             at ./pumpkin/src/entity/player.rs:672:22
  11: pumpkin::entity::player::Player::process_packets::{{closure}}::{{closure}}
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/macros/select.rs:557:49
  12: <core::future::poll_fn::PollFn<F> as core::future::future::Future>::poll
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/future/poll_fn.rs:151:9
  13: pumpkin::entity::player::Player::process_packets::{{closure}}
             at ./pumpkin/src/entity/player.rs:576:13
  14: pumpkin::main::{{closure}}::{{closure}}
             at ./pumpkin/src/main.rs:236:57
  15: tokio::runtime::task::core::Core<T,S>::poll::{{closure}}
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/task/core.rs:331:17
  16: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/loom/std/unsafe_cell.rs:16:9
  17: tokio::runtime::task::core::Core<T,S>::poll
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/task/core.rs:320:30
  18: tokio::runtime::task::harness::poll_future::{{closure}}
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/task/harness.rs:499:19
  19: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/panic/unwind_safe.rs:272:9
  20: std::panicking::try::do_call
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:557:40
  21: std::panicking::try
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:520:19
  22: std::panic::catch_unwind
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panic.rs:358:14
  23: tokio::runtime::task::harness::poll_future
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/task/harness.rs:487:18
  24: tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/task/harness.rs:209:27
  25: tokio::runtime::task::harness::Harness<T,S>::poll
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/task/harness.rs:154:15
  26: tokio::runtime::task::raw::poll
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/task/raw.rs:271:5
  27: tokio::runtime::task::raw::RawTask::poll
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/task/raw.rs:201:18
  28: tokio::runtime::task::LocalNotified<S>::run
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/task/mod.rs:435:9
  29: tokio::runtime::scheduler::multi_thread::worker::Context::run_task::{{closure}}
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/scheduler/multi_thread/worker.rs:596:18
  30: tokio::runtime::coop::with_budget
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/coop.rs:107:5
  31: tokio::runtime::coop::budget
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/coop.rs:73:5
  32: tokio::runtime::scheduler::multi_thread::worker::Context::run_task
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/scheduler/multi_thread/worker.rs:595:9
  33: tokio::runtime::scheduler::multi_thread::worker::Context::run
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/scheduler/multi_thread/worker.rs:546:24
  34: tokio::runtime::scheduler::multi_thread::worker::run::{{closure}}::{{closure}}
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/scheduler/multi_thread/worker.rs:511:21
  35: tokio::runtime::context::scoped::Scoped<T>::set
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/context/scoped.rs:40:9
  36: tokio::runtime::context::set_scheduler::{{closure}}
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/context.rs:180:26
  37: std::thread::local::LocalKey<T>::try_with
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/thread/local.rs:283:12
  38: std::thread::local::LocalKey<T>::with
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/thread/local.rs:260:9
  39: tokio::runtime::context::set_scheduler
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/context.rs:180:17
  40: tokio::runtime::scheduler::multi_thread::worker::run::{{closure}}
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/scheduler/multi_thread/worker.rs:506:9
  41: tokio::runtime::context::runtime::enter_runtime
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/context/runtime.rs:65:16
  42: tokio::runtime::scheduler::multi_thread::worker::run
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/scheduler/multi_thread/worker.rs:498:5
  43: tokio::runtime::scheduler::multi_thread::worker::Launch::launch::{{closure}}
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/scheduler/multi_thread/worker.rs:464:45
  44: <tokio::runtime::blocking::task::BlockingTask<T> as core::future::future::Future>::poll
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/blocking/task.rs:42:21
  45: tokio::runtime::task::core::Core<T,S>::poll::{{closure}}
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/task/core.rs:331:17
  46: tokio::loom::std::unsafe_cell::UnsafeCell<T>::with_mut
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/loom/std/unsafe_cell.rs:16:9
  47: tokio::runtime::task::core::Core<T,S>::poll
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/task/core.rs:320:30
  48: tokio::runtime::task::harness::poll_future::{{closure}}
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/task/harness.rs:499:19
  49: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/core/src/panic/unwind_safe.rs:272:9
  50: std::panicking::try::do_call
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:557:40
  51: std::panicking::try
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panicking.rs:520:19
  52: std::panic::catch_unwind
             at /rustc/90b35a6239c3d8bdabc530a6a0816f7ff89a0aaf/library/std/src/panic.rs:358:14
  53: tokio::runtime::task::harness::poll_future
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/task/harness.rs:487:18
  54: tokio::runtime::task::harness::Harness<T,S>::poll_inner
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/task/harness.rs:209:27
  55: tokio::runtime::task::harness::Harness<T,S>::poll
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/task/harness.rs:154:15
  56: tokio::runtime::task::raw::poll
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/task/raw.rs:271:5
  57: tokio::runtime::task::raw::RawTask::poll
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/task/raw.rs:201:18
  58: tokio::runtime::task::UnownedTask<S>::run
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/task/mod.rs:472:9
  59: tokio::runtime::blocking::pool::Task::run
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/blocking/pool.rs:161:9
  60: tokio::runtime::blocking::pool::Inner::run
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/blocking/pool.rs:511:17
  61: tokio::runtime::blocking::pool::Spawner::spawn_thread::{{closure}}
             at /home/minecraft/.cargo/registry/src/index.crates.io-6f17d22bba15001f/tokio-1.41.0/src/runtime/blocking/pool.rs:469:13
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

To Reproduce

Unknown

Expected behavior

N/A

@kralverde kralverde added the bug Something isn't working label Dec 8, 2024
@DataM0del
Copy link
Contributor

(carried_item.item_count as usize).div_rem_euclid(&amount_of_slots);

@DataM0del
Copy link
Contributor

Oh! drag_handler divides by 0 because you probably started dragging one of the items in a chest or etc. and because amount_of_slots is 0, and there's no checks, then it will divide by 0 and crash it.

@Snowiiii
Copy link
Owner

Oh! drag_handler divides by 0 because you probably started dragging one of the items in a chest or etc. and because amount_of_slots is 0, and there's no checks, then it will divide by 0 and crash it.

I'm not sure how to reproduce this ?

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

Successfully merging a pull request may close this issue.

3 participants