Jump to content
Excelsior Forums

XFunction clamscan crashes tomcat

Recommended Posts

Hi ,

Im evaluating xfunction library for scanning virus during upload using the clamscan libclamav shared library . The clamscan lib is loaded properly only once and the file is scanned for virus. 2nd time i try to scan for the virus - the xfunction crashed tomcat/jvm .Im using JDK 1.4_02

Here is the error log - generated by the JVM crash

An unexpected exception has been detected in native code outside the VM.

Unexpected Signal : 11 occurred at PC=0x4E51B432



Current Java thread:

       at com.excelsior.xFunction.xFunction.callFunc(Native Method)

       at com.excelsior.xFunction.xFunction.invoke(xFunction.java:120)

       at com.excelsior.xFunction.xFunction.invoke(xFunction.java:53)

       at com.smartifacts.upload.UploadToDatabase.scanForVirus(UploadToDatabase.java:703)

       - locked <0x443f75b8> (a com.smartifacts.upload.UploadToDatabase)

       at org.apache.jsp.processfiles_jsp._jspService(processfiles_jsp.java:321)

       at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:137)

       at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

       at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:210)

       at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:295)

       at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:241)

       at javax.servlet.http.HttpServlet.service(HttpServlet.java:853)

       at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:247)

       at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:193)

       at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:256)

I hope this would be sufficient - Its urgent for me since the whole application need to go into production in a couple of days. Only if my evaluation is successful then we can go for a license



Share this post

Link to post
Share on other sites


Unfortunatley, I can't help you without having the example reproducing the bug. Could you possibly send to the support@excelsior-usa.com the example along with the full description of the problem, including the OS version, used software etc. The Non-Disclosure-Agreement may be signed if needed.

Share this post

Link to post
Share on other sites

I am getting the same Exception.  I have tracked it down to being an issue with JNI not specifically xFunction.  The issue is that one of the pointers is not the same size and in the process of derefrencing it tries to access memory that is not allowed.  Or at least that is how I understand it.  My CSTRING in my structure seems to be my problem and I will include my code so that it will be clear.  Please let me know if you know a solution.



An unexpected exception has been detected in native code outside the VM.

Unexpected Signal : EXCEPTION_ACCESS_VIOLATION occurred at PC=0x100011C1



Current Java thread:

       at com.excelsior.xFunction.Argument.derefString(Native Method)

       at com.excelsior.xFunction.SLFieldString.fromByteArray(SLFieldString.jav


       at com.excelsior.xFunction.StructureLayout.fromByteArray(StructureLayout


       at com.excelsior.xFunction.Structure.fromByteArray(Structure.java:28)

       at com.excelsior.xFunction.Argument.getValue(Argument.java:166)

       at com.excelsior.xFunction.Pointer.deref(Pointer.java:30)

       at winApi.main(winApi.java:34)

Dynamic libraries:

0x00400000 - 0x00406000         C:\j2sdk1.4.0_01\bin\java.exe

0x77F80000 - 0x77FFB000         C:\WINNT\System32\ntdll.dll

0x77DB0000 - 0x77E0C000         C:\WINNT\system32\ADVAPI32.dll

0x77E80000 - 0x77F35000         C:\WINNT\system32\KERNEL32.DLL

0x77D30000 - 0x77D9E000         C:\WINNT\system32\RPCRT4.DLL

0x78000000 - 0x78046000         C:\WINNT\system32\MSVCRT.dll

0x6D330000 - 0x6D445000         C:\j2sdk1.4.0_01\jre\bin\client\jvm.dll

0x77E10000 - 0x77E74000         C:\WINNT\system32\USER32.dll

0x77F40000 - 0x77F7C000         C:\WINNT\system32\GDI32.DLL

0x77570000 - 0x775A0000         C:\WINNT\System32\WINMM.dll

0x6D1D0000 - 0x6D1D7000         C:\j2sdk1.4.0_01\jre\bin\hpi.dll

0x6D300000 - 0x6D30D000         C:\j2sdk1.4.0_01\jre\bin\verify.dll

0x6D210000 - 0x6D228000         C:\j2sdk1.4.0_01\jre\bin\java.dll

0x6D320000 - 0x6D32D000         C:\j2sdk1.4.0_01\jre\bin\zip.dll

0x10000000 - 0x10012000         C:\_src\xFunc\xFunction.dll

0x77920000 - 0x77943000         C:\WINNT\system32\imagehlp.dll

0x72A00000 - 0x72A2D000         C:\WINNT\system32\DBGHELP.dll

0x690A0000 - 0x690AB000         C:\WINNT\System32\PSAPI.DLL



import com.excelsior.xFunction.*;

public class winApi


 public static void main(String[] args) throws xFunctionException



     SYSTEMTIME sysTime = new SYSTEMTIME();

     Pointer ptr_sysTime = Pointer.createPointerTo(sysTime);


     xFunction getTime = new xFunction("kernel32", "void GetSystemTime(SYSTEMTIME*)");



     sysTime = (SYSTEMTIME)ptr_sysTime.deref();


     System.out.println("System Time");

     System.out.println("Day " + sysTime.wDayOfWeek + " of the week.");

     System.out.println(sysTime.wMonth + "/" + sysTime.wDay + "/" + sysTime.wYear);

     System.out.println(sysTime.wHour + ":" + sysTime.wMinute + ":" + sysTime.wSecond + "." + sysTime.wMilliseconds);      




     Pointer ptr_osInfo = Pointer.createPointerTo(osInfo);


         xFunction getVersion = new xFunction("kernel32","int GetVersionExA(OSVERSIONINFO*)");

         int result = ( (Integer)getVersion.invoke(ptr_osInfo) ).intValue() ;



         System.out.println("System Information");          



         osInfo = (OSVERSIONINFO)ptr_osInfo.deref();











class OSVERSIONINFO extends Structure


 long dwOSVersionInfoSize;  

 long dwMajorVersion;  

 long dwMinorVersion;  

 long dwBuildNumber;  

 long dwPlatformId;  

 String szCSDVersion;


 public String defineLayout()


   return "long dwOSVersionInfoSize, long dwMajorVersion, long dwMinorVersion, " +

          "long dwBuildNumber, long dwPlatformId, CSTRING szCSDVersion";



 public OSVERSIONINFO() {}



class SYSTEMTIME extends Structure


 short wYear;  

 short wMonth;  

 short wDayOfWeek;  

 short wDay;  

 short wHour;  

 short wMinute;  

 short wSecond;  

 short wMilliseconds;


 public String defineLayout()


   return "short wYear,  short wMonth,  short wDayOfWeek,  short wDay,  short wHour, " +

          "short wMinute,  short wSecond,  short wMilliseconds";



 public SYSTEMTIME() {}





Share this post

Link to post
Share on other sites

In your case the problem is in the declaration of the structure OSVERSIONINFO. It should contain 32-bit 'int' values, not 64-bit 'long'. Please note that in C the types DWORD and long are 32-bit, so they correspond to Java type 'int'.

As a result, the offset of the String to be dereferenced was calculated incorrectly, and dereferencing cause ACCESS VIOLATION.

The correct OSVERSIONINFO structure can be found in sample11.

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now