cascadium / OpenMAMA-zmq

OpenMAMA ZeroMQ Bridge
MIT License
17 stars 8 forks source link

JVM crashes when a publisher is stopped #11

Closed nemacrux closed 8 years ago

nemacrux commented 8 years ago

I'm having an issue with the zmq bridge, for instance I have an app in Java and this app lets to stop and restart a publisher to OpenMama any moment without finish the app. When started, the publisher runs in a thread different to main. Now when I choose to stop the publisher thread the JVM crashes (and the whole app crashes). It seems that the crash is due to a null pointer in the JNI layer but I'm not sure. It was tested with the qpid bridge and its ok, you can start/stop the connection whenever you want (and using any transport) but when you use zmq as middleware and stops the client then happens what I'm reporting.

It is happening in both, windows and ubuntu. This is the environment: Windows 10/java 1.8 x86/OpenMama 2.4.0 x86/zmq bridge x86/ and Ubuntu 14.04/java 1.8/OpenMama 2.4.0/zmq.

I have pushed a repo with an eclipse project that lets to recreate this scenario. You can find it in here

fquinner commented 8 years ago

You can work around this on linux using export LD_PRELOAD=/path/to/libmamazmqimpl.so prior to running the java command. Recreation command (bypassing eclipse) is:

java -cp ../fquinner/OpenMAMA/openmama_install_2.4.0/lib/mamajni.jar:./bin:./libs/slf4j-api-1.7.21.jar com.algocodex.publisher.MsgPublisher

If I comment out the closeSharedLib function (maps to dlclose) function in mama.c the problem goes away, suggesting that something is calling a shared object function or resource after the close, though it's hard to see where.

fquinner commented 8 years ago

Another workaround is to use the default queue rather than the queue group's queue.

nemacrux commented 8 years ago

Hi @fquinner, I have tested using the default queue and it seems to work fine, so many thanks

fquinner commented 8 years ago

Thanks @macrux - closing off.