Lea-fish / Leafish

A minecraft-like multi version client implemented in Rust.
Apache License 2.0
811 stars 46 forks source link

Login crash #166

Closed kepet19 closed 3 years ago

kepet19 commented 3 years ago

when I login it panics latest version 3f1740036ff10fc6dbc23f99247b5eb6a82a9fed

Minecraft server version 1.12.2

RUST_BACKTRACE=full

❮ RUST_BACKTRACE=full cargo run
    Finished dev [optimized + debuginfo] target(s) in 0.11s
     Running `target/debug/leafish`
[main.rs:220][INFO] Starting Leafish...
[main.rs:281][INFO] Shader version: #version 150
[xfer/mod.rs:47][WARN] error notifying wait, possible future leak: Err(ProtoError { kind: Message("requestor canceled") })
[xfer/mod.rs:47][WARN] error notifying wait, possible future leak: Err(ProtoError { kind: Message("requestor canceled") })
[xfer/mod.rs:47][WARN] error notifying wait, possible future leak: Err(ProtoError { kind: Message("requestor canceled") })
[xfer/mod.rs:47][WARN] error notifying wait, possible future leak: Err(ProtoError { kind: Message("requestor canceled") })
[xfer/mod.rs:47][WARN] error notifying wait, possible future leak: Err(ProtoError { kind: Message("requestor canceled") })
[xfer/mod.rs:47][WARN] error notifying wait, possible future leak: Err(ProtoError { kind: Message("requestor canceled") })
[main.rs:115][INFO] Detected server protocol version 578
thread '<unnamed>' panicked at 'bad packet internal id 0xb in Serverbound Play', protocol/src/protocol/versions/v1_15.rs:1:1
stack backtrace:
   0:     0x563e7fc8b4bc - std::backtrace_rs::backtrace::libunwind::trace::h788b2853b7016c32
                               at /rustc/1698e3cac54aa8691d4e9e207567672af8231cb6/library/std/src/../../backtrace/src/backtrace/libunwind.rs:90:5
   1:     0x563e7fc8b4bc - std::backtrace_rs::backtrace::trace_unsynchronized::h3626590e16510efa
                               at /rustc/1698e3cac54aa8691d4e9e207567672af8231cb6/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x563e7fc8b4bc - std::sys_common::backtrace::_print_fmt::ha76294ed367b5eb6
                               at /rustc/1698e3cac54aa8691d4e9e207567672af8231cb6/library/std/src/sys_common/backtrace.rs:67:5
   3:     0x563e7fc8b4bc - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h4244b134876ede81
                               at /rustc/1698e3cac54aa8691d4e9e207567672af8231cb6/library/std/src/sys_common/backtrace.rs:46:22
   4:     0x563e7fcafd7c - core::fmt::write::h9a6d9c74526a6c1b
                               at /rustc/1698e3cac54aa8691d4e9e207567672af8231cb6/library/core/src/fmt/mod.rs:1150:17
   5:     0x563e7fc83fc5 - std::io::Write::write_fmt::h7f8a2ef72f011ad9
                               at /rustc/1698e3cac54aa8691d4e9e207567672af8231cb6/library/std/src/io/mod.rs:1667:15
   6:     0x563e7fc8d0d0 - std::sys_common::backtrace::_print::h4b3c9553c91f7522
                               at /rustc/1698e3cac54aa8691d4e9e207567672af8231cb6/library/std/src/sys_common/backtrace.rs:49:5
   7:     0x563e7fc8d0d0 - std::sys_common::backtrace::print::h36fb46a493801fb8
                               at /rustc/1698e3cac54aa8691d4e9e207567672af8231cb6/library/std/src/sys_common/backtrace.rs:36:9
   8:     0x563e7fc8d0d0 - std::panicking::default_hook::{{closure}}::hf28f6810f0e04677
                               at /rustc/1698e3cac54aa8691d4e9e207567672af8231cb6/library/std/src/panicking.rs:210:50
   9:     0x563e7fc8cc87 - std::panicking::default_hook::hadb819fa279f9d7b
                               at /rustc/1698e3cac54aa8691d4e9e207567672af8231cb6/library/std/src/panicking.rs:227:9
  10:     0x563e7fc8d784 - std::panicking::rust_panic_with_hook::h015085c4aa271d26
                               at /rustc/1698e3cac54aa8691d4e9e207567672af8231cb6/library/std/src/panicking.rs:624:17
  11:     0x563e7fc8d260 - std::panicking::begin_panic_handler::{{closure}}::h15a8a2888dd1ba59
                               at /rustc/1698e3cac54aa8691d4e9e207567672af8231cb6/library/std/src/panicking.rs:521:13
  12:     0x563e7fc8b964 - std::sys_common::backtrace::__rust_end_short_backtrace::h673e204498e49379
                               at /rustc/1698e3cac54aa8691d4e9e207567672af8231cb6/library/std/src/sys_common/backtrace.rs:141:18
  13:     0x563e7fc8d1c9 - rust_begin_unwind
                               at /rustc/1698e3cac54aa8691d4e9e207567672af8231cb6/library/std/src/panicking.rs:517:5
  14:     0x563e7f074fcb - std::panicking::begin_panic_fmt::hc0c200f2fa4ef986
                               at /rustc/1698e3cac54aa8691d4e9e207567672af8231cb6/library/std/src/panicking.rs:460:5
  15:     0x563e7f827382 - leafish_protocol::protocol::versions::v1_15::translate_internal_packet_id::h52c663abaa22713d
  16:     0x563e7f7ee91a - leafish_protocol::protocol::versions::translate_internal_packet_id_for_version::h7c0e5ea3373740bd
  17:     0x563e7f7effb8 - <leafish_protocol::protocol::packet::play::serverbound::ClientSettings_u8_Handsfree as leafish_protocol::protocol::PacketType>
::packet_id::h39bc149e363bfea8
                               at /home/kkmp/dev/leafish/main-upstream/protocol/src/protocol/mod.rs:179:29
  18:     0x563e7f819be3 - leafish_protocol::protocol::Conn::write_packet::hfbe795686577cd16
                               at /home/kkmp/dev/leafish/main-upstream/protocol/src/protocol/mod.rs:1184:16
  19:     0x563e7f82ee60 - leafish_protocol::protocol::packet::send_client_settings::h8d5bc55bb271e62a
                               at /home/kkmp/dev/leafish/main-upstream/protocol/src/protocol/packet.rs:3500:9
  20:     0x563e7f0addeb - leafish::server::Server::on_game_join::hb6e1060140869944
                               at /home/kkmp/dev/leafish/main-upstream/src/server/mod.rs:1661:9
  21:     0x563e7f0ad862 - leafish::server::Server::on_game_join_hashedseed_respawn::hf1c86eb6fea9182f
                               at /home/kkmp/dev/leafish/main-upstream/src/server/mod.rs:1600:9
  22:     0x563e7f0875dc - leafish::server::Server::spawn_reader::{{closure}}::h0a4092841a64f510
                               at /home/kkmp/dev/leafish/main-upstream/src/server/mod.rs:522:29
  23:     0x563e7f0813c7 - std::sys_common::backtrace::__rust_begin_short_backtrace::h614764b137a05d2a
                               at /rustc/1698e3cac54aa8691d4e9e207567672af8231cb6/library/std/src/sys_common/backtrace.rs:125:18
  24:     0x563e7f1343d7 - std::thread::Builder::spawn_unchecked::{{closure}}::{{closure}}::hd11a092150e3c7dc
                               at /rustc/1698e3cac54aa8691d4e9e207567672af8231cb6/library/std/src/thread/mod.rs:481:17
  25:     0x563e7f1340c7 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h6e4b53ae340a4b20
                               at /rustc/1698e3cac54aa8691d4e9e207567672af8231cb6/library/core/src/panic/unwind_safe.rs:271:9
  26:     0x563e7f253d43 - std::panicking::try::do_call::hf1860deeabd7e428
                               at /rustc/1698e3cac54aa8691d4e9e207567672af8231cb6/library/std/src/panicking.rs:403:40
  27:     0x563e7f254274 - __rust_try.llvm.8106761219242412960
  28:     0x563e7f2535b5 - std::panicking::try::h81b36b43d7abea46
                               at /rustc/1698e3cac54aa8691d4e9e207567672af8231cb6/library/std/src/panicking.rs:367:19
  29:     0x563e7f0d11f7 - std::panic::catch_unwind::hb4c1f05e7aa53599
                               at /rustc/1698e3cac54aa8691d4e9e207567672af8231cb6/library/std/src/panic.rs:129:14
  30:     0x563e7f247e9f - std::thread::Builder::spawn_unchecked::{{closure}}::h35f870a23596a197
                               at /rustc/1698e3cac54aa8691d4e9e207567672af8231cb6/library/std/src/thread/mod.rs:480:30
  31:     0x563e7f249126 - core::ops::function::FnOnce::call_once{{vtable.shim}}::h91b41c7094e28898
                               at /rustc/1698e3cac54aa8691d4e9e207567672af8231cb6/library/core/src/ops/function.rs:227:5
  32:     0x563e7fc92673 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h334de5469f492d6e
                               at /rustc/1698e3cac54aa8691d4e9e207567672af8231cb6/library/alloc/src/boxed.rs:1636:9
  33:     0x563e7fc92673 - <alloc::boxed::Box<F,A> as core::ops::function::FnOnce<Args>>::call_once::h24abb7dc135c5761
                               at /rustc/1698e3cac54aa8691d4e9e207567672af8231cb6/library/alloc/src/boxed.rs:1636:9
  34:     0x563e7fc92673 - std::sys::unix::thread::Thread::new::thread_start::h09d0eb3bf5e9d59a
                               at /rustc/1698e3cac54aa8691d4e9e207567672af8231cb6/library/std/src/sys/unix/thread.rs:106:17
  35:     0x7fe545f23259 - start_thread
  36:     0x7fe545d065e3 - __GI___clone
  37:                0x0 - <unknown>

tried to add some debug statements.

// protocol/src/protocol/packet.rs ; bottom of the file
pub fn send_client_settings(
    conn: &mut Conn,
    version: Version,
    locale: String,
    view_distance: u8,
    chat_mode: u8,
    chat_colors: bool,
    displayed_skin_parts: u8,
    main_hand: Hand,
) -> Result<(), Error> {
    debug!("first");
    if version >= Version::V1_9 {
        debug!("if");
        // TODO: Do this for protocol version 48
        // 1 snapshot after 1.8
        conn.write_packet(packet::play::serverbound::ClientSettings_u8_Handsfree {
            locale,
            view_distance,
            chat_mode,
            chat_colors,
            displayed_skin_parts,
        })
    } else {
        debug!("else");
        conn.write_packet(packet::play::serverbound::ClientSettings {
            locale,
            view_distance,
            chat_mode: VarInt(chat_mode as i32),
            chat_colors,
            displayed_skin_parts,
            main_hand: VarInt(main_hand.ordinal() as i32),
        })
    }
}

output

[main.rs:115][INFO] Detected server protocol version 340
[protocol/mod.rs:1152][DEBUG] address: localhost is not an IP
[protocol/mod.rs:1154][DEBUG] localhost's ip may be localhost:25565.
[connect.rs:561][DEBUG] starting new connection: https://sessionserver.mojang.com/
[async_impl/client.rs:1649][DEBUG] response '204 No Content' for https://sessionserver.mojang.com/session/minecraft/join
[server/mod.rs:279][DEBUG] Login: Kevz__ b4309f1c-6a41-4ac0-8857-2be00133108d
[protocol/packet.rs:3497][DEBUG] first
[protocol/packet.rs:3499][DEBUG] if
thread '<unnamed>' panicked at 'bad packet internal id 0xb in Serverbound Play', protocol/src/protocol/versions/v1_12_2.rs:1:1
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace

tried getting the result of the function with this code

// protocol/src/protocol/packet.rs ; bottom of the file
pub fn send_client_settings(
    conn: &mut Conn,
    version: Version,
    locale: String,
    view_distance: u8,
    chat_mode: u8,
    chat_colors: bool,
    displayed_skin_parts: u8,
    main_hand: Hand,
) -> Result<(), Error> {
    debug!("first");
    let result = if version >= Version::V1_9 {
        // TODO: Do this for protocol version 48
        // 1 snapshot after 1.8
        conn.write_packet(packet::play::serverbound::ClientSettings_u8_Handsfree {
            locale,
            view_distance,
            chat_mode,
            chat_colors,
            displayed_skin_parts,
        })
    } else {
        conn.write_packet(packet::play::serverbound::ClientSettings {
            locale,
            view_distance,
            chat_mode: VarInt(chat_mode as i32),
            chat_colors,
            displayed_skin_parts,
            main_hand: VarInt(main_hand.ordinal() as i32),
        })
    };
    debug!("second");

    debug!("result {:?}", result);
    result
}

and the out is this.

[main.rs:115][INFO] Detected server protocol version 340
[protocol/mod.rs:1152][DEBUG] address: localhost is not an IP
[protocol/mod.rs:1154][DEBUG] localhost's ip may be localhost:25565.
[connect.rs:561][DEBUG] starting new connection: https://sessionserver.mojang.com/
[async_impl/client.rs:1649][DEBUG] response '204 No Content' for https://sessionserver.mojang.com/session/minecraft/join
[server/mod.rs:279][DEBUG] Login: Kevz__ b4309f1c-6a41-4ac0-8857-2be00133108d
[protocol/packet.rs:3497][DEBUG] first
thread '<unnamed>' panicked at 'bad packet internal id 0xb in Serverbound Play', protocol/src/protocol/versions/v1_12_2.rs:1:1
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
terrarier2111 commented 3 years ago

I think this https://github.com/Lea-fish/Leafish/commit/ffcdc17477f72461e2d4cf028d04735cf913912a should fix the issue.

PureTryOut commented 3 years ago

I confirm ffcdc17 fixes this, closing.