我正在使用本教程中的代码来试验OCCI:
http://oradim.blogspot.com.br/2009/08/getting-started-with-occi-linux-version_16.html
当我尝试运行该应用程序时,它给出了以下错误:
*** Error in `./occi_test': free(): invalid pointer: 0x0000000000cb7578 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7fd386f347e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x7fe0a)[0x7fd386f3ce0a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7fd386f4098c]
./occi_test[0x4013e3]
./occi_test[0x4011e6]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7fd386edd830]
./occi_test[0x4010f9]
======= Memory map: ========
00400000-00403000 r-xp 00000000 08:05 9438076 /home/cohen/NetBeansProjects/OCCI_TEST/dist/Debug/GNU-Linux/occi_test
00602000-00603000 r--p 00002000 08:05 9438076 /home/cohen/NetBeansProjects/OCCI_TEST/dist/Debug/GNU-Linux/occi_test
00603000-00604000 rw-p 00003000 08:05 9438076 /home/cohen/NetBeansProjects/OCCI_TEST/dist/Debug/GNU-Linux/occi_test
00c16000-00cc9000 rw-p 00000000 00:00 0 [heap]
7fd380000000-7fd380021000 rw-p 00000000 00:00 0
7fd380021000-7fd384000000 ---p 00000000 00:00 0
7fd384277000-7fd384278000 r-xp 00000000 08:05 13635893 /lib/x86_64-linux-gnu/libaio.so.1.0.1
7fd384278000-7fd384477000 ---p 00001000 08:05 13635893 /lib/x86_64-linux-gnu/libaio.so.1.0.1
7fd384477000-7fd384478000 r--p 00000000 08:05 13635893 /lib/x86_64-linux-gnu/libaio.so.1.0.1
7fd384478000-7fd384479000 rw-p 00001000 08:05 13635893 /lib/x86_64-linux-gnu/libaio.so.1.0.1
7fd384479000-7fd384489000 r-xp 00000000 08:05 20584019 /u01/app/oracle/product/12/dbhome_1/lib/libnque12.so
7fd384489000-7fd384689000 ---p 00010000 08:05 20584019 /u01/app/oracle/product/12/dbhome_1/lib/libnque12.so
7fd384689000-7fd38468a000 rw-p 00010000 08:05 20584019 /u01/app/oracle/product/12/dbhome_1/lib/libnque12.so
7fd38468a000-7fd38468b000 rw-p 00000000 00:00 0
7fd38468b000-7fd384695000 r-xp 00000000 08:05 25436941 /usr/lib/x86_64-linux-gnu/libnuma.so.1.0.0
7fd384695000-7fd384894000 ---p 0000a000 08:05 25436941 /usr/lib/x86_64-linux-gnu/libnuma.so.1.0.0
7fd384894000-7fd384895000 r--p 00009000 08:05 25436941 /usr/lib/x86_64-linux-gnu/libnuma.so.1.0.0
7fd384895000-7fd384896000 rw-p 0000a000 08:05 25436941 /usr/lib/x86_64-linux-gnu/libnuma.so.1.0.0
7fd384896000-7fd3848a1000 r-xp 00000000 08:05 13631575 /lib/x86_64-linux-gnu/libnss_files-2.23.so
7fd3848a1000-7fd384aa0000 ---p 0000b000 08:05 13631575 /lib/x86_64-linux-gnu/libnss_files-2.23.so
7fd384aa0000-7fd384aa1000 r--p 0000a000 08:05 13631575 /lib/x86_64-linux-gnu/libnss_files-2.23.so
7fd384aa1000-7fd384aa2000 rw-p 0000b000 08:05 13631575 /lib/x86_64-linux-gnu/libnss_files-2.23.so
7fd384aa2000-7fd384aa8000 rw-p 00000000 00:00 0
7fd384aa8000-7fd384ab3000 r-xp 00000000 08:05 13631572 /lib/x86_64-linux-gnu/libnss_nis-2.23.so
7fd384ab3000-7fd384cb2000 ---p 0000b000 08:05 13631572 /lib/x86_64-linux-gnu/libnss_nis-2.23.so
7fd384cb2000-7fd384cb3000 r--p 0000a000 08:05 13631572 /lib/x86_64-linux-gnu/libnss_nis-2.23.so
7fd384cb3000-7fd384cb4000 rw-p 0000b000 08:05 13631572 /lib/x86_64-linux-gnu/libnss_nis-2.23.so
7fd384cb4000-7fd384cca000 r-xp 00000000 08:05 13631513 /lib/x86_64-linux-gnu/libnsl-2.23.so
7fd384cca000-7fd384ec9000 ---p 00016000 08:05 13631513 /lib/x86_64-linux-gnu/libnsl-2.23.so
7fd384ec9000-7fd384eca000 r--p 00015000 08:05 13631513 /lib/x86_64-linux-gnu/libnsl-2.23.so
7fd384eca000-7fd384ecb000 rw-p 00016000 08:05 13631513 /lib/x86_64-linux-gnu/libnsl-2.23.so
7fd384ecb000-7fd384ecd000 rw-p 00000000 00:00 0
7fd384ecd000-7fd384ed5000 r-xp 00000000 08:05 13631502 /lib/x86_64-linux-gnu/libnss_compat-2.23.so
7fd384ed5000-7fd3850d4000 ---p 00008000 08:05 13631502 /lib/x86_64-linux-gnu/libnss_compat-2.23.so
7fd3850d4000-7fd3850d5000 r--p 00007000 08:05 13631502 /lib/x86_64-linux-gnu/libnss_compat-2.23.so
7fd3850d5000-7fd3850d6000 rw-p 00008000 08:05 13631502 /lib/x86_64-linux-gnu/libnss_compat-2.23.so
7fd3850d6000-7fd3850dd000 r-xp 00000000 08:05 13631584 /lib/x86_64-linux-gnu/librt-2.23.so
7fd3850dd000-7fd3852dc000 ---p 00007000 08:05 13631584 /lib/x86_64-linux-gnu/librt-2.23.so
7fd3852dc000-7fd3852dd000 r--p 00006000 08:05 13631584 /lib/x86_64-linux-gnu/librt-2.23.so
7fd3852dd000-7fd3852de000 rw-p 00007000 08:05 13631584 /lib/x86_64-linux-gnu/librt-2.23.so
7fd3852de000-7fd385454000 r-xp 00000000 08:05 20582107 /u01/app/oracle/product/12/dbhome_1/lib/libipc1.so
7fd385454000-7fd385654000 ---p 00176000 08:05 20582107 /u01/app/oracle/product/12/dbhome_1/lib/libipc1.so
7fd385654000-7fd385657000 rw-p 00176000 08:05 20582107 /u01/app/oracle/product/12/dbhome_1/lib/libipc1.so
7fd385657000-7fd38565c000 rw-p 00000000 00:00 0
7fd38565c000-7fd3859af000 r-xp 00000000 08:05 20584015 /u01/app/oracle/product/12/dbhome_1/lib/libclntshcore.so.12.1
7fd3859af000-7fd385baf000 ---p 00353000 08:05 20584015 /u01/app/oracle/product/12/dbhome_1/lib/libclntshcore.so.12.1
7fd385baf000-7fd385bb0000 r--p 00353000 08:05 20584015 /u01/app/oracle/product/12/dbhome_1/lib/libclntshcore.so.12.1
7fd385bb0000-7fd385bc9000 rw-p 00354000 08:05 20584015 /u01/app/oracle/product/12/dbhome_1/lib/libclntshcore.so.12.1
7fd385bc9000-7fd385bce000 rw-p 00000000 00:00 0
7fd385bce000-7fd385be6000 r-xp 00000000 08:05 13635974 /lib/x86_64-linux-gnu/libpthread-2.23.so
7fd385be6000-7fd385de5000 ---p 00018000 08:05 13635974 /lib/x86_64-linux-gnu/libpthread-2.23.so
7fd385de5000-7fd385de6000 r--p 00017000 08:05 13635974 /lib/x86_64-linux-gnu/libpthread-2.23.so
7fd385de6000-7fd385de7000 rw-p 00018000 08:05 13635974 /lib/x86_64-linux-gnu/libpthread-2.23.so
7fd385de7000-7fd385deb000 rw-p 00000000 00:00 0
7fd385deb000-7fd385ef3000 r-xp 00000000 08:05 13631581 /lib/x86_64-linux-gnu/libm-2.23.so
7fd385ef3000-7fd3860f2000 ---p 00108000 08:05 13631581 /lib/x86_64-linux-gnu/libm-2.23.so
7fd3860f2000-7fd3860f3000 r--p 00107000 08:05 13631581 /lib/x86_64-linux-gnu/libm-2.23.so
7fd3860f3000-7fd3860f4000 rw-p 00108000 08:05 13631581 /lib/x86_64-linux-gnu/libm-2.23.so
7fd3860f4000-7fd3860f7000 r-xp 00000000 08:05 13635976 /lib/x86_64-linux-gnu/libdl-2.23.so
7fd3860f7000-7fd3862f6000 ---p 00003000 08:05 13635976 /lib/x86_64-linux-gnu/libdl-2.23.so
7fd3862f6000-7fd3862f7000 r--p 00002000 08:05 13635976 /lib/x86_64-linux-gnu/libdl-2.23.so
7fd3862f7000-7fd3862f8000 rw-p 00003000 08:05 13635976 /lib/x86_64-linux-gnu/libdl-2.23.so
7fd3862f8000-7fd38633c000 r-xp 00000000 08:05 20583989 /u01/app/oracle/product/12/dbhome_1/lib/libons.so
7fd38633c000-7fd38653b000 ---p 00044000 08:05 20583989 /u01/app/oracle/product/12/dbhome_1/lib/libons.so
7fd38653b000-7fd38653d000 rw-p 00043000 08:05 20583989 /u01/app/oracle/product/12/dbhome_1/lib/libons.so
7fd38653d000-7fd3865af000 r-xp 00000000 08:05 20582105 /u01/app/oracle/product/12/dbhome_1/lib/libmql1.so
7fd3865af000-7fd3867ae000 ---p 00072000 08:05 20582105 /u01/app/oracle/product/12/dbhome_1/lib/libmql1.so
7fd3867ae000-7fd3867b1000 rw-p 00071000 08:05 20582105 /u01/app/oracle/product/12/dbhome_1/lib/libmql1.so
7fd3867b1000-7fd3867b3000 rw-p 00000000 00:00 0
7fd3867b3000-7fd386c5a000 r-xp 00000000 08:05 20584044 /u01/app/oracle/product/12/dbhome_1/lib/libnnz12.so
7fd386c5a000-7fd386e5a000 ---p 004a7000 08:05 20584044 /u01/app/oracle/product/12/dbhome_1/lib/libnnz12.so
7fd386e5a000-7fd386ebc000 rw-p 004a7000 08:05 20584044 /u01/app/oracle/product/12/dbhome_1/lib/libnnz12.so
7fd386ebc000-7fd386ebd000 rw-p 00000000 00:00 0
7fd386ebd000-7fd38707c000 r-xp 00000000 08:05 13635975 /lib/x86_64-linux-gnu/libc-2.23.so
7fd38707c000-7fd38727c000 ---p 001bf000 08:05 13635975 /lib/x86_64-linux-gnu/libc-2.23.so
7fd38727c000-7fd387280000 r--p 001bf000 08:05 13635975 /lib/x86_64-linux-gnu/libc-2.23.so
7fd387280000-7fd387282000 rw-p 001c3000 08:05 13635975 /lib/x86_64-linux-gnu/libc-2.23.so
7fd387282000-7fd387286000 rw-p 00000000 00:00 0
7fd387286000-7fd38729c000 r-xp 00000000 08:05 13635995 /lib/x86_64-linux-gnu/libgcc_s.so.1
7fd38729c000-7fd38749b000 ---p 00016000 08:05 13635995 /lib/x86_64-linux-gnu/libgcc_s.so.1
7fd38749b000-7fd38749c000 rw-p 00015000 08:05 13635995 /lib/x86_64-linux-gnu/libgcc_s.so.1
7fd38749c000-7fd38760e000 r-xp 00000000 08:05 25430146 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7fd38760e000-7fd38780e000 ---p 00172000 08:05 25430146 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7fd38780e000-7fd387818000 r--p 00172000 08:05 25430146 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7fd387818000-7fd38781a000 rw-p 0017c000 08:05 25430146 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7fd38781a000-7fd38781e000 rw-p 00000000 00:00 0
7fd38781e000-7fd38a3d9000 r-xp 00000000 08:05 20583996 /u01/app/oracle/product/12/dbhome_1/lib/libclntsh.so.12.1
7fd38a3d9000-7fd38a5d8000 ---p 02bbb000 08:05 20583996 /u01/app/oracle/product/12/dbhome_1/lib/libclntsh.so.12.1
7fd38a5d8000-7fd38a5dc000 r--p 02bba000 08:05 20583996 /u01/app/oracle/product/12/dbhome_1/lib/libclntsh.so.12.1
7fd38a5dc000-7fd38a7bb000 rw-p 02bbe000 08:05 20583996 /u01/app/oracle/product/12/dbhome_1/lib/libclntsh.so.12.1
7fd38a7bb000-7fd38a7db000 rw-p 00000000 00:00 0
7fd38a7db000-7fd38a90f000 r-xp 00000000 08:05 20583888 /u01/app/oracle/product/12/dbhome_1/lib/libocci.so.12.1
7fd38a90f000-7fd38ab0f000 ---p 00134000 08:05 20583888 /u01/app/oracle/product/12/dbhome_1/lib/libocci.so.12.1
7fd38ab0f000-7fd38ab10000 r--p 00134000 08:05 20583888 /u01/app/oracle/product/12/dbhome_1/lib/libocci.so.12.1
7fd38ab10000-7fd38ab1a000 rw-p 00135000 08:05 20583888 /u01/app/oracle/product/12/dbhome_1/lib/libocci.so.12.1
7fd38ab1a000-7fd38ab40000 r-xp 00000000 08:05 13631585 /lib/x86_64-linux-gnu/ld-2.23.so
7fd38abce000-7fd38ac30000 rw-p 00000000 00:00 0
7fd38ac30000-7fd38acef000 r--p 00000000 08:05 20583487 /u01/app/oracle/product/12/dbhome_1/oracore/zoneinfo/timezlrg_18.dat
7fd38acef000-7fd38ad20000 rw-p 00000000 00:00 0
7fd38ad3c000-7fd38ad3f000 rw-p 00000000 00:00 0
7fd38ad3f000-7fd38ad40000 r--p 00025000 08:05 13631585 /lib/x86_64-linux-gnu/ld-2.23.so
7fd38ad40000-7fd38ad41000 rw-p 00026000 08:05 13631585 /lib/x86_64-linux-gnu/ld-2.23.so
7fd38ad41000-7fd38ad42000 rw-p 00000000 00:00 0
7fff6ff52000-7fff6ff72000 rwxp 00000000 00:00 0 [stack]
7fff6ff72000-7fff6ff73000 rw-p 00000000 00:00 0
7fff6fff2000-7fff6fff4000 r--p 00000000 00:00 0 [vvar]
7fff6fff4000-7fff6fff6000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
我正在使用netbeans在ubuntu机器上运行来编译。汇编如下:
g++ -c -g -I/u01/app/oracle/product/12/dbhome_1/rdbms/public -MMD -MP -MF "build/Debug/GNU-Linux/main.o.d" -o build/Debug/GNU-Linux/main.o main.cpp
mkdir -p dist/Debug/GNU-Linux
g++ -o dist/Debug/GNU-Linux/occi_test build/Debug/GNU-Linux/main.o -L/u01/app/oracle/product/12/dbhome_1/lib -lnnz12 -locci -lclntsh -lipc1
经过调试,我可以看到它在这里崩溃(用户,密码和ip ommited,但我使用相同的用户和密码连接到sqlplus),但我不知道为什么崩溃:
this->user = "usr";
this->passwd = "pass";
this->db = "myip:1521/orcl";
this->env = Environment::createEnvironment(Environment::DEFAULT);
try
{
this->con = env->createConnection(this->user, this->passwd, this->db);
cout << "12cjd" << endl;
}
catch (SQLException& ex)
{
cout << ex.getMessage();
exit(EXIT_FAILURE);
}
答案 0 :(得分:0)
从你的输出中不清楚你的catch块是否正在捕捉任何东西。 如果正确清理连接和环境,这些错误可能会消失。
env->terminateConnection(con);
Environment::terminateEnvironment(env);