MCHPR / MCHPRS

A multithreaded Minecraft server built for redstone.
MIT License
1.55k stars 68 forks source link

Plot panics when comparator reads from an empty container #150

Closed BramOtte closed 2 weeks ago

BramOtte commented 2 months ago

To reproduce, place a comparator infront of an empty barrel, the plot will panic immediately

Error message:

2024-05-06T18:01:01.822437Z ERROR mchprs_core::server: plot panicked at crates/core/src/redstone/comparator.rs:49:25:
internal error: entered unreachable code: Backing blockentity does not exist
   0: mchprs_core::server::MinecraftServer::run::{{closure}}
             at crates/core/src/server.rs:134:29
   1: <alloc::boxed::Box<F,A> as core::ops::function::Fn<Args>>::call
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/alloc/src/boxed.rs:2029:9
      std::panicking::rust_panic_with_hook
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:783:13
   2: std::panicking::begin_panic_handler::{{closure}}
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:649:13
   3: std::sys_common::backtrace::__rust_end_short_backtrace
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys_common/backtrace.rs:171:18
   4: rust_begin_unwind
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:645:5
   5: core::panicking::panic_fmt
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panicking.rs:72:14
   6: mchprs_core::redstone::comparator::get_override
             at crates/core/src/redstone/comparator.rs:49:25
   7: mchprs_core::redstone::comparator::calculate_input_strength
   8: mchprs_core::redstone::comparator::calculate_output_strength
             at crates/core/src/redstone/comparator.rs:114:26
   9: mchprs_core::redstone::comparator::update
             at crates/core/src/redstone/comparator.rs:142:27
  10: mchprs_core::redstone::update_surrounding_blocks
             at crates/core/src/redstone/mod.rs:344:9
  11: mchprs_core::interaction::place_in_world
             at crates/core/src/interaction.rs:281:9
  12: mchprs_core::interaction::use_item_on_block
             at crates/core/src/interaction.rs:487:9
  13: mchprs_core::plot::packet_handlers::<impl mchprs_network::packets::serverbound::ServerBoundPacketHandler for mchprs_core::plot::Plot>::handle_player_block_placement
             at crates/core/src/plot/packet_handlers.rs:245:29
  14: <mchprs_network::packets::serverbound::SPlayerBlockPlacemnt as mchprs_network::packets::serverbound::ServerBoundPacket>::handle
             at crates/network/src/packets/serverbound.rs:421:9
  15: mchprs_core::plot::packet_handlers::<impl mchprs_core::plot::Plot>::handle_packets_for_player
             at crates/core/src/plot/packet_handlers.rs:27:13
      mchprs_core::plot::Plot::update_players
             at crates/core/src/plot/mod.rs:830:13
      mchprs_core::plot::Plot::update
             at crates/core/src/plot/mod.rs:913:9
  16: mchprs_core::plot::Plot::run
             at crates/core/src/plot/mod.rs:1066:13
  17: mchprs_core::plot::Plot::load_and_run::{{closure}}
             at crates/core/src/plot/mod.rs:1091:17
      std::sys_common::backtrace::__rust_begin_short_backtrace
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys_common/backtrace.rs:155:18
  18: std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/mod.rs:529:17
      <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/panic/unwind_safe.rs:272:9
      std::panicking::try::do_call
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:552:40
      std::panicking::try
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panicking.rs:516:19
      std::panic::catch_unwind
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/panic.rs:142:14
      std::thread::Builder::spawn_unchecked_::{{closure}}
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/thread/mod.rs:528:30
      core::ops::function::FnOnce::call_once{{vtable.shim}}
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/core/src/ops/function.rs:250:5
  19: <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/alloc/src/boxed.rs:2015:9
      <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/alloc/src/boxed.rs:2015:9
      std::sys::unix::thread::Thread::new::thread_start
             at /rustc/07dca489ac2d933c78d3c5158e3f43beefeb02ce/library/std/src/sys/unix/thread.rs:108:17
  20: start_thread
             at ./nptl/pthread_create.c:442:8
  21: __GI___clone3
             at ./misc/../sysdeps/unix/sysv/linux/x86_64/clone3.S:81
StackDoubleFlow commented 2 weeks ago

Fixed in 00a0d4e5a95510c207e9ee71c838359a2b1d1b53