timdubbins / tap

An audio player for the terminal with fuzzy-finder.
MIT License
35 stars 2 forks source link

Panic #5

Closed chromer030 closed 1 year ago

chromer030 commented 1 year ago

OS: Arch Linux Version: compile from git

Compile argument : cargo build --release

backtrace:

./tap
thread 'main' panicked at 'cannot sample empty range', /home/chromer/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rand-0.8.5/src/rng.rs:134:9
stack backtrace:
   0:     0x7f40d5682f61 - <unknown>
   1:     0x7f40d56a7b1f - <unknown>
   2:     0x7f40d5680179 - <unknown>
   3:     0x7f40d5682d75 - <unknown>
   4:     0x7f40d56842a3 - <unknown>
   5:     0x7f40d5684034 - <unknown>
   6:     0x7f40d5684829 - <unknown>
   7:     0x7f40d56846e1 - <unknown>
   8:     0x7f40d56833c6 - <unknown>
   9:     0x7f40d5684472 - <unknown>
  10:     0x7f40d5444f73 - <unknown>
  11:     0x7f40d5445003 - <unknown>
  12:     0x7f40d5487090 - <unknown>
  13:     0x7f40d54e8970 - <unknown>
  14:     0x7f40d54c6d8b - <unknown>
  15:     0x7f40d54fe3c9 - <unknown>
  16:     0x7f40d545f0ed - <unknown>
  17:     0x7f40d54d29a3 - <unknown>
  18:     0x7f40d5493569 - <unknown>
  19:     0x7f40d567a65b - <unknown>
  20:     0x7f40d545f1e5 - <unknown>
  21:     0x7f40d5027cd0 - <unknown>
  22:     0x7f40d5027d8a - __libc_start_main
  23:     0x7f40d5445615 - <unknown>
  24:                0x0 - <unknown>

UPDATE: Same panic with 0.4.6 release. (https://github.com/timdubbins/tap/releases/download/v0.4.6/tap_0.4.6-x86_64-unknown-linux-gnu.tar.gz)

timdubbins commented 1 year ago

Hi, thanks for raising this issue.

Can you try running tap in a directory that contains audio files? Or supply a path as an argument?

I think this panic is caused by the way we're queuing a random track (for the 'random album' and 'random' shortcuts) - if tap is run in a directory that contains no audio this would panic.

Let me know if this solves your issue. If it does I'll add some error handling for this case. If not I will take a closer look and try and reproduce

chromer030 commented 1 year ago

Hi,

Can you try running tap in a directory that contains audio files?

No panic by this way, but: The behaviour of tap is somehow weird, i put it in a folder containing musics with tracks and folders (mp3, m4a, webm, ogg), but it onlt detects and play the first folder and the tracks inside it and ignores every other files. Let me show via screenshot:

Screenshot_20230926_214500

No sign of : All too well Daughter Joo won etc And it only enqueue and plays content of Pop folder

supply a path as an argument

Same panic:

$ ./tap Pop/
thread 'main' panicked at 'cannot sample empty range', /home/tim/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rand-0.8.5/src/rng.rs:134:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
chromer030 commented 1 year ago

Full backtrace:

$ RUST_BACKTRACE=full ./tap Pop/
thread 'main' panicked at 'cannot sample empty range', /home/tim/.cargo/registry/src/index.crates.io-6f17d22bba15001f/rand-0.8.5/src/rng.rs:134:9
stack backtrace:
   0:     0x55b0a2c9774a - std::backtrace_rs::backtrace::libunwind::trace::h9a6b80bbf328ba5d
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/../../backtrace/src/backtrace/libunwind.rs:93:5
   1:     0x55b0a2c9774a - std::backtrace_rs::backtrace::trace_unsynchronized::hd162ec543a11886b
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5
   2:     0x55b0a2c9774a - std::sys_common::backtrace::_print_fmt::h78a5099be12f51a6
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:65:5
   3:     0x55b0a2c9774a - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::ha1c5390454d74f71
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:44:22
   4:     0x55b0a2cb5caf - core::fmt::write::h9ffde816c577717b
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/fmt/mod.rs:1254:17
   5:     0x55b0a2c94b25 - std::io::Write::write_fmt::h88186074961638e4
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/io/mod.rs:1698:15
   6:     0x55b0a2c97515 - std::sys_common::backtrace::_print::h184198273ed08d59
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:47:5
   7:     0x55b0a2c97515 - std::sys_common::backtrace::print::h1b4d8e7add699453
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:34:9
   8:     0x55b0a2c98bbe - std::panicking::default_hook::{{closure}}::h393bcea75423915a
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:269:22
   9:     0x55b0a2c98965 - std::panicking::default_hook::h48c64f31d8b3fd03
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:288:9
  10:     0x55b0a2c9911e - std::panicking::rust_panic_with_hook::hafdc493a79370062
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:691:13
  11:     0x55b0a2c98fd2 - std::panicking::begin_panic_handler::{{closure}}::h0a64bc82e36bedc7
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:580:13
  12:     0x55b0a2c97bb6 - std::sys_common::backtrace::__rust_end_short_backtrace::hc203444fb7416a16
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/sys_common/backtrace.rs:150:18
  13:     0x55b0a2c98d72 - rust_begin_unwind
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:578:5
  14:     0x55b0a2a75753 - core::panicking::panic_fmt::h0f6ef0178afce4f2
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:67:14
  15:     0x55b0a2a757ed - core::panicking::panic::h0ead933cb8f56d66
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/panicking.rs:117:5
  16:     0x55b0a2a96f43 - tap::utils::random::ha777dd80d3b24636
  17:     0x55b0a2aad900 - tap::player::player::Player::randomized::h24ed4756dfa58c73
  18:     0x55b0a2af213f - tap::data::UserData::new::h8f0fca1e0c699fef
  19:     0x55b0a2afd8d9 - tap::app::run::h7a5f14fa257f482e
  20:     0x55b0a2aaee0d - tap::main::hfdee168564c8bdbd
  21:     0x55b0a2b155a3 - std::sys_common::backtrace::__rust_begin_short_backtrace::h5a4f0f554398fb82
  22:     0x55b0a2a86c79 - std::rt::lang_start::{{closure}}::h9d287f8170869061
  23:     0x55b0a2c8f4be - core::ops::function::impls::<impl core::ops::function::FnOnce<A> for &F>::call_once::hb1327dc2ef3fecdf
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/core/src/ops/function.rs:287:13
  24:     0x55b0a2c8f4be - std::panicking::try::do_call::h4044173225fe83dd
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:485:40
  25:     0x55b0a2c8f4be - std::panicking::try::hd8a722c09d156a53
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:449:19
  26:     0x55b0a2c8f4be - std::panic::catch_unwind::hd2ca07971cf0119b
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panic.rs:140:14
  27:     0x55b0a2c8f4be - std::rt::lang_start_internal::{{closure}}::h26d89d595cf47b70
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/rt.rs:148:48
  28:     0x55b0a2c8f4be - std::panicking::try::do_call::hf47aa1aa005e5f1a
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:485:40
  29:     0x55b0a2c8f4be - std::panicking::try::h73d246b2423eaf4e
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panicking.rs:449:19
  30:     0x55b0a2c8f4be - std::panic::catch_unwind::hbaaeae8f1b2f9915
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/panic.rs:140:14
  31:     0x55b0a2c8f4be - std::rt::lang_start_internal::h76f3e81e6b8f13f9
                               at /rustc/90c541806f23a127002de5b4038be731ba1458ca/library/std/src/rt.rs:148:20
  32:     0x55b0a2aaf045 - main
  33:     0x7fb7a3427cd0 - <unknown>
  34:     0x7fb7a3427d8a - __libc_start_main
  35:     0x55b0a2a75cd5 - _start
  36:                0x0 - <unknown>
timdubbins commented 1 year ago

Hey, this should be fixed with the latest commit.

I've also modified the search to include any audio files that are not in subdirectories of the search root (so All too well Daughter and Joo wo in your example directory will know be visible). These files appear under the name of the search root in the fuzzy-finder.

Let me know if this now works as expected.

chromer030 commented 1 year ago

Tested 0.4.7-git , issue fixed, thanks for your efforts.