charleywright / spotify-analyze-v2

4 stars 1 forks source link

Failed to send data to FIFO channel #10

Open hansiflick12 opened 4 months ago

hansiflick12 commented 4 months ago

Im trying to run pineapple on ubuntu, now im getting the following error:

root@ubuntu-4gb-hel1-1:~/spotify-analyze-v2/pineapple/target/release# ./pineapple listen --write a.pcapng Accepted connection from x.x.x.x:49995 thread 'main' panicked at src/proxy/pcap.rs:97:41: Failed to write interface block: IoError(Custom { kind: Other, error: "Failed to send data to FIFO channel" }) note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

hansiflick12 commented 4 months ago

full backtrace:

root@ubuntu-4gb-hel1-1:~/spotify-analyze-v2/pineapple/target/release# RUST_BACKTRACE=full cargo run listen Finished dev profile [unoptimized + debuginfo] target(s) in 0.13s Running /root/spotify-analyze-v2/pineapple/target/debug/pineapple listen Listening on 0.0.0.0:4070 Accepted connection from 109.192.119.203:50221 thread 'main' panicked at src/proxy/pcap.rs:97:41: Failed to write interface block: IoError(Custom { kind: Other, error: "Failed to send data to FIFO channel" }) stack backtrace: 0: 0x61de814ea845 - std::backtrace_rs::backtrace::libunwind::trace::hb4d9489fd44693d7 at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/std/src/../../backtrace/src/backtrace/libunwind.rs:105:5 1: 0x61de814ea845 - std::backtrace_rs::backtrace::trace_unsynchronized::h9f7a303c564be742 at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/std/src/../../backtrace/src/backtrace/mod.rs:66:5 2: 0x61de814ea845 - std::sys_common::backtrace::_print_fmt::h61cec1a0bb227b54 at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/std/src/sys_common/backtrace.rs:68:5 3: 0x61de814ea845 - ::fmt::h83a98f6d5617789b at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/std/src/sys_common/backtrace.rs:44:22 4: 0x61de8150c84b - core::fmt::rt::Argument::fmt::h54122b05c7531f92 at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/core/src/fmt/rt.rs:165:63 5: 0x61de8150c84b - core::fmt::write::h880ae86840cfb66d at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/core/src/fmt/mod.rs:1157:21 6: 0x61de814e810f - std::io::Write::write_fmt::h39b30cd087522a51 at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/std/src/io/mod.rs:1832:15 7: 0x61de814ea61e - std::sys_common::backtrace::_print::h25741770fceedc79 at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/std/src/sys_common/backtrace.rs:47:5 8: 0x61de814ea61e - std::sys_common::backtrace::print::h5e0016a491d84c1d at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/std/src/sys_common/backtrace.rs:34:9 9: 0x61de814eb8d9 - std::panicking::default_hook::{{closure}}::h0c2f75f7a65b5547 10: 0x61de814eb61d - std::panicking::default_hook::h1284229a24b71c4c at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/std/src/panicking.rs:298:9 11: 0x61de814ebd73 - std::panicking::rust_panic_with_hook::hca3ced3c46879131 at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/std/src/panicking.rs:795:13 12: 0x61de814ebc54 - std::panicking::begin_panic_handler::{{closure}}::h4ff95bfaaee639b6 at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/std/src/panicking.rs:664:13 13: 0x61de814ead09 - std::sys_common::backtrace::rust_end_short_backtrace::h9ea6903d337d4498 at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/std/src/sys_common/backtrace.rs:171:18 14: 0x61de814eb987 - rust_begin_unwind at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/std/src/panicking.rs:652:5 15: 0x61de7f17c053 - core::panicking::panic_fmt::h766125e319de443c at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/core/src/panicking.rs:72:14 16: 0x61de7f17c5a6 - core::result::unwrap_failed::h942a9268418bbe17 at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/core/src/result.rs:1654:5 17: 0x61de7f1d0ee3 - core::result::Result<T,E>::expect::h75ccacd0e14a0ed0 at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/core/src/result.rs:1034:23 18: 0x61de7f1c6117 - pineapple::proxy::pcap::PcapWriter::create_interface::h83cffcb66761ee7c at /root/spotify-analyze-v2/pineapple/src/proxy/pcap.rs:97:9 19: 0x61de7f18413d - pineapple::proxy::proxy_session::ProxySession::handle_event::h3dbace0cb2c6dfae at /root/spotify-analyze-v2/pineapple/src/proxy/proxy_session.rs:381:25 20: 0x61de7f1b25ce - pineapple::proxy::run_proxy::h239b24779860d3d1 at /root/spotify-analyze-v2/pineapple/src/proxy.rs:94:45 21: 0x61de7f1a2665 - pineapple::main::h80c56d870da59a72 at /root/spotify-analyze-v2/pineapple/src/main.rs:108:38 22: 0x61de7f1f5deb - core::ops::function::FnOnce::call_once::h8f1912e92df5df6b at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/core/src/ops/function.rs:250:5 23: 0x61de7f1e4e9e - std::sys_common::backtrace::__rust_begin_short_backtrace::h1b479bdce6f02a95 at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/std/src/sys_common/backtrace.rs:155:18 24: 0x61de7f202501 - std::rt::lang_start::{{closure}}::h6b7a935930fb7f9a at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/std/src/rt.rs:159:18 25: 0x61de814e1cf0 - core::ops::function::impls::<impl core::ops::function::FnOnce for &F>::call_once::h05e5fc3ed039dc6b at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/core/src/ops/function.rs:284:13 26: 0x61de814e1cf0 - std::panicking::try::do_call::hf4fa5da1702a7d33 at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/std/src/panicking.rs:559:40 27: 0x61de814e1cf0 - std::panicking::try::h0965acaf2bd52050 at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/std/src/panicking.rs:523:19 28: 0x61de814e1cf0 - std::panic::catch_unwind::h7de95711cd7e4428 at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/std/src/panic.rs:149:14 29: 0x61de814e1cf0 - std::rt::lang_start_internal::{{closure}}::hb1d2daa487425280 at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/std/src/rt.rs:141:48 30: 0x61de814e1cf0 - std::panicking::try::do_call::hd59af035bb5532e5 at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/std/src/panicking.rs:559:40 31: 0x61de814e1cf0 - std::panicking::try::h5c744d815e99837d at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/std/src/panicking.rs:523:19 32: 0x61de814e1cf0 - std::panic::catch_unwind::hef381c98182948e1 at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/std/src/panic.rs:149:14 33: 0x61de814e1cf0 - std::rt::lang_start_internal::ha4d5687999a05b44 at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/std/src/rt.rs:141:20 34: 0x61de7f2024da - std::rt::lang_start::h5d6cfae3f9686cc6 at /rustc/c987ad527540e8f1565f57c31204bde33f63df76/library/std/src/rt.rs:158:17 35: 0x61de7f1a27fe - main 36: 0x735de382a1ca - 37: 0x735de382a28b - libc_start_main 38: 0x61de7f17c9e5 - _start 39: 0x0 -

charleywright commented 4 months ago

This is expected for now, pineapple is still in development and I've run into this bug myself a few times. I'll get around to fixing it sometime but if you're comfortable with rust feel free to diagnose it yourself and open a PR.

The reason for this error is how the FIFO is implemented. The main thread which runs the proxy sends any data it has to a channel: https://github.com/charleywright/spotify-analyze-v2/blob/8fbe7a261722750d9ebe8db21bc3f8e57228489f/pineapple/src/proxy/pcap.rs#L253-L256

This will fail if the receiving end of the channel has hung up (Drop is called on Receiver) which is my guess for the cause of this. The Receiver is owned by the FIFO thread which just runs the fifo_thread function: https://github.com/charleywright/spotify-analyze-v2/blob/8fbe7a261722750d9ebe8db21bc3f8e57228489f/pineapple/src/proxy/pcap.rs#L134

You could try to reproduce with RUST_LOG=debug set as an environment variable, that should make it clear if the thread is exiting before it should causing the Receiver to be dropped.

charleywright commented 4 months ago

This bug may be fixed by https://github.com/charleywright/spotify-analyze-v2/commit/5b890961a6d230418326548248b9fd1caf8361dc which handles an error when the proxy is trying to write data while Wireshark is opening. Before this commit the FIFO thread would exit which could cause the broken channel error you are seeing.

EDIT: If you test this commit, make sure to run the proxy with -vv, this will enable all logging and should help narrow down the error e.g. cargo run -- listen -vv