twitchax / rusty_socks

A super basic SOCKS5 proxy.
MIT License
4 stars 1 forks source link

Crashes using the nordvpn-proxy container #1

Closed bascht closed 4 years ago

bascht commented 4 years ago

Hi @twitchax! I'm opening this issue here, since I can only reproduce it using the twitchax/nordvpn-proxy container and seeing periodic crashes with:


2020-08-21 09:54:56 | thread 'main' panicked at 'index out of bounds: the len is 0 but the index is 0', /rustc/fdc0011561c6365c596dfd8fa1ef388162bc89c7/src/libcore/slice/mod.rs:2797:10 -- | --
2020-08-21 09:54:56 | stack backtrace:
2020-08-21 09:54:56 | 0:     0x5612c509c734 - backtrace::backtrace::libunwind::trace::hc586f95f659e6084
2020-08-21 09:54:56 | at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/libunwind.rs:88
2020-08-21 09:54:56 | 1:     0x5612c509c734 - backtrace::backtrace::trace_unsynchronized::ha9827fdb593fd967
2020-08-21 09:54:56 | at /cargo/registry/src/github.com-1ecc6299db9ec823/backtrace-0.3.40/src/backtrace/mod.rs:66
2020-08-21 09:54:56 | 2:     0x5612c509c734 - std::sys_common::backtrace::_print_fmt::h00c888c95e07165a
2020-08-21 09:54:56 | at src/libstd/sys_common/backtrace.rs:84
2020-08-21 09:54:56 | 3:     0x5612c509c734 - <std::sys_common::backtrace::_print::DisplayBacktrace as core::fmt::Display>::fmt::h8407ffb2d059bc74
2020-08-21 09:54:56 | at src/libstd/sys_common/backtrace.rs:61
2020-08-21 09:54:56 | 4:     0x5612c50bcfdc - core::fmt::write::h4165a12a3856465f
2020-08-21 09:54:56 | at src/libcore/fmt/mod.rs:1024
2020-08-21 09:54:56 | 5:     0x5612c50983a7 - std::io::Write::write_fmt::h499a0566ceaa0048
2020-08-21 09:54:56 | at src/libstd/io/mod.rs:1428
2020-08-21 09:54:56 | 6:     0x5612c509e84e - std::sys_common::backtrace::_print::h05fbb11587298e2b
2020-08-21 09:54:56 | at src/libstd/sys_common/backtrace.rs:65
2020-08-21 09:54:56 | 7:     0x5612c509e84e - std::sys_common::backtrace::print::h8021a3ed2b5ff07e
2020-08-21 09:54:56 | at src/libstd/sys_common/backtrace.rs:50
2020-08-21 09:54:56 | 8:     0x5612c509e84e - std::panicking::default_hook::{{closure}}::hd3a6326f5c6c149f
2020-08-21 09:54:56 | at src/libstd/panicking.rs:193
2020-08-21 09:54:56 | 9:     0x5612c509e541 - std::panicking::default_hook::h7088fb00a0cb1faf
2020-08-21 09:54:56 | at src/libstd/panicking.rs:210
2020-08-21 09:54:56 | 10:     0x5612c509ef2b - std::panicking::rust_panic_with_hook::h6b223bff7721d4c1
2020-08-21 09:54:56 | at src/libstd/panicking.rs:471
2020-08-21 09:54:56 | 11:     0x5612c509eade - rust_begin_unwind
2020-08-21 09:54:56 | at src/libstd/panicking.rs:375
2020-08-21 09:54:56 | 12:     0x5612c50b9bee - core::panicking::panic_fmt::hed15e18c2b62a00c
2020-08-21 09:54:56 | at src/libcore/panicking.rs:82
2020-08-21 09:54:56 | 13:     0x5612c50b9bb5 - core::panicking::panic_bounds_check::h41a98982cc62de71
2020-08-21 09:54:56 | at src/libcore/panicking.rs:60
2020-08-21 09:54:56 | 14:     0x5612c503555b - rusty_socks::helpers::Helpers::get_interface_ip::hbbfcb62cc933fbef
2020-08-21 09:54:56 | 15:     0x5612c503d3c9 - rusty_socks::main::{{closure}}::h2fc8a9ec0604ea62
2020-08-21 09:54:56 | 16:     0x5612c50377dc - <std::future::GenFuture<T> as core::future::future::Future>::poll::hf16790e2626148b9
2020-08-21 09:54:56 | 17:     0x5612c503048e - tokio::runtime::enter::Enter::block_on::h9a7d5f6b756ff292
2020-08-21 09:54:56 | 18:     0x5612c504a630 - std::thread::local::LocalKey<T>::with::h7f16a0e13efb06c6
2020-08-21 09:54:56 | 19:     0x5612c504a2e5 - std::thread::local::LocalKey<T>::with::h1b14be7c72bbc4bd
2020-08-21 09:54:56 | 20:     0x5612c5030626 - tokio::runtime::spawner::Spawner::enter::h9c32e43b322fdaf3
2020-08-21 09:54:56 | 21:     0x5612c5034e15 - tokio::runtime::time::variant::with_default::h92285d8b59c217ee
2020-08-21 09:54:56 | 22:     0x5612c504a4b6 - std::thread::local::LocalKey<T>::with::h3bc945cb76af335e
2020-08-21 09:54:56 | 23:     0x5612c50324a7 - rusty_socks::main::hefb1ec8086c8f848
2020-08-21 09:54:56 | 24:     0x5612c50440c7 - std::rt::lang_start::{{closure}}::h1aaa1cc6a81ef541
2020-08-21 09:54:56 | 25:     0x5612c509e973 - std::rt::lang_start_internal::{{closure}}::h1595fe6caeecd9df
2020-08-21 09:54:56 | at src/libstd/rt.rs:52
2020-08-21 09:54:56 | 26:     0x5612c509e973 - std::panicking::try::do_call::he30f1dd3074e47c0
2020-08-21 09:54:56 | at src/libstd/panicking.rs:292
2020-08-21 09:54:56 | 27:     0x5612c50a274a - __rust_maybe_catch_panic
2020-08-21 09:54:56 | at src/libpanic_unwind/lib.rs:78
2020-08-21 09:54:56 | 28:     0x5612c509f3c0 - std::panicking::try::hf96e32b9e974850c
2020-08-21 09:54:56 | at src/libstd/panicking.rs:270
2020-08-21 09:54:56 | 29:     0x5612c509f3c0 - std::panic::catch_unwind::h6019fde5b359e726
2020-08-21 09:54:56 | at src/libstd/panic.rs:394
2020-08-21 09:54:56 | 30:     0x5612c509f3c0 - std::rt::lang_start_internal::he1a167fa2ebf85bc
2020-08-21 09:54:56 | at src/libstd/rt.rs:51
2020-08-21 09:54:56 | 31:     0x5612c5032562 - main
2020-08-21 09:54:56 | 32:     0x7f4c6a7fc09b - __libc_start_main
2020-08-21 09:54:56 | 33:     0x5612c502018a - _start
2020-08-21 09:54:56 | 34:                0x0 - <unknown>
2020-08-21 09:54:56 | \ \|
``` 

Is there anything I can help to debug this further? :-)
twitchax commented 4 years ago

Looks like a problem with finding the interface (definitely needs a better error message).

What is the docker run command that you are using?

twitchax commented 4 years ago

Oh, it's periodic?

twitchax commented 4 years ago

I just pushed a likely fix, and fixed some of the error handling in the proxy.

bascht commented 4 years ago

Yup, it wasn't a fatal crash, but recurring errors. I ran it via:

docker run -it --rm --cap-add NET_ADMIN --sysctl net.ipv4.conf.all.rp_filter=2 -p 1080:1080 -e USER=… -e PASS='…' -e TECHNOLOGY=NordLynx -e CONNECT=Germany twitchax/nordvpn-proxy

Will re-test – is it fixed in https://hub.docker.com/layers/twitchax/nordvpn-proxy/latest/images/sha256-fdf12b8cab65c71b153d5618e595458a80e1039272f2ce81b510e376692eecd9?context=explore ?

twitchax commented 4 years ago

Recurring errors while the proxy was on? The fix is in that container.

bascht commented 4 years ago

Thanks for the quick reply! No longer reproducable with the latest build!