1. Harmony
  2. HARMONY-3117

[db2] IBM DB2 JDBC "sample apps" crash on exit


    • Type: Bug Bug
    • Status: Closed
    • Priority: Critical Critical
    • Resolution: Won't Fix
    • Affects Version/s: None
    • Fix Version/s: 5.0M4
    • Labels:
    • Environment:
      EM64T -- RedHat Enterprise Linux 4 - U4
      IBM DB2 Express-C version9.1
      Latest Harmony JRE binary download (vn = r487452, (Dec 15 2006), Linux/em64t/gcc 4.0.3, release build)
    • Estimated Complexity:


      Putting critical because critical is defined as "Crashes, loss of data, severe memory leak."

      I was experimenting with whether DB2 JDBC connection will work with Harmony. I am using the sample apps that come with DB2. The JDBC layer appears to connect to the database successfully (which is good for Harmony) and queries appear to work (data comes thru). However, during shutdown of the sample apps, the process regularly segfaults when using Harmony and exits cleanly using the BEA JRE and Sun JRE.

      crash behavior is consistent with both "java DbConn" (basic connection test) and "java TbSel" (basic sql select test) sample apps that come with the "free" version of DB2.

      unfortunately, the core file provides little insight.
      (gdb) bt
      #0 0x0000002aaf5898fa in ?? ()
      #1 0x0000000000000000 in ?? ()
      (gdb) info threads

      • 1 process 22262 0x0000002aaf5898fa in ?? ()

      Attaching with debugger gives a possible hint:
      Program received signal SIGSEGV, Segmentation fault.
      0x0000002aaf5898fa in OSSHLibrary::unload ()
      from /home/db2inst/sqllib/lib64/libdb2osse.so.1
      (gdb) bt
      #0 0x0000002aaf5898fa in OSSHLibrary::unload ()
      from /home/db2inst/sqllib/lib64/libdb2osse.so.1
      #1 0x0000002aacce93de in sqlexPluginUnload ()
      from /home/db2inst/sqllib/lib64/libdb2.so.1
      #2 0x0000002aad1dd080 in sqlexAppLibTerm ()
      from /home/db2inst/sqllib/lib64/libdb2.so.1
      #3 0x0000002aacc41afa in sqlmStreamFlagsAction ()
      from /home/db2inst/sqllib/lib64/libdb2.so.1
      #4 0x0000002aacc41b83 in _ZN10appLibInitD9Ev ()
      from /home/db2inst/sqllib/lib64/libdb2.so.1
      #5 0x0000002aacc41b73 in appLibInit::~appLibInit ()
      from /home/db2inst/sqllib/lib64/libdb2.so.1
      #6 0x000000380df30c45 in exit () from /lib64/tls/libc.so.6
      #7 0x000000380df1c402 in __libc_start_main () from /lib64/tls/libc.so.6
      #8 0x000000000040096a in _start () at ../sysdeps/x86_64/elf/start.S:113

      It looks to me that the C++ destructors registered by some presumably JNI components are being invoked by the C runtime at process exit. At this time there are no other threads remaining (i.e., java looks like it is done and gone) and presumably during the cleanup process something gets out of control.

      In contrast with the Sun Java5 JRE, there are 13 other threads remaining when the destructor runs and 12 other threads with the BEA Java5 JRE.

      I'm not sure if this is a compatibility issue with the reference implementation or if is simply a hole in the JNI support that Harmony currently provides. It appears to be 100% reproducable.

      1. db2-setup.zip
        131 kB
        Chris Elford
      2. db2admin.png
        19 kB
        Gregory Shimansky

        Issue Links


          Chris Elford created issue -
          Gregory Shimansky made changes -
          Field Original Value New Value
          Component/s DRLVM [ 12311272 ]
          Summary IBM DB2 JDBC "sample apps" crash on exit [drlvm] IBM DB2 JDBC "sample apps" crash on exit
          Gregory Shimansky made changes -
          Component/s App-Oriented Bug Reports [ 12311280 ]
          Chris Elford made changes -
          Attachment db2-setup.zip [ 12358724 ]
          Gregory Shimansky made changes -
          Component/s DRLVM [ 12311272 ]
          Summary [drlvm] IBM DB2 JDBC "sample apps" crash on exit [db2] IBM DB2 JDBC "sample apps" crash on exit
          Gregory Shimansky made changes -
          Fix Version/s 5.0M4 [ 12312882 ]
          Assignee Gregory Shimansky [ gshimansky ]
          Status Open [ 1 ] Resolved [ 5 ]
          Resolution Fixed [ 1 ]
          Chris Elford made changes -
          Status Resolved [ 5 ] Reopened [ 4 ]
          Resolution Fixed [ 1 ]
          Chris Elford made changes -
          Link This issue relates to HARMONY-5380 [ HARMONY-5380 ]
          Gregory Shimansky made changes -
          Comment [ Interesting how it works, it looks like DB2 crashes itself. I set up a breakpoing on DestroyJavaVM, and then on dlclose to see each unloaded library. After many API libraries the breakpoint was hit with the following stack:

          Breakpoint 3, 0x00000037a5601240 in dlclose () from /lib64/libdl.so.2
          (gdb) bt
          #0 0x00000037a5601240 in dlclose () from /lib64/libdl.so.2
          #1 0x00002aaac070e8fa in OSSHLibrary::unload ()
             from /home/db2inst1/sqllib/lib64/libdb2osse.so.1
          #2 0x00002aaabde743de in sqlexPluginUnload ()
             from /home/db2inst1/sqllib/lib64/libdb2.so.1
          #3 0x00002aaabe368080 in sqlexAppLibTerm ()
             from /home/db2inst1/sqllib/lib64/libdb2.so.1
          #4 0x00002aaabddccafa in sqlmStreamFlagsAction ()
             from /home/db2inst1/sqllib/lib64/libdb2.so.1
          #5 0x00002aaabddccb83 in _ZN10appLibInitD9Ev ()
             from /home/db2inst1/sqllib/lib64/libdb2.so.1
          #6 0x00002aaabddccb73 in appLibInit::~appLibInit ()
             from /home/db2inst1/sqllib/lib64/libdb2.so.1
          #7 0x00000037a5332405 in exit () from /lib64/libc.so.6
          #8 0x00000037a531d08b in __libc_start_main () from /lib64/libc.so.6
          #9 0x0000000000400999 in _start ()
          #10 0x00007fffff95a008 in ?? ()
          #11 0x0000000000000000 in ?? ()

          The return address from dlclose is 0x00002aaac070e8fa which is the crash address. I set a breakpoint on this instruction after call, but right with this dlclose the library libdb2osse.so.1 is unloaded, so it appears that it unloads itself, and then after return from dlclose tries to execute some code, this doesn't work well.

          I suppose that the bug may be in DB2 9.1. Maybe sometimes this library is opened twice, so dlclose doesn't ctually ]
          Gregory Shimansky made changes -
          Attachment db2admin.png [ 12373332 ]
          Gregory Shimansky made changes -
          Status Reopened [ 4 ] Closed [ 6 ]
          Resolution Won't Fix [ 2 ]


            • Assignee:
              Gregory Shimansky
              Chris Elford
            • Votes:
              0 Vote for this issue
              3 Start watching this issue


              • Created: