Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-6219857

PreparedStatement.setString("") causes EXCEPTION_ACCESS_VIOLATION

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Won't Fix
    • Affects Version/s: 5.0
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:

      Description

      FULL PRODUCT VERSION :
      java version "1.5.0_01"
      Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_01-b08)
      Java HotSpot(TM) Client VM (build 1.5.0_01-b08, mixed mode, sharing)


      ADDITIONAL OS VERSION INFORMATION :
      Microsoft Windows XP [Version 5.1.2600]

      A DESCRIPTION OF THE PROBLEM :
      I like to fill a MS Access database table using PreparedStatement and INSERT. An EXCEPTION_ACCESS_VIOLATION error will occur if PreparedStatement.setString(columnIndex, null) is followed by PreparedStatement.setString(columnIndex, "") for the next row.

      PreparedStatement.setString(columnIndex, null) or setting a non-empty string does not causes the error.

      STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
      In MS Access create a table which consists of two simple VARCHAR columns. Connect the database via ODBC interface and run the code example below.



      ERROR MESSAGES/STACK TRACES THAT OCCUR :
      #
      # An unexpected error has been detected by HotSpot Virtual Machine:
      #
      # EXCEPTION_ACCESS_VIOLATION (0xc0000005) at pc=0x1f90f570, pid=3976, tid=2320
      #
      # Java VM: Java HotSpot(TM) Client VM (1.5.0_01-b08 mixed mode)
      # Problematic frame:
      # C [odbcjt32.dll+0x1f570]
      #

      --------------- T H R E A D ---------------

      Current thread (0x00356d68): JavaThread "main" [_thread_in_native, id=2320]

      siginfo: ExceptionCode=0xc0000005, reading address 0x00000000

      Registers:
      EAX=0x00000000, EBX=0x00000000, ECX=0x0000000a, EDX=0x00000003
      ESP=0x0006f7e8, EBP=0x0006f804, ESI=0x0ace9338, EDI=0x0ace93a0
      EIP=0x1f90f570, EFLAGS=0x00010246

        Top of Stack: (sp=0x0006f7e8)
      0x0006f7e8: 0ace93a0 0ace9338 00000000 00000000
      0x0006f7f8: 00000000 00000001 00000001 0006f838
      0x0006f808: 1f910100 00000000 00000002 00000001
      0x0006f818: 00000001 000000ff 00000000 00a55bb0
      0x0006f828: 00000000 00000000 0af01ea8 0af01f98
      0x0006f838: 0006f878 1f7b9792 0ace9338 00000002
      0x0006f848: 00000001 00000001 00000001 000000ff
      0x0006f858: 00000000 00a55bb0 00000000 00000000

      Instructions: (pc=0x1f90f570)
      0x1f90f560: 39 5d 08 8b 40 20 75 14 83 f8 ff 75 08 8b 45 24
      0x1f90f570: 83 38 ff 75 07 c7 45 f0 01 00 00 00 0f bf 45 14


      Stack: [0x00030000,0x00070000), sp=0x0006f7e8, free space=253k
      Native frames: (J=compiled Java code, j=interpreted, Vv=VM code, C=native code)
      C [odbcjt32.dll+0x1f570]
      C [odbcjt32.dll+0x20100]
      C [ODBC32.dll+0x9792]
      C [ODBC32.dll+0x9664]
      C [JdbcOdbc.dll+0x2af9]
      j sun.jdbc.odbc.JdbcOdbc.bindInParameterString(JII[BII[B[B[J)V+0
      j sun.jdbc.odbc.JdbcOdbc.SQLBindInParameterString(JIIII[B[B[J)V+110
      j sun.jdbc.odbc.JdbcOdbcPreparedStatement.setChar(IIILjava/lang/String;)V+135
      j sun.jdbc.odbc.JdbcOdbcPreparedStatement.setString(ILjava/lang/String;)V+39
      j de.dzsh.main.PreparedStatementSimpleInsert.insert()V+80
      j de.dzsh.main.PreparedStatementSimpleInsert.main([Ljava/lang/String;)V+0
      v ~StubRoutines::call_stub
      V [jvm.dll+0x8176e]
      V [jvm.dll+0xd481d]
      V [jvm.dll+0x8163f]
      V [jvm.dll+0x885cd]
      C [javaw.exe+0x14c0]
      C [javaw.exe+0x313d]
      C [kernel32.dll+0x214c7]

      Java frames: (J=compiled Java code, j=interpreted, Vv=VM code)
      j sun.jdbc.odbc.JdbcOdbc.bindInParameterString(JII[BII[B[B[J)V+0
      j sun.jdbc.odbc.JdbcOdbc.SQLBindInParameterString(JIIII[B[B[J)V+110
      j sun.jdbc.odbc.JdbcOdbcPreparedStatement.setChar(IIILjava/lang/String;)V+135
      j sun.jdbc.odbc.JdbcOdbcPreparedStatement.setString(ILjava/lang/String;)V+39
      j de.dzsh.main.PreparedStatementSimpleInsert.insert()V+80
      j de.dzsh.main.PreparedStatementSimpleInsert.main([Ljava/lang/String;)V+0
      v ~StubRoutines::call_stub

      --------------- P R O C E S S ---------------

      Java Threads: ( => current thread )
        0x00a2d608 JavaThread "Low Memory Detector" daemon [_thread_blocked, id=1648]
        0x00a2bc50 JavaThread "CompilerThread0" daemon [_thread_blocked, id=468]
        0x00a29c98 JavaThread "Signal Dispatcher" daemon [_thread_blocked, id=3840]
        0x00a27e90 JavaThread "JDWP Command Reader" daemon [_thread_in_native, id=3724]
        0x00a26fe8 JavaThread "JDWP Event Helper Thread" daemon [_thread_blocked, id=2364]
        0x00a21118 JavaThread "JDWP Transport Listener: dt_socket" daemon [_thread_blocked, id=1136]
        0x00a175b8 JavaThread "Finalizer" daemon [_thread_blocked, id=4012]
        0x00a16b50 JavaThread "Reference Handler" daemon [_thread_blocked, id=3852]
      =>0x00356d68 JavaThread "main" [_thread_in_native, id=2320]

      Other Threads:
        0x00a14850 VMThread [id=840]
        0x00a2e830 WatcherThread [id=864]

      VM state:not at safepoint (normal execution)

      VM Mutex/Monitor currently owned by a thread: None

      Heap
       def new generation total 576K, used 289K [0x02a60000, 0x02b00000, 0x02f40000)
        eden space 512K, 56% used [0x02a60000, 0x02aa87d0, 0x02ae0000)
        from space 64K, 0% used [0x02ae0000, 0x02ae0000, 0x02af0000)
        to space 64K, 0% used [0x02af0000, 0x02af0000, 0x02b00000)
       tenured generation total 1408K, used 0K [0x02f40000, 0x030a0000, 0x06a60000)
         the space 1408K, 0% used [0x02f40000, 0x02f40000, 0x02f40200, 0x030a0000)
       compacting perm gen total 8192K, used 1967K [0x06a60000, 0x07260000, 0x0aa60000)
         the space 8192K, 24% used [0x06a60000, 0x06c4bc28, 0x06c4be00, 0x07260000)
      No shared spaces configured.

      Dynamic libraries:
      0x00400000 - 0x0040c000 C:\jdk1.5.0\bin\javaw.exe
      0x77f40000 - 0x77fee000 C:\WINDOWS\System32\ntdll.dll
      0x77e40000 - 0x77f38000 C:\WINDOWS\system32\kernel32.dll
      0x77da0000 - 0x77e3c000 C:\WINDOWS\system32\ADVAPI32.dll
      0x78000000 - 0x78086000 C:\WINDOWS\system32\RPCRT4.dll
      0x77d10000 - 0x77d9c000 C:\WINDOWS\system32\USER32.dll
      0x77c40000 - 0x77c80000 C:\WINDOWS\system32\GDI32.dll
      0x77be0000 - 0x77c33000 C:\WINDOWS\system32\MSVCRT.dll
      0x6d6b0000 - 0x6d835000 C:\jdk1.5.0\jre\bin\client\jvm.dll
      0x76af0000 - 0x76b1d000 C:\WINDOWS\System32\WINMM.dll
      0x6d2f0000 - 0x6d2f8000 C:\jdk1.5.0\jre\bin\hpi.dll
      0x76bb0000 - 0x76bbb000 C:\WINDOWS\System32\PSAPI.DLL
      0x6d3f0000 - 0x6d425000 C:\jdk1.5.0\jre\bin\jdwp.dll
      0x6d680000 - 0x6d68c000 C:\jdk1.5.0\jre\bin\verify.dll
      0x6d370000 - 0x6d38d000 C:\jdk1.5.0\jre\bin\java.dll
      0x6d6a0000 - 0x6d6af000 C:\jdk1.5.0\jre\bin\zip.dll
      0x6d290000 - 0x6d297000 C:\jdk1.5.0\jre\bin\dt_socket.dll
      0x71a10000 - 0x71a25000 C:\WINDOWS\System32\WS2_32.dll
      0x71a00000 - 0x71a08000 C:\WINDOWS\System32\WS2HELP.dll
      0x719b0000 - 0x719ec000 C:\WINDOWS\System32\mswsock.dll
      0x76ee0000 - 0x76f05000 C:\WINDOWS\System32\DNSAPI.dll
      0x76f70000 - 0x76f77000 C:\WINDOWS\System32\winrnr.dll
      0x76f20000 - 0x76f4d000 C:\WINDOWS\system32\WLDAP32.dll
      0x76f80000 - 0x76f85000 C:\WINDOWS\System32\rasadhlp.dll
      0x719f0000 - 0x719f8000 C:\WINDOWS\System32\wshtcpip.dll
      0x6d3e0000 - 0x6d3ed000 C:\jdk1.5.0\jre\bin\JdbcOdbc.dll
      0x1f7b0000 - 0x1f7e1000 C:\WINDOWS\System32\ODBC32.dll
      0x77310000 - 0x7739b000 C:\WINDOWS\system32\COMCTL32.dll
      0x76350000 - 0x76396000 C:\WINDOWS\system32\comdlg32.dll
      0x772a0000 - 0x77304000 C:\WINDOWS\system32\SHLWAPI.dll
      0x773a0000 - 0x77ba1000 C:\WINDOWS\system32\SHELL32.dll
      0x78090000 - 0x78174000 C:\WINDOWS\WinSxS\x86_Microsoft.Windows.Common-Controls_6595b64144ccf1df_6.0.10.0_x-ww_f7fb5805\comctl32.dll
      0x1f850000 - 0x1f868000 C:\WINDOWS\System32\odbcint.dll
      0x1f8f0000 - 0x1f932000 C:\WINDOWS\System32\odbcjt32.dll
      0x1b000000 - 0x1b16f000 C:\WINDOWS\System32\msjet40.dll
      0x1b5c0000 - 0x1b655000 C:\WINDOWS\System32\mswstr10.dll
      0x0b000000 - 0x0b121000 C:\WINDOWS\system32\ole32.dll
      0x770f0000 - 0x7717b000 C:\WINDOWS\system32\OLEAUT32.dll
      0x1f8e0000 - 0x1f8ef000 C:\WINDOWS\System32\odbcji32.dll
      0x1b2c0000 - 0x1b2cd000 C:\WINDOWS\System32\msjter40.dll
      0x1b2d0000 - 0x1b2fd000 C:\WINDOWS\System32\MSJINT40.DLL
      0x76f50000 - 0x76f60000 C:\WINDOWS\System32\Secur32.dll
      0x76f90000 - 0x77008000 C:\WINDOWS\System32\CLBCATQ.DLL
      0x77010000 - 0x770e3000 C:\WINDOWS\System32\COMRes.dll
      0x77bd0000 - 0x77bd7000 C:\WINDOWS\system32\VERSION.dll
      0x1b7f0000 - 0x1b82a000 C:\WINDOWS\System32\msjtes40.dll
      0x10390000 - 0x1039b000 C:\WINDOWS\System32\VBAJET32.DLL
      0x107b0000 - 0x10812000 C:\WINDOWS\System32\expsrv.dll

      VM Arguments:
      jvm_args: -Xdebug -Xnoagent -Xrunjdwp:transport=dt_socket,suspend=y,address=localhost:1293
      java_command: de.dzsh.main.PreparedStatementSimpleInsert

      Environment Variables:
      JAVA_HOME=C:\jdk_aktuell
      PATH=C:\oracle\ora90\bin;C:\Programme\Oracle\jre\1.1.8\bin;C:\jdk_aktuell;C:\jdk_aktuell\BIN;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\Programme\Microsoft SQL Server\80\Tools\BINN
      USERNAME=SeulbeNo
      OS=Windows_NT
      PROCESSOR_IDENTIFIER=x86 Family 15 Model 2 Stepping 9, GenuineIntel


      --------------- S Y S T E M ---------------

      OS: Windows XP Build 2600 Service Pack 1

      CPU:total 1 family 15, cmov, cx8, fxsr, mmx, sse, sse2, ht

      Memory: 4k page, physical 1039344k(595608k free), swap 1718340k(1372532k free)

      vm_info: Java HotSpot(TM) Client VM (1.5.0_01-b08) for windows-x86, built on Dec 6 2004 19:51:00 by "java_re" with MS VC++ 6.0



      REPRODUCIBILITY :
      This bug can be reproduced always.

      ---------- BEGIN SOURCE ----------
      import java.sql.*;
      import java.util.*;

      public class PreparedStatementSimpleInsert {

      private static String driverName = "sun.jdbc.odbc.JdbcOdbcDriver";
      private static String databaseName = "jdbc:odbc:PreparedStatementInsert";

      private static void insert() {
      PreparedStatement statement = null;
      Connection connection = null;
      try {
      Class.forName(driverName);
      } catch (ClassNotFoundException e) {
      System.out.println(e.getMessage());
      }

      try {
      connection = DriverManager.getConnection(databaseName, null, null);
      statement = connection.prepareStatement("INSERT INTO SIMPLE_TABLE VALUES (?, ?)");

      // This works
      statement.setString(1, "Mouse");
      statement.setString(2, null);
      statement.execute();
      // statement.clearParameters();

      // This crashes with 'unexpected error EXCEPTION_ACCESS_VIOLATION'
      statement.setString(1, "Elephant");
      statement.setString(2, "");
      statement.execute();

      } catch (SQLException e) {
      System.out.println(e.getMessage());
      } finally {
      try {
      statement.close();
      connection.close();
      } catch (SQLException e1) {
      // ignore
      }
      }
      }

      public static void main(String[] args) {
      insert();
      System.out.println("Program finished.");
      }
      }

      ---------- END SOURCE ----------

      CUSTOMER SUBMITTED WORKAROUND :
      Use PreparedStatement.clearParameters() after execution. According to the API doc it should not be neccessary ('Setting a parameter value automatically clears its previous value') but it helps.
      ###@###.### 2005-1-21 00:18:05 GMT

        Attachments

          Activity

            People

            Assignee:
            ahandasunw Amit Handa (Inactive)
            Reporter:
            rmandalasunw Ranjith Mandala (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: