FULL PRODUCT VERSION :
java version "1.7.0_25"
Java(TM) SE Runtime Environment (build 1.7.0_25-b15)
Java HotSpot(TM) 64-Bit Server VM (build 23.25-b01, mixed mode)
ADDITIONAL OS VERSION INFORMATION :
CentOS release 5.2 (Final)
A DESCRIPTION OF THE PROBLEM :
I use apache-tomcat-7.0.52 container to run run my application (.war file) which uses c++ native libraries. I should be able to upgrade my war file without shutting down tomcat (which may run multiple such applications). Each time my war file is copied to the apache-tomcat-7.0.52/webapps folder it loads new version of my c++ dll, thus to be able to load new version of this dll I have to unload old library from java.exe first. To make old library unload work properly I have to use Custom Class loader so that it gets garbage collected when one removes .war file from webapps. When class loader is garbage collected by dll gets unloaded from java.exe and I can load new dll to the process during upgrade of war file. The problem is that I see sporadic crashes during this unloading process. My investigation shows that problem rises when JNI_OnUnload gets called before Java_com_sun_jna_Native_close is called. If JNI_OnUnload is called before Java_com_sun_jna_Native_close, program tries to find Java_com_sun_jna_Native_close symbol using an invalid handle (as JNI_OnUnload has already been called). Thus dlsym crashes the application.
REPRODUCIBILITY :
This bug can be reproduced occasionally.