rdev icon indicating copy to clipboard operation
rdev copied to clipboard

segmentation fault when grab events

Open jimliang opened this issue 5 years ago • 5 comments

I run

cargo run --features="unstable_grab" --example grab

It crash when I keypress.

image

envs: macos: 10.15.6 rust: 1.49.0-nightly

jimliang avatar Nov 12 '20 07:11 jimliang

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 avatar Nov 12 '20 08:11 Narsil

@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).

jimliang avatar Nov 16 '20 03:11 jimliang

Can you make a PR ?

Narsil avatar Nov 16 '20 07:11 Narsil

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?

alextremblay avatar Jun 04 '21 18:06 alextremblay

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.

jimliang avatar Sep 22 '21 09:09 jimliang