iohook: Built electron binary crashes with segfault
Expected Behavior
Current Behavior
strace binaryName
poll([{fd=46, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=46, revents=POLLOUT}])
writev(46, [{iov_base="\20\1\6\0\20\0\0\0SCREEN_RESOURCES", iov_len=24}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 24
poll([{fd=46, events=POLLIN}], 1, -1) = 1 ([{fd=46, revents=POLLIN}])
recvmsg(46, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\1\0\t\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 32
uname({sysname="Linux", nodename="x-Lenovo-ideapad-530S-15IKB", ...}) = 0
openat(AT_FDCWD, "/home/x/.Xdefaults-x-Lenovo-ideapad-530S-15IKB", O_RDONLY) = -1 ENOENT (No such file or directory)
access("/home/x/en_US.UTF-8/libuiohook-color", R_OK) = -1 ENOENT (No such file or directory)
access("/home/x/en/libuiohook-color", R_OK) = -1 ENOENT (No such file or directory)
access("/home/x/libuiohook-color", R_OK) = -1 ENOENT (No such file or directory)
access("/home/x/en_US.UTF-8/libuiohook", R_OK) = -1 ENOENT (No such file or directory)
access("/home/x/en/libuiohook", R_OK) = -1 ENOENT (No such file or directory)
access("/home/x/libuiohook", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/X11/en_US.UTF-8/app-defaults/libuiohook", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/X11/en/app-defaults/libuiohook", R_OK) = -1 ENOENT (No such file or directory)
access("/usr/lib/X11/app-defaults/libuiohook", R_OK) = -1 ENOENT (No such file or directory)
access("/etc/X11/en_US.UTF-8/app-defaults/libuiohook-color", R_OK) = -1 ENOENT (No such file or directory)
access("/etc/X11/en/app-defaults/libuiohook-color", R_OK) = -1 ENOENT (No such file or directory)
access("/etc/X11/app-defaults/libuiohook-color", R_OK) = -1 ENOENT (No such file or directory)
access("/etc/X11/en_US.UTF-8/app-defaults/libuiohook", R_OK) = -1 ENOENT (No such file or directory)
access("/etc/X11/en/app-defaults/libuiohook", R_OK) = -1 ENOENT (No such file or directory)
access("/etc/X11/app-defaults/libuiohook", R_OK) = -1 ENOENT (No such file or directory)
poll([{fd=45, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=45, revents=POLLOUT}])
writev(45, [{iov_base="\207\27\5\0\0\1\377\0\377\0\0\0\0\0\0\0\0\0\0\0", iov_len=20}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 20
poll([{fd=45, events=POLLIN}], 1, -1) = 1 ([{fd=45, revents=POLLIN}])
recvmsg(45, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\1\3\7\0\371\f\0\0\10\377\0\0\177\0\377\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 4096
recvfrom(45, "k\377\10\20\0\0\0\0\1\1\1\0m\377\10\20\0\0\0\0\1\1\1\0h\377\0\0\0\0\0\0"..., 9220, 0, NULL, NULL) = 9220
poll([{fd=45, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=45, revents=POLLOUT}])
writev(45, [{iov_base="\21\27\2\0w\2\0\0", iov_len=8}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 8
poll([{fd=45, events=POLLIN}], 1, -1) = 1 ([{fd=45, revents=POLLIN}])
recvmsg(45, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\1\0\10\0\6\0\0\0\25\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0"..., iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 56
poll([{fd=45, events=POLLIN|POLLOUT}], 1, -1) = 1 ([{fd=45, revents=POLLOUT}])
writev(45, [{iov_base="\207\10\7\0\0\1\7\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0\0", iov_len=28}, {iov_base=NULL, iov_len=0}, {iov_base="", iov_len=0}], 3) = 28
poll([{fd=45, events=POLLIN}], 1, -1) = 1 ([{fd=45, revents=POLLIN}])
recvmsg(45, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="\1\3\t\0E\5\0\0\0\0\10\377\7\0\0\34\34\10k\1\370\0\0\0\0\0\0\0\0\0\0\10"..., iov_len=4096}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 4096
recvfrom(45, "\0\0\0\0\1\1\1\0h\377\0\0\0\0\0\0\1\1\1\0X\377\10\20\0\0\0\0\1\1\1\0"..., 1332, 0, NULL, NULL) = 1332
munmap(0x7f823cb05000, 92573) = 0
--- SIGSEGV {si_signo=SIGSEGV, si_code=SI_KERNEL, si_addr=NULL} ---
+++ killed by SIGSEGV (core dumped) +++
Possible Solution
Steps to Reproduce (for bugs)
Sorry for report without data, just want to get some help on parsing segfault
Context
Your Environment
- Version used:
- Environment name and version (e.g. Chrome 39, node.js 5.4): electron 8,
- Operating System and version (desktop or mobile): desktop Ubuntu 20.04
- Link to your project:
About this issue
- Original URL
- State: open
- Created 4 years ago
- Comments: 21 (2 by maintainers)
Yea sure sounds good, I think just need to change package.json to not use the local iohook.
Yes I have a working example here: https://github.com/abacaj/iohook-sample
You can see what I changed here: https://github.com/abacaj/iohook-sample/commit/0094c4c3e733337f5733d80f1cb6360b86c2535f
If you
yarn install
and thenyarn start
, you should be able to see clicks logged in the console output.It looks like we can keep those options and run iohook in
preload.js
exposing it to renderer using context bridge (my app didn’t crash when doing this).The only piece required is:
app.allowRendererProcessReuse = false;
which will be deprecated as you mentioned.I’m not as proficient in c/c++ so would take me ages to migrate to napi / troubleshoot the bad access error.
The reason I couldn’t replicate this is because I’ve been using iohook in renderer. I can replicate with your example now. There are so many issues on all platforms in main process that it’s probably worth avoiding using it in main for now. The workaround to get you working is to use iohook in renderer and make sure to set both
nodeIntegration:true
andcontextIsolation: false
. I recommend you do this for now because this seems to be an issue inlibuiohook
(seems like a memory access bug when unloading) that’s avoided when running in renderer. Fix for this will come right after I fix build and install (which is up next on the agenda), that’s when I’ll get to all thelibuiohook
bugs and start working with upstream.Exactly