4 Replies Latest reply on Jul 27, 2006 10:44 PM by 521085

    getString produces "*** glibc detected *** free(): invalid pointer"

    518079
      The simple query below fails when the result of ResultSet::getString() goes out of scope. Any help resolving this error would be greatly appreciated.

      This Oracle 10.2.0 application is running on Linux (RedHat?) 2.6.9 with g++ 3.4.4.

      The compile statement is: /usr/bin/g++ -m32 -fPIC -I$ORACLE_HOME/rdbms/public -c Tmp.cc -o Tmp.o

      The link statement is: /usr/bin/g++ -L$ORACLE_HOME/lib32 Tmp.o -m32 -fPIC -lclntsh -locci -lnnz10 -o Tmp -lpthread

      The output is:
      value(BOOKS)
      *** glibc detected *** free(): invalid pointer: 0x0805fa80 ***
      Abort



      #include <pthread.h>
      #include <iostream>
      #include <occi.h>

      int
      main( int argc, char * argv[] )
      {
      oracle::occi::Environment * env;
      env = oracle::occi::Environment::createEnvironment();
      oracle::occi::Connection * conn;
      conn = env->createConnection( "occidemo", "occidemo" );
      oracle::occi::Statement * stmt;
      stmt = conn->createStatement( "select table_name from user_tables" );
      oracle::occi::ResultSet * rs;
      rs = stmt->executeQuery();
      rs->next();

      std::string const sValue = rs->getString( 1 );
      std::cerr << "value(" << sValue << ")" << std::endl;
      // FIXME application aborts when sValue goes out of scope.
      }
      std::cerr << "does not reach this statement" << std::endl;
      stmt->closeResultSet( rs );
      conn->terminateStatement( stmt );
      env->terminateConnection( conn );
      oracle::occi::Environment::terminateEnvironment( env );
      return( 0 );
      }
        • 1. Re: getString produces "*** glibc detected *** free(): invalid pointer"
          518079
          Also, the link statement produces this warning message:

          /usr/bin/ld: warning: libstdc++.so.5, needed by /opt/oracle/product/10.2.0/lib32/libocci.so, may conflict with libstdc++.so.6


          Here's the gdb output:


          GNU gdb Red Hat Linux (6.3.0.0-1.63rh)
          Copyright 2004 Free Software Foundation, Inc.
          GDB is free software, covered by the GNU General Public License, and you are
          welcome to change it and/or distribute copies of it under certain conditions.
          Type "show copying" to see the conditions.
          There is absolutely no warranty for GDB. Type "show warranty" for details.
          This GDB was configured as "x86_64-redhat-linux-gnu"...(no debugging symbols found)
          Using host libthread_db library "/lib64/tls/libthread_db.so.1".

          (gdb) run
          Starting program: /tmp/OracleFailure
          Reading symbols from shared object read from target memory...(no debugging symbols found)...done.
          Loaded system supplied DSO at 0xffffe000
          (no debugging symbols found)
          (no debugging symbols found)
          (no debugging symbols found)
          (no debugging symbols found)
          [Thread debugging using libthread_db enabled]
          [New Thread 4142298816 (LWP 31182)]
          (no debugging symbols found)
          (no debugging symbols found)
          (no debugging symbols found)
          (no debugging symbols found)
          (no debugging symbols found)
          (no debugging symbols found)
          (no debugging symbols found)
          (no debugging symbols found)
          (no debugging symbols found)
          (no debugging symbols found)
          Detaching after fork from child process 31285.
          value(BOOKS)
          *** glibc detected *** free(): invalid pointer: 0x0805fa80 ***

          Program received signal SIGABRT, Aborted.
          [Switching to Thread 4142298816 (LWP 31182)]
          0xffffe405 in __kernel_vsyscall ()
          (gdb) where
          #0 0xffffe405 in __kernel_vsyscall ()
          #1 0x0089c7d5 in raise () from /lib/tls/libc.so.6
          #2 0x0089e149 in abort () from /lib/tls/libc.so.6
          #3 0x008d040a in __libc_message () from /lib/tls/libc.so.6
          #4 0x008d6b3f in intfree () from /lib/tls/libc.so.6
          #5 0x008d6eba in free () from /lib/tls/libc.so.6
          #6 0x00a7af21 in operator delete () from /usr/lib/libstdc++.so.6
          #7 0x00a5cc4f in std::string::_Rep::_M_destroy () from /usr/lib/libstdc++.so.6
          #8 0x00a5ced2 in std::basic_string<char, std::char_traits<char>, std::allocator<char> >::~basic_string ()
          from /usr/lib/libstdc++.so.6
          #9 0x08048fd3 in main ()
          • 2. Re: getString produces "*** glibc detected *** free(): invalid pointer"
            518079
            The solution turned out to be upgrading the Oracle OCCI.

            To download OCCI for gcc 3.4.3:

            http://www.oracle.com/technology/tech/oci/occi/occidownloads.html
            • 3. Re: getString produces "*** glibc detected *** free(): invalid pointer"
              518667
              Hello there!

              I have the same problem.

              I am using Gentoo 2.6.15 system with an Intel Xeon 64 Bit CPU with Oracle Instant Client 10.2.0.2 and gcc version 3.4.4.

              I have downloaded the OCCI upgrade from http://www.oracle.com/technology/tech/oci/occi/occidownloads.html but then I get an incompatible lib error.

              Is this OCCI version compiled for a 32 Bit system?

              Thanks for any help.

              Martin
              • 4. Re: getString produces "*** glibc detected *** free(): invalid pointer"
                521085
                I got a similar error when I try to do following:

                unsigned long ip = ACE_OS::inet_addr(rs->getString(2).c_str());
                unsigned short port = htons(rs->getInt(3));
                ACE_DEBUG((LM_DEBUG, "%s %s %d\n",
                rs->getString(1).c_str(),
                rs->getString(2).c_str(), port));

                addName(rs->getString(1).c_str(), port, new_addrs);

                Anything to do with the "rs->getString(n).c_str()" would cause the program segment fault.

                However, I have to convert the string to char *

                I am using:

                Linux LinuxMOne 2.6.11-1.1369_FC4smp #1 SMP Thu Jun 2 23:08:39 EDT 2005 i686 i686 i386 GNU/Linux

                gcc (GCC) 4.0.2 20051125 (Red Hat 4.0.2-8)