hcoona / one

The mono-repo for me.
GNU General Public License v3.0
9 stars 3 forks source link

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

Open domenicosf opened 3 years ago

domenicosf commented 3 years ago

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?

hcoona commented 2 years ago

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

https://vault.centos.org/