hcoona / one

The mono-repo for me.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Application crash when io.github.hcoona.concurrent.NamedMutexPosixImpl.waitOne is called

domenicosf opened this issue · comments

Hi guys.
I am using your library in a application that i am a developer.
In the application We have wrapped class with internal attribute of type NamedMutex (we use the newInstance to create the implementation) and in this wrapped class we create a waitOne method thar call the NamedMutexPosixImpl.waitOne original method:

public boolean waitOne(long timeout, TimeUnit unit) {
        boolean acquired = false;
        try {
            //Where mutex is of type NamedMutex
            acquired = mutex.waitOne(timeout, unit);
        } catch (AbandonedMutexException ame) {
            System.out.println(ame.getMessage());
        } catch (IOException ioe) {
            System.out.println(ioe.getMessage());
        } catch (Exception e) {
            System.out.println(e.getMessage());
        }
        if (!acquired) {
            close();
            mutex = createMutex(); //Recreate the mutex using NamedMutex.newInstance method
        }
        return acquired;
    }

We use this code to lock file read/write operations. Sometimes the application crash with the repeated method call waitOne. We are using the following os: Red Hat Enterprise Linux 7 (7.2).
The the usage of method waitOne is crashing the aplication ans always generating a thread dump with the following stack:

J 6744  com.sun.jna.Native.invokeInt(Lcom/sun/jna/Function;JI[Ljava/lang/Object;)I (0 bytes) @ 0x00007f4bc210f329 [0x00007f4bc210f2c0+0x69]
j  com.sun.jna.Function.invoke([Ljava/lang/Object;Ljava/lang/Class;ZI)Ljava/lang/Object;+211
j  com.sun.jna.Function.invoke(Ljava/lang/reflect/Method;[Ljava/lang/Class;Ljava/lang/Class;[Ljava/lang/Object;Ljava/util/Map;)Ljava/lang/Object;+271
J 6620 C1 com.sun.jna.Library$Handler.invoke(Ljava/lang/Object;Ljava/lang/reflect/Method;[Ljava/lang/Object;)Ljava/lang/Object; (348 bytes) @ 0x00007f4bc1ca8d2c [0x00007f4bc1ca6900+0x242c]
j  io.github.hcoona.concurrent.$Proxy68.sem_timedwait(Lcom/sun/jna/Pointer;Lio/github/hcoona/concurrent/Pthread$TimeSpecByReference;)I+20
j  io.github.hcoona.concurrent.NamedMutexPosixImpl.waitOne(JLjava/util/concurrent/TimeUnit;)Z+74

Do anyone face this issue before?

Will try to reproduce it on CentOS 7 in Hyper-V or maybe Docker (docker pull centos:centos7.2.1511).

https://vault.centos.org/