rdev
rdev copied to clipboard
segmentation fault when grab events
I run
cargo run --features="unstable_grab" --example grab
It crash when I keypress.

envs: macos: 10.15.6 rust: 1.49.0-nightly
Did you authorize Terminal ? needs to have accessibility settings enabled (Terminal added in System Preferences > Security & Privacy > Privacy > Accessibility).
Grab is not 100% supported as the name suggests. I'd be happy to pull a patch if you figure it out, but I don't intend to dig into it. (Also I don't have a Mac machine anymore to test this)
@Narsil yep, I authorized Terminal. It works on listen but crash when changing to CGEventType::Null.
I think it should return NULL instead of cg_event.set_type(CGEventType::Null).
Can you make a PR ?
I'm unable to replicate the issue described here. My environment: MacOS: 10.15.7 Rust: 1.52.1
When I run the example without Accessibility API access, it immediately exits with a "Error: EventTapError" message When i run it with Accessibility API access, it works as expected, no segfaults.
either Apple fixed whatever bug rdev was surfacing, or the bug had something to do with rust nightly.
@jimliang are you able to test either hypothesis and confirm?
The program crashes when I press the keyboard.
I try to use lldb --file target/debug/examples/grab to get more information:
Process 33648 stopped
* thread #1, queue = 'com.apple.main-thread', stop reason = EXC_BAD_ACCESS (code=1, address=0x0)
frame #0: 0x00007fff325235de CoreFoundation`CFDataGetBytePtr + 6
CoreFoundation`CFDataGetBytePtr:
-> 0x7fff325235de <+6>: movq (%rdi), %rax
0x7fff325235e1 <+9>: testq %rax, %rax
0x7fff325235e4 <+12>: je 0x7fff32523611 ; <+57>
0x7fff325235e6 <+14>: leaq 0x57a157bb(%rip), %rcx ; __CFConstantStringClassReferencePtr
Target 0: (grab) stopped.