rdev: Panic on macOS 12 when key pressed

Environment

❯ rustc --version
rustc 1.63.0 (4b91a6ea7 2022-08-08)
❯ sw_vers
ProductName:    macOS
ProductVersion: 12.6
BuildVersion:   21G115

How to reproduce

Run example code put in README:

fn main() {
  if let Err(error) = listen(callback) {
    println!("Error: {:?}", error)
  }

  fn callback(event: Event) {
    println!("My callback {:?}", event);
    match event.name {
      Some(string) => println!("User wrote {:?}", string),
      None => (),
    }
  }
}

Press any key.

Program exits with code 139 (segmentation fault).

My callback Event { time: SystemTime { tv_sec: 1665994839, tv_nsec: 390045000 }, name: None, event_type: MouseMove { x: 710.1378173828125, y: 51.1708984375 } }
My callback Event { time: SystemTime { tv_sec: 1665994839, tv_nsec: 397934000 }, name: None, event_type: MouseMove { x: 710.1378173828125, y: 50.5587158203125 } }
My callback Event { time: SystemTime { tv_sec: 1665994839, tv_nsec: 406208000 }, name: None, event_type: MouseMove { x: 710.4036865234375, y: 50.29290771484375 } }
My callback Event { time: SystemTime { tv_sec: 1665994839, tv_nsec: 413942000 }, name: None, event_type: MouseMove { x: 710.4036865234375, y: 50.027099609375 } }
My callback Event { time: SystemTime { tv_sec: 1665994839, tv_nsec: 421406000 }, name: None, event_type: MouseMove { x: 710.4036865234375, y: 49.76129150390625 } }
My callback Event { time: SystemTime { tv_sec: 1665994839, tv_nsec: 430607000 }, name: None, event_type: MouseMove { x: 710.4036865234375, y: 49.49577331542969 } }
My callback Event { time: SystemTime { tv_sec: 1665994839, tv_nsec: 437597000 }, name: None, event_type: MouseMove { x: 710.4036865234375, y: 49.22996520996094 } }
My callback Event { time: SystemTime { tv_sec: 1665994839, tv_nsec: 477605000 }, name: None, event_type: ButtonPress(Left) }
My callback Event { time: SystemTime { tv_sec: 1665994839, tv_nsec: 560937000 }, name: None, event_type: ButtonRelease(Left) }
My callback Event { time: SystemTime { tv_sec: 1665994839, tv_nsec: 560983000 }, name: None, event_type: MouseMove { x: 710.4036865234375, y: 48.609344482421875 } }
zsh: segmentation fault ./reproducer
❯ echo $?
139

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 17 (4 by maintainers)

Most upvoted comments

tauri Pressing the keyboard listener in the middle of the program will cause the program to crash.

@Narsil Please has the version that fixes this problem been released? I think the latest version 0.5.2 is not fixed

just in case, be sure you arent accessing the data from a different thread. I think accessing keystrokes needs to be done on the main thread, which is a huge pain.

I found how to reproduce it.

An important context: Using CJK input method.

If I use ABC input method, rdev works well. macOS may handle CJK input methods differently.