suraj0208/jnativehook

crash jvm

Closed this issue · 14 comments

What steps will reproduce the problem?
1.
2.
3.

What is the expected output? What do you see instead?


What version of the product are you using? On what operating system?


Please provide any additional information below.


Original issue reported on code.google.com by munikant...@gmail.com on 5 Feb 2014 at 11:56

I need more information.  Please provide information about what you were doing 
to cause the crash.  The operating system it occurred on and the crash log that 
was written to the jar location after it crashed.

Original comment by a...@1stleg.com on 5 Feb 2014 at 6:12

  • Changed state: Invalid
I am using jNativeHook version 1.14 in JavaFx application on Linux Fedora 14 
and when jvm crash the log get written in hs_err_pid<processId>.log file like 
the following. Due to too long log detail file I have attached the log file :

#
# A fatal error has been detected by the Java Runtime Environment:
#
#  SIGSEGV (0xb) at pc=0x00840e58, pid=2114, tid=2694839152
#
# JRE version: Java(TM) SE Runtime Environment (7.0_51-b13) (build 1.7.0_51-b13)
# Java VM: Java HotSpot(TM) Client VM (24.51-b03 mixed mode linux-x86 )
# Problematic frame:
# C  [libc.so.6+0x2fe58]  exit+0x38
#
# Failed to write core dump. Core dumps have been disabled. To enable core 
dumping, try "ulimit -c unlimited" before starting Java again
#
# If you would like to submit a bug report, please visit:
#   http://bugreport.sun.com/bugreport/crash.jsp
# The crash happened outside the Java Virtual Machine in native code.
# See problematic frame for where to report the bug.
#

---------------  T H R E A D  ---------------
---------------  T H R E A D  ---------------

Current thread (0xa0a8d800):  JavaThread "JNativeHook Native Hook" 
[_thread_in_native, id=2306, stack(0xa01ff000,0xa0a00000)]

siginfo:si_signo=SIGSEGV: si_errno=0, si_code=1 (SEGV_MAPERR), 
si_addr=0x126d5ac8

Registers:
EAX=0x009a13b0, EBX=0x0099fff4, ECX=0x126d5ac8, EDX=0x09a13b00
ESP=0xa09fde20, EBP=0xa09fde58, ESI=0x08cc1fd0, EDI=0x00000001
EIP=0x00840e58, EFLAGS=0x00210202, CR2=0x126d5ac8

Top of Stack: (sp=0xa09fde20)
0xa09fde20:   00f762e0 00000001 094333c8 00828460
0xa09fde30:   06f82e10 0906e918 a09fde58 06f544cd
0xa09fde40:   094333c8 002cd34c 00840e2b 002cd34c
0xa09fde50:   09432810 00000000 a09fde78 001d4d63
0xa09fde60:   00000001 008026a0 00000000 001d4d0a
0xa09fde70:   002cd34c 09432810 a09fded8 001dc6c0
0xa09fde80:   09432810 00000000 a09fdebc 0099fff4
0xa09fde90:   a1800010 00000008 00000902 0099fff4 


Original comment by munikant...@gmail.com on 11 Feb 2014 at 1:49

Attachments:

I used jNativeHook version 1.14 in JavaFx application on Linux Fedora 14 to 
capture mouse click and keystroke for every interval of 9-10 minute  

Original comment by munikant...@gmail.com on 11 Feb 2014 at 1:52

Thanks for the error log, can you test version 1.2.0 and see if the error still 
occurs?  Version 1.1 was shipped without debugging symbols so I would either 
need some test code to reproduce the problem or have you reproduce the issue 
using the attached jar file and post the log file it generates.  

Original comment by a...@1stleg.com on 11 Feb 2014 at 4:59

  • Changed state: New

Attachments:

Thanks for your quick reply. I am testing using your attached jar and will post 
error log if there is any generated there after.

Original comment by munikant...@gmail.com on 12 Feb 2014 at 8:53

I have tested with your attached jar file and my application run fine for some 
couple of time say 4-5 hours in Linux Fedora 14 and after that my application 
get close or exit automatically. I was unable to get error.log file.

I also tested my application by removing the functionality of jNativeHook i.e 
without jNativeHook my application run fine. And even others application 
running does not get slow and begin to consume less memory.

Original comment by munikant...@gmail.com on 13 Feb 2014 at 12:27

The same application using jNativeHook 1.1.4 are working fine windows OS and 
Mac OS

I have not tested yet using jNativeHook 2 .

Original comment by munikant...@gmail.com on 13 Feb 2014 at 12:39

I believe the problem you are experiencing was inadvertently addressed by some 
refactoring done in version 1.2.

Original comment by a...@1stleg.com on 15 Feb 2014 at 5:46

  • Changed state: Accepted
Hi, today I run a simple java program which counting Keystroke and Mouse click 
using jNativeHook 1.1.4 in Linux Fedora 14 having RAM 1GB and 2GB swap memory. 
The program run find for about 7-8 hrs and after the program exit showing the 
following exception

Error: Cannot perform realloc

Is this due to the low memory of my system because I was running numbers of 
other application simultaneously Or it is some native issue in jNativeHook.

Please help me

Original comment by munikant...@gmail.com on 24 Feb 2014 at 1:16

My java program is under the following. I will be very appreciate if you help 
me. 

package com.main;

import java.io.File;
import java.util.Timer;
import java.util.TimerTask;
import java.util.logging.FileHandler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.logging.SimpleFormatter;

import org.jnativehook.GlobalScreen;
import org.jnativehook.NativeHookException;
import org.jnativehook.keyboard.NativeKeyEvent;
import org.jnativehook.keyboard.NativeKeyListener;
import org.jnativehook.mouse.NativeMouseEvent;
import org.jnativehook.mouse.NativeMouseListener;


public class JnativeApp implements NativeKeyListener, NativeMouseListener {

    public volatile int keyStrokeCount;
    public volatile int mouseClickCount;
    public static Logger logger;
    private final String APP_DIRECTORY = "JnativeApp";
    private final String APP_LOG = "JnativeApp.log";
    public FileHandler fh;
    public Timer timer;
    public int constantsMax = 100;
    public int constantsMin= 90;

    public static void main(String s[]){
        System.out.println("started");
        logger = Logger.getLogger(JnativeApp.class.getName());
        new JnativeApp().startApp();

    }

    public void startApp()  {

        try{
            final long tmp_minuteChunk = (long) (Math.floor(Math.random()
                    * (1 +  - constantsMax) + constantsMin) * 60);




            // Logger

            String currentDir = System.getProperty("user.home");
            File homeDir = new File(currentDir + File.separator + APP_DIRECTORY);
            homeDir.mkdir();

            File settingFile = new File(homeDir.getAbsolutePath() + File.separator + APP_LOG);
            settingFile.createNewFile();
            String loggerFile = homeDir.getAbsolutePath() + File.separator  + APP_LOG;
            fh = new FileHandler(loggerFile, true);
            logger.addHandler(fh);
            logger.setLevel(Level.ALL);
            SimpleFormatter formatter = new SimpleFormatter();
            fh.setFormatter(formatter);

            // the following statement is used to log any messages
            logger.log(Level.FINE, "Log of JnativeApp is starting ");

            timer = new java.util.Timer();

            timer.schedule(new TimerTask() {
                public void run() {
                    logger.log(Level.FINE, "Timer stated ::: " + tmp_minuteChunk );
                    mouseClickCount = 0;
                }
            }, (tmp_minuteChunk));

            logger.log(Level.FINE,"captureKeyMouseStroke Starting ...");
            GlobalScreen.getInstance().addNativeKeyListener(this);
            GlobalScreen.getInstance().addNativeMouseListener(this);


            try {
                GlobalScreen.registerNativeHook();
            } catch (NativeHookException e) {
                logger.log(Level.WARNING,"RegisterNativeHook Error :" + e);
                e.printStackTrace();
            }
//          while(true){}
        }catch (Exception e){logger.log(Level.WARNING, "Exception :: "+ e);}


        System.out.println("Ended ::");
    }

    @Override
    public void nativeMouseClicked(NativeMouseEvent arg0) {
        // TODO Auto-generated method stub

    }

    @Override
    public void nativeMousePressed(NativeMouseEvent arg0) {
        // TODO Auto-generated method stub

    }

    @Override
    public void nativeMouseReleased(NativeMouseEvent arg0) {
        // TODO Auto-generated method stub
        mouseClickCount++;
//      System.out.println(mouseClickCount);
        logger.log(Level.FINE, "Mouse click count :: "+ mouseClickCount);
    }

    @Override
    public void nativeKeyPressed(NativeKeyEvent arg0) {
        // TODO Auto-generated method stub
        keyStrokeCount++;
//      System.out.println(keyStrokeCount);
        logger.log(Level.FINE, "Keystroke count :: "+ keyStrokeCount);

    }

    @Override
    public void nativeKeyReleased(NativeKeyEvent arg0) {
        // TODO Auto-generated method stub


    }

    @Override
    public void nativeKeyTyped(NativeKeyEvent arg0) {
        // TODO Auto-generated method stub

    }
}

Original comment by munikant...@gmail.com on 24 Feb 2014 at 1:30

Error: Cannot perform realloc is definitely caused by running out of 
memory/swap.  The original error described is fixed in 1.2

Original comment by a...@1stleg.com on 24 Feb 2014 at 5:57

I will be posting version 1.2.0 Beta2 in the coming days.

Original comment by a...@1stleg.com on 21 Mar 2014 at 6:27

  • Changed state: Fixed
[deleted comment]
Hi Remi,

I assume you located the Beta2 download on GitHub because you deleted your 
comment?  Just in case you can find it here 
https://github.com/kwhat/jnativehook/releases/tag/v1.2.0-Beta2

If you would like a nightly, just send me an email directly and I will run it 
through the cross compiler for you.  I eventually plan to get nightlies 
automatically posted somewhere for download.

Original comment by a...@1stleg.com on 5 Jun 2014 at 4:41