We use livesplit-hotkey in our rust project and found this weird interaction with Windows Sandbox
When a hook is registered focusing the sandbox or pressing hotkeys will trigger panics.
There first way to trigger the panic:
- run the hook
- focus the sanbox -> will trigger panic
A
- press a hotkey -> will trigger panic
B
Second
- run the hook
- press a hotkey (before focusing the sandbox)
- focus the sandbox
- press a hotkey -> will trigger panic
B
Here's a recording in action: https://share.splamy.de/20/10/Desktop%202020.10.10%20-%2019.19.46.03.mp4
This is a minimal repro, which basically just uses the crate:
pub use livesplit_hotkey::KeyCode;
use livesplit_hotkey::*;
use std::{thread, time};
fn main() {
let hook = Hook::new().unwrap();
hook.register(KeyCode::Scroll, move || {
println!("got key");
})
.unwrap();
let sec = time::Duration::from_secs(1);
loop {
thread::sleep(sec);
}
}
Panic A
thread '<unnamed>' panicked at 'internal error: entered unreachable code', C:\Users\Splamy\.rustup\toolchains\nightly-x86_64-pc-windowsvc\lib/rustlib/src/rust\library\std\src\sync\mpsc\oneshot.rs:167:33
stack backtrace:
0: std::panicking::begin_panic<str*>
at C:\Users\Splamy\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\panicking.rs:505
1: std::sync::mpsc::oneshot::Packet<livesplit_hotkey::windows::key_code::KeyCode>::try_recv<livesplit_hotkey::windows::key_code::Keye>
at C:\Users\Splamy\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sync\mpsc\oneshos:167
2: std::sync::mpsc::oneshot::Packet<livesplit_hotkey::windows::key_code::KeyCode>::recv<livesplit_hotkey::windows::key_code::KeyCode
at C:\Users\Splamy\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sync\mpsc\oneshos:149
3: std::sync::mpsc::Receiver<livesplit_hotkey::windows::key_code::KeyCode>::recv<livesplit_hotkey::windows::key_code::KeyCode>
at C:\Users\Splamy\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\sync\mpsc\mod.rs22
4: livesplit_hotkey::windows::{{impl}}::new::{{closure}}
at C:\Users\Splamy\.cargo\registry\src\github.com-1ecc6299db9ec823\livesplit-hotkey-0.5.0\src\windows\mod.rs:139
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Panic B
thread '<unnamed>' panicked at 'Callback Thread disconnected: "SendError(..)"', C:\Users\Splamy\.cargo\registry\src\github.com-1ecc6299ec823\livesplit-hotkey-0.5.0\src\windows\mod.rs:69:22
ustlib\src\rust\library\core\src\result.rs:933
4: livesplit_hotkey::windows::callback_proc::{{closure}}
at C:\Users\Splamy\.cargo\registry\src\github.com-1ecc6299db9ec823\livesplit-hotkey-0.5.0\src\windows\mod.rs:66
5: std::thread::local::LocalKey<core::cell::RefCell<core::option::Option<livesplit_hotkey::windows::State>>>::try_with<core::cell::RefCell<core::option::Option<livesplit_hotkey::windows::State>>,closure-0,isize>
at C:\Users\Splamy\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\thread\local.rs:272 6: std::thread::local::LocalKey<core::cell::RefCell<core::option::Option<livesplit_hotkey::windows::State>>>::with<core::cell::RefCell<core::option::Option<livesplit_hotkey::windows::State>>,closure-0,isize>
at C:\Users\Splamy\.rustup\toolchains\nightly-x86_64-pc-windows-msvc\lib\rustlib\src\rust\library\std\src\thread\local.rs:248 7: livesplit_hotkey::windows::callback_proc
at C:\Users\Splamy\.cargo\registry\src\github.com-1ecc6299db9ec823\livesplit-hotkey-0.5.0\src\windows\mod.rs:58
8: GetDlgCtrlID
9: CreateSystemThreads
10: KiUserCallbackDispatcher
11: NtUserGetMessage
12: GetMessageW
13: livesplit_hotkey::windows::{{impl}}::new::{{closure}}
at C:\Users\Splamy\.cargo\registry\src\github.com-1ecc6299db9ec823\livesplit-hotkey-0.5.0\src\windows\mod.rs:120
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
error: process didn't exit successfully: `target\debug\bug_livesplit_hotkey.exe` (exit code: 0xc0000409, STATUS_STACK_BUFFER_OVERRUN)
Details:
- Windows 10 Education, 2004 (Build 19041.508)
- livesplit-hotkey crate 0.5.0
- rust 1.49.0-nightly
We use livesplit-hotkey in our rust project and found this weird interaction with Windows Sandbox
When a hook is registered focusing the sandbox or pressing hotkeys will trigger panics.
There first way to trigger the panic:
ABSecond
BHere's a recording in action: https://share.splamy.de/20/10/Desktop%202020.10.10%20-%2019.19.46.03.mp4
This is a minimal repro, which basically just uses the crate:
Panic
APanic
BDetails: