iohook icon indicating copy to clipboard operation
iohook copied to clipboard

[OSX] Application crashes due to deallocated memory access

Open vadimturkov opened this issue 5 years ago • 8 comments

Periodically our application crashes on OSX with logs info provided below.

Expected Behavior

Work without crashing.

Current Behavior

For example, crash log looks like:

`Crashed Thread: 9

Exception type: EXC_BAD_ACCESS(SIGSEV) Exception Codes: KERN_INVALID_ADDRESS at 0x0000010000000022 Exception Note: EXC_CORPSE_NOTIFY

Thread 9 Crashed: 0 iohook.node 0x0000000110fa359d dispatch_proc(_uiohook_event*) + 221 1 iohook.node 0x0000000110fa757d hook_event_proc + 1709 2 com.apple.SkyLight 0x00007fff58f250b4 processDecodedEventRef(__CGEvent*, __CGEventTapProxy*) + 112 3 com.apple.SkyLight 0x00007fff58f2490d processEventTapData(void*, unsigned int, unsigned int, unsigned int, unsigned char*, unsigned int) + 543 4 com.apple.SkyLight 0x00007fff58e23bb2 _XPostEventTapData + 278 5 com.apple.SkyLight 0x00007fff58f24690 eventTapMessageHandler(__CFMachPort*, void*, long, void*) + 132 6 com.apple.CoreFoundation 0x00007fff32eb5a5b __CFMachPortPerform + 246 7 com.apple.CoreFoundation 0x00007fff32eb5959 CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE1_PERFORM_FUNCTION + 41 8 com.apple.CoreFoundation 0x00007fff32eb58b7 __CFRunLoopDoSource1 + 527 9 com.apple.CoreFoundation 0x00007fff32e9d945 __CFRunLoopRun + 2574 10 com.apple.CoreFoundation 0x00007fff32e9cce4 CFRunLoopRunSpecific + 463 11 com.apple.CoreFoundation 0x00007fff32e9caf0 CFRunLoopRun + 40 12 iohook.node 0x0000000110fa8b74 hook_run + 1700 13 iohook.node 0x0000000110fa365e hook_thread_proc(void*) + 14 14 libsystem_pthread.dylib 0x00007fff6012633d _pthread_body + 126 15 libsystem_pthread.dylib 0x00007fff601292a7 _pthread_start + 70 16 libsystem_pthread.dylib 0x00007fff60125425 thread_start + 13`

Possible Solution

I have no idea. It looks like an access to invalid pointers.

Your Environment

  • Version used: 0.4.0
  • Environment name and version (e.g. Chrome 39, node.js 5.4): Chrome 66, Node 10.2.0, Electron 3.1.0
  • Operating System and version (desktop or mobile): OSX 10.14.4

vadimturkov avatar Jun 19 '19 11:06 vadimturkov

I have this same issue in my electron app on close. I have since figured out that I had another event that was causing iohooks not to shut down or even start properly in some occasions.

Another thing I had to do was reboot my OSX Application after granting accessibility permissions. I don't even boot iohooks even if the user grants the application permission. I force a re-start of the application. Apple seems to do some weird stuff under the hood with the accessibility permission.

tance77 avatar Jun 23 '20 21:06 tance77

maybe the same problem:

on window. electron 5.0.11

  • EXCEPTION_ACCESS_VIOLATION_READ * Assertion Error: Unknown assertion type 0x00000000
Crashed Thread: 10784

Application Specific Information:
Assertion Error: Unknown assertion type 0x00000000

Thread 10784 Crashed:
0   iohook.node                     0x5bdc1f2b          <unknown>
1   iohook.node                     0x5bdc26f2          <unknown>
2   XXX.exe                        0x44d2c5f           uv_process_async_wakeup_req (async.c:96)
3   XXX.exe                        0x34cb1d2           uv_run (core.c:519)
4   XXX.exe                        0x34c4e72           atom::NodeBindings::UvRunOnce() (node_bindings.cc:404)
5   XXX.exe                        0x29813bb           base::debug::TaskAnnotator::RunTask(char const *,base::PendingTask *) (task_annotator.cc:105)
6   XXX.exe                        0x29e76d3           base::sequence_manager::internal::ThreadControllerImpl::DoWork(base::sequence_manager::internal::ThreadControllerImpl::WorkType) (thread_controller_impl.cc:209)
7   XXX.exe                        0x1510a32           base::internal::Invoker<base::internal::BindState<void (atom::URLRequestFetchJob::*)(int) __attribute__((thiscall)),base::WeakPtr<atom::URLRequestFetchJob>,net::Error>,void ()>::RunOnce (bind_internal.h:671)

ape-casear avatar Dec 01 '20 11:12 ape-casear

Following up on this. We also found that the new touch bar on OSX is not supported by iohooks. Which would could similar errors as mentioned above.

tance77 avatar Dec 01 '20 16:12 tance77

I confirm the touch bar crashed the app every single time.

michelvermeulen avatar Mar 14 '21 19:03 michelvermeulen

I confirm the touch bar crashed the app every single time.

I fixed it by moving iohook to the renderer process

michelvermeulen avatar Mar 16 '21 09:03 michelvermeulen

It seems that iohook in main process causes lots of issues on mac specifically. Will investigate but touchbar issue is not something I can address.

ash0x0 avatar Jun 11 '21 19:06 ash0x0

Not sure what the status of this issue is, but for me it also crashed if during the lifetime of an Electron app an ioHook event took place. In my case if a mouse drag and mouseup event happened, then when i closed the app it would issue a similar exception. My event handlers are defined in the nodejs main process.

I solved the issue by calling ioHooks.stop(); followed by ioHooks.unload();

Leaving this here in case it helps anyone.

fgheorghe avatar Nov 08 '21 09:11 fgheorghe

Solved with

app.on('quit', () => {
  ioHook.unload();
});

dmatora avatar Nov 06 '22 04:11 dmatora