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

Panic when trying to add multiple games #3

Open
igormp opened this issue Apr 23, 2024 · 1 comment · May be fixed by mq1/wbfs-rs#1
Open

Panic when trying to add multiple games #3

igormp opened this issue Apr 23, 2024 · 1 comment · May be fixed by mq1/wbfs-rs#1

Comments

@igormp
Copy link

igormp commented Apr 23, 2024

After trying to copy multiple .wbfs games into a FAT32 formatted microSD on a Linux system, I end up getting a panic without a clear indicator on what's the underlying issue. Running with RUST_BACKTRACE=full returns the following:

Backtrace
RUST_BACKTRACE=full ./target/debug/tiny-wii-backup-manager
thread '<unnamed>' panicked at src/pages/games.rs:72:65:
called `Result::unwrap()` on an `Err` value: IO error

Caused by:
    Invalid argument (os error 22)

Stack backtrace:
   0: anyhow::error::<impl core::convert::From<E> for anyhow::Error>::from
             at /home/igor/.cargo/registry/src/index.crates.io-6f17d22bba15001f/anyhow-1.0.79/src/error.rs:565:25
   1: <core::result::Result<T,F> as core::ops::try_trait::FromResidual<core::result::Result<core::convert::Infallible,E>>>::from_residual
             at /usr/src/debug/rust/rustc-1.77.2-src/library/core/src/result.rs:1959:27
   2: tiny_wii_backup_manager::types::drive::Drive::add_game
             at ./src/types/drive.rs:114:21
   3: tiny_wii_backup_manager::pages::games::view::{{closure}}::{{closure}}::{{closure}}
             at ./src/pages/games.rs:72:37
   4: std::sys_common::backtrace::__rust_begin_short_backtrace
             at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/sys_common/backtrace.rs:155:18
   5: std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}
             at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/thread/mod.rs:529:17
   6: <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once
             at /usr/src/debug/rust/rustc-1.77.2-src/library/core/src/panic/unwind_safe.rs:272:9
   7: std::panicking::try::do_call
             at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/panicking.rs:554:40
   8: __rust_try
   9: std::panicking::try
             at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/panicking.rs:518:19
  10: std::panic::catch_unwind
             at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/panic.rs:142:14
  11: std::thread::Builder::spawn_unchecked_::{{closure}}
             at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/thread/mod.rs:528:30
  12: core::ops::function::FnOnce::call_once{{vtable.shim}}
             at /usr/src/debug/rust/rustc-1.77.2-src/library/core/src/ops/function.rs:250:5
  13: std::sys::pal::unix::thread::Thread::new::thread_start
  14: <unknown>
  15: <unknown>
stack backtrace:
   0:     0x613cac38c006 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h2fe490803af88cd5
   1:     0x613cac3bd110 - core::fmt::write::h0e806f9ceb53dc01
   2:     0x613cac386cdd - std::io::Write::write_fmt::hc993ca4907c5591c
   3:     0x613cac38bde4 - std::sys_common::backtrace::print::h7188c066e4378df6
   4:     0x613cac38d737 - std::panicking::default_hook::{{closure}}::hdc0fc6164adc38ae
   5:     0x613cac38d499 - std::panicking::default_hook::h42848e1a5516cbc3
   6:     0x613cac38dbc8 - std::panicking::rust_panic_with_hook::h37f14317b32091f5
   7:     0x613cac38daa2 - std::panicking::begin_panic_handler::{{closure}}::h8a1c6b82df46520d
   8:     0x613cac38c506 - std::sys_common::backtrace::__rust_end_short_backtrace::hc4ef5a9b6f477b45
   9:     0x613cac38d7f4 - rust_begin_unwind
  10:     0x613caaabf935 - core::panicking::panic_fmt::hacac095bf637f1ac
  11:     0x613caaabff73 - core::result::unwrap_failed::h51a1fc544636e6d9
  12:     0x613caab1af74 - core::result::Result<T,E>::unwrap::h4a92e7c02316681d
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/core/src/result.rs:1073:23
  13:     0x613caab1af74 - tiny_wii_backup_manager::pages::games::view::{{closure}}::{{closure}}::{{closure}}::he61e80842e0b5eb3
                               at /home/igor/Documents/Code/TinyWiiBackupManager/src/pages/games.rs:72:37
  14:     0x613caaaf9d56 - std::sys_common::backtrace::__rust_begin_short_backtrace::hae853361db2889e7
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/sys_common/backtrace.rs:155:18
  15:     0x613caaadc673 - std::thread::Builder::spawn_unchecked_::{{closure}}::{{closure}}::h31b9b2aa1f860e78
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/thread/mod.rs:529:17
  16:     0x613caaae1bb3 - <core::panic::unwind_safe::AssertUnwindSafe<F> as core::ops::function::FnOnce<()>>::call_once::h47f5aadc0fd5b526
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/core/src/panic/unwind_safe.rs:272:9
  17:     0x613caaafc91f - std::panicking::try::do_call::h881e27bb889a3da2
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/panicking.rs:554:40
  18:     0x613caaafcb5b - __rust_try
  19:     0x613caaafc748 - std::panicking::try::ha606d76ed8f3deb0
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/panicking.rs:518:19
  20:     0x613caaadbf4c - std::panic::catch_unwind::ha4985779a66dfcb7
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/panic.rs:142:14
  21:     0x613caaadbf4c - std::thread::Builder::spawn_unchecked_::{{closure}}::h7242b69013716f6d
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/std/src/thread/mod.rs:528:30
  22:     0x613caaaf32ae - core::ops::function::FnOnce::call_once{{vtable.shim}}::h2ba94c7115a70a9e
                               at /usr/src/debug/rust/rustc-1.77.2-src/library/core/src/ops/function.rs:250:5
  23:     0x613cac3942d5 - std::sys::pal::unix::thread::Thread::new::thread_start::haecd96a40b7bdcef
  24:     0x722c34fbd55a - <unknown>
  25:     0x722c3503aa3c - <unknown>
  26:                0x0 - <unknown>

One fun fact is that it fails on some certain games that have a - on their name, so maybe it's an issue with the underlying wbfs lib?
Here are the games that end up panicking:

  • Metroid - Other M (USA) (En,Fr,Es) (Rev 1)
  • Muramasa - The Demon Blade (USA)
  • No More Heroes 2 - Desperate Struggle (USA) (En,Fr,Es)

Other games, such as Fire Emblem - Radiant Dawn (USA) (Rev 1) don't seem to face this issue since the actual "standard" game name ends up as Fire Emblem: Radiant Dawn.

I'm not sure what other info may be relevant, but I'll be glad to provide whatever is needed :)

@sync-on-luma
Copy link

sync-on-luma commented Oct 28, 2024

I'm getting the exact same error on Fedora.
It appears that adding multiple games works fine, but certain games cause it to crash no matter what. In some cases it will work with a different dump of the same game, other times not.

Edit: I attempted to fix the issue myself. The crash seems to happen when wbfs::copy_wbfs_file() is called from drive.rs. I wasn't able to find that function in the code. I suspect it may be a part of this dependacy, but I'm not 100% sure.
Someone who has more experience with rust should take a look at it.

Edit 2: I went through the WBFS library and found the misbehaving function. I've fixed the issue and created a pull request. Once the library has been updated, this application just needs to be recompiled and the crashes should go away.

@sync-on-luma sync-on-luma linked a pull request Oct 28, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants