title: Java: app crashes during connecting GSM USB modem
body: <p>I am working on an open-source application called FrontlineSMS which can be interfaced with GSM modems to send and receive SMS. The windows installer that is available through their website works fine. Since i wanted to modify it, I got the source code and built the jar and tried to launch it. When I plug in the GSM modem and launch the application, it sometimes detects the GSM device and i am even able to send and receive SMS. Or else
  1.) I get the following error-</p>
  
  <pre><code>Launching FrontlineSMS for Windows... Stable Library
  ========================================= Native lib Version = RXTX-2.1-7 Java lib Version   = RXTX-2.1-7 Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(860): Access is de ied.
  
  Error 0x57 at /home/bob/foo/rxtx-devel/build/../src/termios.c(2352): The parame er is incorrect.
  
  Error 0x57 at /home/bob/foo/rxtx-devel/build/../src/termios.c(2352): The parame er is incorrect.
  
  Error 0x57 at /home/bob/foo/rxtx-devel/build/../src/termios.c(2352): The parame er is incorrect.
  
  Error 0x57 at /home/bob/foo/rxtx-devel/build/../src/termios.c(2352): The parame er is incorrect.
  
  Error 0x57 at /home/bob/foo/rxtx-devel/build/../src/termios.c(2352): The parame er is incorrect.
  
  Error 0x57 at /home/bob/foo/rxtx-devel/build/../src/termios.c(2352): The parame er is incorrect.
  
  Error 0x57 at /home/bob/foo/rxtx-devel/build/../src/termios.c(2352): The parame er is incorrect.
  
  Error 0x57 at /home/bob/foo/rxtx-devel/build/../src/termios.c(2352): The parame er is incorrect.
  
  Error 0x57 at /home/bob/foo/rxtx-devel/build/../src/termios.c(2352): The parame er is incorrect.
  
  Error 0x57 at /home/bob/foo/rxtx-devel/build/../src/termios.c(2352): The parame er is incorrect.
  
  Error 0x5 at /home/bob/foo/rxtx-devel/build/../src/termios.c(860): Access is de ied.
  
  Error 0x57 at /home/bob/foo/rxtx-devel/build/../src/termios.c(2352): The parame er is incorrect.
  
  Error 0x57 at /home/bob/foo/rxtx-devel/build/../src/termios.c(2352): The parame er is incorrect.
  
  Error 0x57 at /home/bob/foo/rxtx-devel/build/../src/termios.c(2352): The parame er is incorrect.
  
  Error 0x57 at /home/bob/foo/rxtx-devel/build/../src/termios.c(2352): The parame er is incorrect.
  
  Error 0x57 at /home/bob/foo/rxtx-devel/build/../src/termios.c(2352): The parame er is incorrect.
  
  Error 0x57 at /home/bob/foo/rxtx-devel/build/../src/termios.c(2352): The parame er is incorrect.
  
  Error 0x57 at /home/bob/foo/rxtx-devel/build/../src/termios.c(2352): The parame er is incorrect.
  
  Error 0x1 at /home/bob/foo/rxtx-devel/build/../src/termios.c(2497): Incorrect f nction.
  
  Error 0x1 at /home/bob/foo/rxtx-devel/build/../src/termios.c(2497): Incorrect f nction.
  
  Error 0x1 at /home/bob/foo/rxtx-devel/build/../src/termios.c(2497): Incorrect f nction.
  
  Error 0x1 at /home/bob/foo/rxtx-devel/build/../src/termios.c(2497): Incorrect f nction.
  
  Error 0x1 at /home/bob/foo/rxtx-devel/build/../src/termios.c(2497): Incorrect f nction.
  
  Error 0x1 at /home/bob/foo/rxtx-devel/build/../src/termios.c(2497): Incorrect f nction.
  
  Error 0x1 at /home/bob/foo/rxtx-devel/build/../src/termios.c(2497): Incorrect f nction.
  </code></pre>
  
  <p>2.) OR the application sometimes crashes by creating a log file which contains:</p>
  
  <pre><code>#
  # A fatal error has been detected by the Java Runtime Environment:
  #
  #  EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x10009ccb, pid=4452, tid=3464
  #
  # JRE version: 6.0_20-b02
  # Java VM: Java HotSpot(TM) Client VM (16.3-b01 mixed mode, sharing windows-x86 )
  # Problematic frame:
  # C  [rxtxSerial.dll+0x9ccb]
  #
  # If you would like to submit a bug report, please visit:
  #   http://java.sun.com/webapps/bugreport/crash.jsp
  # The crash happened outside the Java Virtual Machine in native code.
  # See problematic frame for where to report the bug.
  #
  
  ---------------  T H R E A D  ---------------
  
  Current thread (0x03433000):  JavaThread "SmsModem :: COM18" daemon [_thread_in_native, id=3464, stack(0x070a0000,0x070f0000)]
  
  siginfo: ExceptionCode=0xc0000005, writing address 0x038cfa10
  
  Registers:
  EAX=0x038cfa08, EBX=0x00000003, ECX=0x7c802413, EDX=0x00000001
  ESP=0x070ef800, EBP=0x070ef9e8, ESI=0x3360b898, EDI=0x03433000
  EIP=0x10009ccb, EFLAGS=0x00010202
  
  Top of Stack: (sp=0x070ef800)
  0x070ef800:   3360b8a0 6d9fbc40 6da2ed98 ffffffff
  0x070ef810:   070ef848 6d8f0a2c 6d8f0340 070ef95c
  0x070ef820:   070ef864 00000dfb 03433000 038cfa08
  0x070ef830:   00000007 00000001 00000001 0000000a
  0x070ef840:   03433bf4 fffffffe 070ef8f4 6d8f0b7a
  0x070ef850:   070ef95c 03433bf8 6da6f210 6da6f538
  0x070ef860:   070ef868 03433bf4 27f18708 27f18708
  0x070ef870:   22eb9810 03433bc4 00000001 070ef898 
  
  Instructions: (pc=0x10009ccb)
  0x10009cbb:   45 1c 7c 19 8b 85 44 fe ff ff 8b 95 4c fe ff ff
  0x10009ccb:   89 50 08 8b 55 f4 89 d0 e9 f8 01 00 00 c7 85 50 
  
  
  Stack: [0x070a0000,0x070f0000],  sp=0x070ef800,  free space=13e070ef334k
  Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
  C  [rxtxSerial.dll+0x9ccb]
  C  [rxtxSerial.dll+0xa05e]
  j  gnu.io.RXTXPort.readByte()I+0
  j  gnu.io.RXTXPort$SerialInputStream.read()I+61
  j  org.smslib.CSerialDriver.getResponse()Ljava/lang/String;+36
  j  net.frontlinesms.smsdevice.SmsModem._doDetection()Z+172
  j  net.frontlinesms.smsdevice.SmsModem.run()V+18
  v  ~StubRoutines::call_stub
  V  [jvm.dll+0xf049c]
  V  [jvm.dll+0x17fcf1]
  V  [jvm.dll+0xf0667]
  V  [jvm.dll+0xf06dd]
  V  [jvm.dll+0x11a2a0]
  V  [jvm.dll+0x1ddb14]
  V  [jvm.dll+0x17f96c]
  C  [msvcr71.dll+0x9565]
  C  [kernel32.dll+0xb729]
  
  Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
  j  gnu.io.RXTXPort.readByte()I+0
  j  gnu.io.RXTXPort$SerialInputStream.read()I+61
  j  org.smslib.CSerialDriver.getResponse()Ljava/lang/String;+36
  j  net.frontlinesms.smsdevice.SmsModem._doDetection()Z+172
  j  net.frontlinesms.smsdevice.SmsModem.run()V+18
  v  ~StubRoutines::call_stub
  
  ---------------  P R O C E S S  ---------------
  
  Java Threads: ( =&gt; current thread )
  =&gt;0x03433000 JavaThread "SmsModem :: COM18" daemon [_thread_in_native, id=3464, stack(0x070a0000,0x070f0000)]
    0x0344b800 JavaThread "D3D Screen Updater" daemon [_thread_blocked, id=4404, stack(0x03dd0000,0x03e20000)]
    0x002b7800 JavaThread "DestroyJavaVM" [_thread_blocked, id=3236, stack(0x008c0000,0x00910000)]
    0x03f6f400 JavaThread "AWT-EventQueue-0" [_thread_blocked, id=1888, stack(0x038e0000,0x03930000)]
    0x03ec2400 JavaThread "AWT-Shutdown" [_thread_blocked, id=4300, stack(0x03740000,0x03790000)]
    0x032d8c00 JavaThread "EmailServerHandler" [_thread_blocked, id=5708, stack(0x03830000,0x03880000)]
    0x032f7000 JavaThread "Incoming message processor" [_thread_blocked, id=4184, stack(0x03650000,0x036a0000)]
    0x03004c00 JavaThread "AWT-Windows" daemon [_thread_in_native, id=4828, stack(0x035a0000,0x035f0000)]
    0x0303f400 JavaThread "Java2D Disposer" daemon [_thread_blocked, id=3768, stack(0x03500000,0x03550000)]
    0x02b1e800 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=4164, stack(0x02dd0000,0x02e20000)]
    0x02b18c00 JavaThread "CompilerThread0" daemon [_thread_blocked, id=2936, stack(0x02d80000,0x02dd0000)]
    0x02b17400 JavaThread "Attach Listener" daemon [_thread_blocked, id=5444, stack(0x02d30000,0x02d80000)]
    0x02b15c00 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=4976, stack(0x02ce0000,0x02d30000)]
    0x02b0d800 JavaThread "Finalizer" daemon [_thread_blocked, id=5876, stack(0x02c90000,0x02ce0000)]
    0x02b0c400 JavaThread "Reference Handler" daemon [_thread_blocked, id=5984, stack(0x02c40000,0x02c90000)]
  
  Other Threads:
    0x02b0ac00 VMThread [stack: 0x02bf0000,0x02c40000] [id=4508]
    0x02b29800 WatcherThread [stack: 0x02e20000,0x02e70000] [id=6080]
  
  VM state:not at safepoint (normal execution)
  
  VM Mutex/Monitor currently owned by a thread: None
  
  Heap
   def new generation   total 7808K, used 4003K [0x22990000, 0x23200000, 0x27ee0000)
    eden space 6976K,  45% used [0x22990000, 0x22ca8e90, 0x23060000)
    from space 832K, 100% used [0x23060000, 0x23130000, 0x23130000)
    to   space 832K,   0% used [0x23130000, 0x23130000, 0x23200000)
   tenured generation   total 17208K, used 15192K [0x27ee0000, 0x28fae000, 0x32990000)
     the space 17208K,  88% used [0x27ee0000, 0x28db6100, 0x28db6200, 0x28fae000)
   compacting perm gen  total 13824K, used 13655K [0x32990000, 0x33710000, 0x36990000)
     the space 13824K,  98% used [0x32990000, 0x336e5f98, 0x336e6000, 0x33710000)
      ro space 10240K,  51% used [0x36990000, 0x36ebae00, 0x36ebae00, 0x37390000)
      rw space 12288K,  54% used [0x37390000, 0x37a272d8, 0x37a27400, 0x37f90000)
  
  Dynamic libraries:
  0x00400000 - 0x00424000  C:\WINDOWS\system32\java.exe
  0x7c900000 - 0x7c9b2000  C:\WINDOWS\system32\ntdll.dll
  0x7c800000 - 0x7c8f6000  C:\WINDOWS\system32\kernel32.dll
  0x77dd0000 - 0x77e6b000  C:\WINDOWS\system32\ADVAPI32.dll
  0x77e70000 - 0x77f02000  C:\WINDOWS\system32\RPCRT4.dll
  0x77fe0000 - 0x77ff1000  C:\WINDOWS\system32\Secur32.dll
  0x7c340000 - 0x7c396000  C:\Program Files\Java\jre6\bin\msvcr71.dll
  0x6d800000 - 0x6da97000  C:\Program Files\Java\jre6\bin\client\jvm.dll
  0x7e410000 - 0x7e4a1000  C:\WINDOWS\system32\USER32.dll
  0x77f10000 - 0x77f59000  C:\WINDOWS\system32\GDI32.dll
  0x76b40000 - 0x76b6d000  C:\WINDOWS\system32\WINMM.dll
  0x76390000 - 0x763ad000  C:\WINDOWS\system32\IMM32.DLL
  0x6d7b0000 - 0x6d7bc000  C:\Program Files\Java\jre6\bin\verify.dll
  0x6d330000 - 0x6d34f000  C:\Program Files\Java\jre6\bin\java.dll
  0x6d290000 - 0x6d298000  C:\Program Files\Java\jre6\bin\hpi.dll
  0x76bf0000 - 0x76bfb000  C:\WINDOWS\system32\PSAPI.DLL
  0x6d7f0000 - 0x6d7ff000  C:\Program Files\Java\jre6\bin\zip.dll
  0x6d000000 - 0x6d14a000  C:\Program Files\Java\jre6\bin\awt.dll
  0x73000000 - 0x73026000  C:\WINDOWS\system32\WINSPOOL.DRV
  0x77c10000 - 0x77c68000  C:\WINDOWS\system32\msvcrt.dll
  0x774e0000 - 0x7761d000  C:\WINDOWS\system32\ole32.dll
  0x773d0000 - 0x774d3000  C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.2600.5512_x-ww_35d4ce83\COMCTL32.dll
  0x77f60000 - 0x77fd6000  C:\WINDOWS\system32\SHLWAPI.dll
  0x5ad70000 - 0x5ada8000  C:\WINDOWS\system32\uxtheme.dll
  0x74720000 - 0x7476c000  C:\WINDOWS\system32\MSCTF.dll
  0x755c0000 - 0x755ee000  C:\WINDOWS\system32\msctfime.ime
  0x7c9c0000 - 0x7d1d7000  C:\WINDOWS\system32\shell32.dll
  0x6d230000 - 0x6d284000  C:\Program Files\Java\jre6\bin\fontmanager.dll
  0x68000000 - 0x68036000  C:\WINDOWS\system32\rsaenh.dll
  0x769c0000 - 0x76a74000  C:\WINDOWS\system32\USERENV.dll
  0x5b860000 - 0x5b8b5000  C:\WINDOWS\system32\netapi32.dll
  0x6d610000 - 0x6d623000  C:\Program Files\Java\jre6\bin\net.dll
  0x71ab0000 - 0x71ac7000  C:\WINDOWS\system32\WS2_32.dll
  0x71aa0000 - 0x71aa8000  C:\WINDOWS\system32\WS2HELP.dll
  0x71a50000 - 0x71a8f000  C:\WINDOWS\System32\mswsock.dll
  0x76f20000 - 0x76f47000  C:\WINDOWS\system32\DNSAPI.dll
  0x76fb0000 - 0x76fb8000  C:\WINDOWS\System32\winrnr.dll
  0x76f60000 - 0x76f8c000  C:\WINDOWS\system32\WLDAP32.dll
  0x16080000 - 0x160a5000  C:\Program Files\Bonjour\mdnsNSP.dll
  0x76d60000 - 0x76d79000  C:\WINDOWS\system32\Iphlpapi.dll
  0x63560000 - 0x63568000  C:\Program Files\National Instruments\Shared\mDNS Responder\nimdnsNSP.dll
  0x63550000 - 0x63559000  C:\WINDOWS\system32\nimdnsResponder.dll
  0x78130000 - 0x781cb000  C:\WINDOWS\WinSxS\x86_Microsoft.VC80.CRT_1fc8b3b9a1e18e3b_8.0.50727.4053_x-ww_e6967989\MSVCR80.dll
  0x76fc0000 - 0x76fc6000  C:\WINDOWS\system32\rasadhlp.dll
  0x10000000 - 0x10012000  C:\Documents and Settings\bjz677\Desktop\client run\rxtxSerial.dll
  0x73d90000 - 0x73db7000  C:\WINDOWS\system32\crtdll.dll
  0x4fdd0000 - 0x4ff76000  C:\WINDOWS\system32\d3d9.dll
  0x038d0000 - 0x038d6000  C:\WINDOWS\system32\d3d8thk.dll
  0x77c00000 - 0x77c08000  C:\WINDOWS\system32\VERSION.dll
  0x6d630000 - 0x6d639000  C:\Program Files\Java\jre6\bin\nio.dll
  0x03930000 - 0x03977000  C:\Program Files\Iomega\DriveIcons\IMGHOOK.DLL
  0x605d0000 - 0x605d9000  C:\WINDOWS\system32\mslbui.dll
  0x77120000 - 0x771ab000  C:\WINDOWS\system32\OLEAUT32.DLL
  
  VM Arguments:
  java_command: net.frontlinesms.DesktopLauncher
  Launcher Type: SUN_STANDARD
  
  Environment Variables:
  JAVA_HOME=C:\Program Files\Java\jdk1.6.0_20\bin
  CLASSPATH=.;C:\Program Files\Java\jre6\lib\ext\QTJava.zip;
  PATH=C:\Program Files\Intel\MKL\10.0.2.019\ia32\bin;C:\Program Files\Intel\VTune\CGGlbCache;C:\Program Files\Intel\VTune\Analyzer\Bin;C:\Program Files\Intel\VTune\Shared\Bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;s:\datamart\bin;C:\Program Files\ATI Technologies\ATI.ACE\;C:\Program Files\IVI\bin;c:\Program Files\Microsoft SQL Server\90\Tools\binn\;C:\Program Files\MATLAB\R2007b\bin;C:\Program Files\MATLAB\R2007b\bin\win32;C:\VXIPNP\WinNT\Bin;C:\Program Files\Intel\Compiler\Fortran\10.1.021\\IA32\Lib;C:\Program Files\Intel\Compiler\Fortran\10.1.021\\EM64T\Lib;C:\VXIPNP\WinNT\Bin\;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\WINDOWS\system32\WindowsPowerShell\v1.0;C:\Program Files\QuickTime\QTSystem\;C:\Program Files\Java\jdk1.6.0_20\bin
  USERNAME=xxx
  OS=Windows_NT
  PROCESSOR_IDENTIFIER=x86 Family 6 Model 15 Stepping 2, GenuineIntel
  
  
  
  ---------------  S Y S T E M  ---------------
  
  OS: Windows XP Build 2600 Service Pack 3
  
  CPU:total 2 (2 cores per cpu, 1 threads per core) family 6 model 15 stepping 2, cmov, cx8, fxsr, mmx, sse, sse2, sse3, ssse3
  
  Memory: 4k page, physical 2094960k(1063364k free), swap 4032536k(3038408k free)
  
  vm_info: Java HotSpot(TM) Client VM (16.3-b01) for windows-x86 JRE (1.6.0_20-b02), built on Apr 12 2010 13:52:23 by "java_re" with MS VC++ 7.1 (VS2003)
  
  time: Wed Jun 16 11:53:40 2010
  elapsed time: 45 seconds
  </code></pre>
  
  <p>Does anyone know what causes it?</p>