Closed pepperonas closed 8 years ago
Hi,
The stack trace provided is not particularly helpful. I suspect the issue causing the segfault is some indirect process. Do you have some code you can provide to duplicate the problem? Can you setup a simple demo app?
Thanks.
Thanks for the donation. I took a look at the sample app, and after removing the comment on initNativeHook and it appears to work on my System. Does it crash for you when you run Main in InteliJ? What flavor of Linux are you using? Try running ldd /tmp/libJNativeHook-2.0.3.so
after your app and paste the output here.
Hey, sorry for answering late. I am running Mint 17.1 (64bit, i7 4790k ~4.4GHz, 32GB RAM at 1800MHz). Yes, the Main crashes in in IntelliJ and also when I set up a artifact and run the .jar.
The last time I faced this issue with an other app on my machine, the error was raised by this: After invoking a button's default action (pressing 'Enter') the dialog, which contained, the button should be closed. In Windows (tested for 7, 8 and 10) the code was working 100% reliable, but running the same code in Linux forces the app to close about 8 of 10 times. So the app crashed directly after the Enter-Key is pressed. My suggestion: The error came up from a faster execution in Linux (or a different behavior in terms of managing the UI-thread(s)). Maybe the problem was that the dialog was closed nearly instantaneously while the action (aka pressing Enter) is still in a triggered state (only in Linux). The reason what makes me suggesting this is the fact the error could be fixed by calling the stage.close() in a new thread (Platform.runLater()). I'm not a professional in JavaFX but this is the only thing what makes sense to me.
The next thing which is weird: When I debug (stepping through) the current app (the clipboard-manager) it would not crash, only when it runs as a "release"..
I will take a look into your lib later, maybe it works too fast? I also tried your native hook with the common JavaFX stuff on my machine and there is no issue at all, everything works as expected, only when AWT is included things get mad (but mixing FX with AWT isnt recommended if I remember correctly).
What you are describing sounds like a thread safety issue. You should be able to avoid that by using something like GlobalScreen.setEventDispatcher(new SwingDispatchService())
See: https://github.com/kwhat/jnativehook/wiki/Swing
I looked over your code and you are indeed mixing Awt with non-awt threading in the example at Point p = MouseInfo.getPointerInfo().getLocation();
and probably elsewhere in the codebase. Try the above before registering the hook example and see if it fixes your segfault.
The JVM crashed in the "AWT-EventQueue-0" JavaThread which is also confirmed by the stack trace below.
Java Threads: ( => current thread )
0x00007f8dd001d800 JavaThread "JNativeHook Dispatch Thread" daemon [_thread_blocked, id=22416, stack(0x00007f8e41616000,0x00007f8e41717000)]
0x00007f8de82c3800 JavaThread "JNativeHook Hook Thread" [_thread_in_native, id=22415, stack(0x00007f8e41717000,0x00007f8e41818000)]
0x00007f8de819c000 JavaThread "Thread-5" daemon [_thread_blocked, id=22414, stack(0x00007f8e42967000,0x00007f8e42a68000)]
=>0x00007f8de8199800 JavaThread "AWT-EventQueue-0" [_thread_in_native, id=22412, stack(0x00007f8e42a68000,0x00007f8e42b69000)]
Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
j sun.awt.X11.XlibWrapper.XGetDefault(JLjava/lang/String;Ljava/lang/String;)Ljava/lang/String;+0
j sun.awt.X11.XToolkit.initializeMultiClickTime()V+12
j sun.awt.X11.XToolkit.getMultiClickTime()I+6
j sun.awt.X11.XToolkit.initializeDesktopProperties()V+82
j java.awt.Toolkit.getDesktopProperty(Ljava/lang/String;)Ljava/lang/Object;+32
j sun.awt.X11.XToolkit.isRightMouseButton(Ljava/awt/event/MouseEvent;)Z+6
j sun.awt.X11.XBaseMenuWindow.doHandleJavaMouseEvent(Ljava/awt/event/MouseEvent;)V+8
j sun.awt.X11.XPopupMenuPeer.handleEvent(Ljava/awt/AWTEvent;)V+93
j sun.awt.X11.XBaseMenuWindow$3.run()V+8
j java.awt.event.InvocationEvent.dispatch()V+47
j java.awt.EventQueue.dispatchEventImpl(Ljava/awt/AWTEvent;Ljava/lang/Object;)V+21
j java.awt.EventQueue.access$500(Ljava/awt/EventQueue;Ljava/awt/AWTEvent;Ljava/lang/Object;)V+3
Did the dispatcher resolve the segfault?
I am going to close this, please reopen if there is an update.
Hello Alex, thanks for your library, it's really awesome. At the moment I struggle when I try to use your native hook in JavaFX. My app has a little uncommon setup.. My app uses JavaFX for the main GUI-part but also includes the AWT system tray. When I press the system tray the app will crash with the below log-file. I had a similiar issue with a button sometime ago, at that time the issue was caused by a missing "Platform.runLater(...)". When I uncomment the code where I register the native hook, my app runs without the issue.
Here is the complete log, maybe you can read something out of it..