iceiix / stevenarella

Multi-protocol Minecraft-compatible client written in Rust
Apache License 2.0
1.45k stars 59 forks source link

on_chunk_data_biomes3d_bitmasks: index out of bounds: the len is 0 but the index is 0 (chunk_data.bitmasks.data[0] empty array) #654

Open Dreamail opened 2 years ago

Dreamail commented 2 years ago

[main.rs:254][INFO] Starting steven [main.rs:346][INFO] Shader version: #version 150 [main.rs:99][INFO] Detected server protocol version 756 [server/mod.rs:1916][INFO] Received chat message: [GSit] 新版本可用: 1.0.5! [server/mod.rs:1916][INFO] Received chat message: [GSit] 当前使用版本: 1.0.4! [server/mod.rs:1916][INFO] Received chat message: [GSit] 下载最新版本: [server/mod.rs:1916][INFO] Received chat message: [GSit] https://www.spigotmc.org/resources/62325 [server/mod.rs:1916][INFO] Received chat message: [Themis] You're running an outdated version of Themis, you should update as soon as possible! [server/mod.rs:1916][INFO] Received chat message: An update for PlaceholderAPI (PlaceholderAPI v2.11.1) [server/mod.rs:1916][INFO] Received chat message: is available at https://www.spigotmc.org/resources/placeholderapi.6245/ [server/mod.rs:1916][INFO] Received chat message: unhandled: multiplayer.player.joined thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', src/server/mod.rs:1957:17 stack backtrace: 0: _rust_begin_unwind 1: core::panicking::panic_fmt 2: core::panicking::panic_bounds_check 3: stevenarella::server::Server::entity_tick 4: stevenarella::server::Server::tick 5: stevenarella::tick_all 6: stevenarella::main2::{{closure}} 7: <winit::platform_impl::platform::app_state::EventLoopHandler as winit::platform_impl::platform::app_state::EventHandler>::handle_nonuser_event 8: winit::platform_impl::platform::app_state::Handler::handle_nonuser_event 9: winit::platform_impl::platform::app_state::AppState::cleared 10: winit::platform_impl::platform::observer::control_flow_end_handler 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: winit::platform_impl::platform::event_loop::EventLoop::run 22: winit::event_loop::EventLoop::run 23: stevenarella::main note: Some details are omitted, run with RUST_BACKTRACE=full for a verbose backtrace.

iceiix commented 2 years ago

thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', src/server/mod.rs:1957:17

If this was on build 9a8d3572eb30c875199efe6bd7c22ac31e781dd9, from 1/17/2022, appears the crash is an OOB in reading chunk data:

    fn on_chunk_data_biomes3d_bitmasks(
        &mut self,
        chunk_data: packet::play::clientbound::ChunkData_Biomes3D_Bitmasks,
    ) {
        self.world
            .load_chunk117(
                chunk_data.chunk_x,
                chunk_data.chunk_z,
                true,
                chunk_data.bitmasks.data[0] as u64, // TODO: get all bitmasks  // <-- HERE
                16,                                 // TODO: get all bitmasks
                chunk_data.data.data,
            )
            .unwrap();
        self.load_block_entities(chunk_data.block_entities.data);
    }

so chunk_data.bitmasks.data is empty, but this case isn't handled. But if there is no data, is there any chunk to load? Are these "empty" chunks, should they be skipped?