Closed
Description
Hello, I got thread panicked
when running adapter.get_config()
I'm using Windows 11 and rustc 1.77.1 (7cf61ebde 2024-03-27)
Maybe similar to this issue?
Here's the stacktrace:
thread '<unnamed>' panicked at library\std\src\time.rs:433:33:
overflow when subtracting duration from instant
stack backtrace:
0: std::panicking::begin_panic_handler
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\panicking.rs:647
1: core::panicking::panic_fmt
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\core\src\panicking.rs:72
2: core::panicking::panic_display
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\core\src\panicking.rs:196
3: core::panicking::panic_str
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\core\src\panicking.rs:171
4: core::option::expect_failed
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\core\src\option.rs:1988
5: core::option::Option::expect
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\core\src\option.rs:894
6: std::time::impl$3::sub
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97/library\std\src\time.rs:434
7: wireguard_nt::adapter::Adapter::get_config
at C:\Users\name\.cargo\registry\src\mirrors.tuna.tsinghua.edu.cn-2eab394af869c8a2\wireguard-nt-0.3.0\src\adapter.rs:576
8: my_code::wg_connect::closure$0
at .\src\main.rs:191
9: core::hint::black_box
at /rustc/7cf61ebde7b22796c69757901dd346d0fe70bd97\library\core\src\hint.rs:334
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Related part of my code:
let _thread = std::thread::spawn(move || {
std::thread::sleep(Duration::from_secs(1));
'outer: loop {
for _ in 0..5 {
if stop.load(Ordering::Relaxed) {
drop(adapter);
break 'outer;
}
std::thread::sleep(Duration::from_millis(200));
}
let stats = adapter.get_config(); //*** Line 191 ***
for peer in stats.peers {
//let handshake_age = Instant::now().saturating_duration_since(peer.last_handshake);
let handshake_age = Duration::from_secs(0);
window
.emit(
"wg-statistics",
WgStatistics {
up: peer.tx_bytes,
down: peer.rx_bytes,
handshake_age: handshake_age.as_secs(),
},
)
.unwrap();
println!(
" {:?}, up: {}, down: {}, handshake: {:.1}s ago",
peer.allowed_ips,
peer.tx_bytes,
peer.rx_bytes,
handshake_age.as_secs()
);
}
}
});
Metadata
Metadata
Assignees
Labels
No labels