load_wait crash when copying from chrome address bar
wrvsrx opened this issue · 1 comments
wrvsrx commented
Reproduce
- compile and run following script with RUST_BACKTRACE=1:
use x11_clipboard::Clipboard;
fn main() {
let clipboard = Clipboard::new().unwrap();
loop {
let val = clipboard
.load_wait(
clipboard.setter.atoms.clipboard,
clipboard.setter.atoms.utf8_string,
clipboard.setter.atoms.property
)
.unwrap();
println!("{}", val.len());
let val = String::from_utf8(val).unwrap();
println!("{}", val);
}
}
- copy from chrome address bar
- It crashes with following information:
23
https://www.google.com/
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: UnexpectedType(0)', src/main.rs:12:14
stack backtrace:
0: rust_begin_unwind
1: core::panicking::panic_fmt
2: core::result::unwrap_failed
3: core::result::Result<T,E>::unwrap
at /build/rustc-1.65.0-src/library/core/src/result.rs:1107:23
4: x11_test::main
at ./src/main.rs:6:19
5: core::ops::function::FnOnce::call_once
at /build/rustc-1.65.0-src/library/core/src/ops/function.rs:248:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Reason
Google chrome has a strange behavior: it send xcb_xfixes_selection_notify_event_t twice when coping from address bar. Therefore loop in process_event
meet XfixesSelectionNotify (
Line 182 in 6d850c0
convert_selection
twice (Line 183 in 6d850c0
Fix
After get XfixesSelectionNotify
, only wait for SelectionNotify
and PropertyNotify
.
Maybe I can make a PR later.
quininer commented
This is not a crash, load_wait returns an error as expected.
The crate is in a maintenance state and I am not willing to make behavior change.