I was working on aqua-sim that is based on ns2 for my ubuntu and i'm getting a buffer overflow error and i can't figure out how to trace this kind of error.
i tried to debug using gdb but with no luck as i don't know how to trace the error, can someone please let me know where should i look based on the following error segment:
num_nodes is set 10
INITIALIZE THE LIST xListHead
Starting Simulation...
GOD: the old file name istest.data
GOD: the new file name isunderwater.data
*** buffer overflow detected ***: ns terminated
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f57d8e347e5]
/lib/x86_64-linux-gnu/libc.so.6(__fortify_fail+0x5c)[0x7f57d8ed611c]
/lib/x86_64-linux-gnu/libc.so.6(+0x117120)[0x7f57d8ed4120]
/lib/x86_64-linux-gnu/libc.so.6(+0x116689)[0x7f57d8ed3689]
/lib/x86_64-linux-gnu/libc.so.6(_IO_default_xsputn+0x80)[0x7f57d8e386b0]
/lib/x86_64-linux-gnu/libc.so.6(_IO_vfprintf+0xc90)[0x7f57d8e0ae00]
/lib/x86_64-linux-gnu/libc.so.6(__vsprintf_chk+0x84)[0x7f57d8ed3714]
/lib/x86_64-linux-gnu/libc.so.6(__sprintf_chk+0x7d)[0x7f57d8ed366d]
ns[0x57ea03]
ns[0x57eb44]
ns[0x415367]
ns[0x4162e6]
ns[0x416d8c]
ns[0x5b3894]
ns[0x5b85d5]
ns[0x5bdf12]
ns[0x5c0372]
ns[0x5e7de9]
ns[0x5ec6c0]
ns[0x5e7e99]
ns[0x5ec6c0]
ns[0x613615]
ns[0x613803]
ns[0x5b8705]
ns[0x5bdf12]
ns[0x5c0372]
ns[0x5e7de9]
ns[0x5ec6c0]
ns[0x613615]
ns[0x613803]
ns[0x5b85d5]
ns[0x5bdf12]
ns[0x5c0372]
ns[0x5c1c37]
ns[0x603321]
ns[0x606936]
ns[0x405abe]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f57d8ddd830]
ns[0x410f59]
======= Memory map: ========
00400000-00766000 r-xp 00000000 08:06 2491295 /home/me/Aqua-Sim/Aqua-Sim-1.0/ns-2.30/ns
00965000-00967000 r--p 00365000 08:06 2491295 /home/me/Aqua-Sim/Aqua-Sim-1.0/ns-2.30/ns
00967000-009f2000 rw-p 00367000 08:06 2491295 /home/me/Aqua-Sim/Aqua-Sim-1.0/ns-2.30/ns
009f2000-00a00000 rw-p 00000000 00:00 0
00c2e000-01085000 rw-p 00000000 00:00 0 [heap]
7f57d8ad0000-7f57d8dbd000 r--p 00000000 08:06 2627421 /usr/lib/locale/locale-archive
7f57d8dbd000-7f57d8f7d000 r-xp 00000000 08:06 1179887 /lib/x86_64-linux-gnu/libc-2.23.so
7f57d8f7d000-7f57d917d000 ---p 001c0000 08:06 1179887 /lib/x86_64-linux-gnu/libc-2.23.so
7f57d917d000-7f57d9181000 r--p 001c0000 08:06 1179887 /lib/x86_64-linux-gnu/libc-2.23.so
7f57d9181000-7f57d9183000 rw-p 001c4000 08:06 1179887 /lib/x86_64-linux-gnu/libc-2.23.so
7f57d9183000-7f57d9187000 rw-p 00000000 00:00 0
7f57d9187000-7f57d919d000 r-xp 00000000 08:06 1184430 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f57d919d000-7f57d939c000 ---p 00016000 08:06 1184430 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f57d939c000-7f57d939d000 rw-p 00015000 08:06 1184430 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f57d939d000-7f57d9517000 r-xp 00000000 08:06 2621627 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.24
7f57d9517000-7f57d9716000 ---p 0017a000 08:06 2621627 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.24
7f57d9716000-7f57d9720000 r--p 00179000 08:06 2621627 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.24
7f57d9720000-7f57d9722000 rw-p 00183000 08:06 2621627 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.24
7f57d9722000-7f57d9725000 rw-p 00000000 00:00 0
7f57d9725000-7f57d982d000 r-xp 00000000 08:06 1179880 /lib/x86_64-linux-gnu/libm-2.23.so
7f57d982d000-7f57d9a2c000 ---p 00108000 08:06 1179880 /lib/x86_64-linux-gnu/libm-2.23.so
7f57d9a2c000-7f57d9a2d000 r--p 00107000 08:06 1179880 /lib/x86_64-linux-gnu/libm-2.23.so
7f57d9a2d000-7f57d9a2e000 rw-p 00108000 08:06 1179880 /lib/x86_64-linux-gnu/libm-2.23.so
7f57d9a2e000-7f57d9a31000 r-xp 00000000 08:06 1179868 /lib/x86_64-linux-gnu/libdl-2.23.so
7f57d9a31000-7f57d9c30000 ---p 00003000 08:06 1179868 /lib/x86_64-linux-gnu/libdl-2.23.so
7f57d9c30000-7f57d9c31000 r--p 00002000 08:06 1179868 /lib/x86_64-linux-gnu/libdl-2.23.so
7f57d9c31000-7f57d9c32000 rw-p 00003000 08:06 1179868 /lib/x86_64-linux-gnu/libdl-2.23.so
7f57d9c32000-7f57d9c58000 r-xp 00000000 08:06 1179846 /lib/x86_64-linux-gnu/ld-2.23.so
7f57d9e37000-7f57d9e3d000 rw-p 00000000 00:00 0
7f57d9e54000-7f57d9e57000 rw-p 00000000 00:00 0
7f57d9e57000-7f57d9e58000 r--p 00025000 08:06 1179846 /lib/x86_64-linux-gnu/ld-2.23.so
7f57d9e58000-7f57d9e59000 rw-p 00026000 08:06 1179846 /lib/x86_64-linux-gnu/ld-2.23.so
7f57d9e59000-7f57d9e5a000 rw-p 00000000 00:00 0
7ffeddbfa000-7ffeddc1c000 rw-p 00000000 00:00 0 [stack]
7ffeddc4b000-7ffeddc4d000 r--p 00000000 00:00 0 [vvar]
7ffeddc4d000-7ffeddc4f000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
Aborted (core dumped)
my gcc is 4.9,on ns-2.30, and ubuntu 16.04
Related
I'm trying to execute a very basic C++ program that interacts with MySQL. I implemented the very beginning of the tutorial for MySQL Connector/C++, but I keep getting a segfault when I try to execute that code. Here is the code that I'm trying to execute:
try
{
sql::mysql::MySQL_Driver *driver = NULL;
sql::Connection *conn = NULL;
driver = sql::mysql::get_mysql_driver_instance();
if (driver != NULL)
{
conn = driver->connect("127.0.0.1:3306", "root", "root");
cout << "Test" << endl;
}
delete conn;
conn = NULL;
}
When I execute this code, "Test" gets printed, but I get the following error:
*** Error in `./test': free(): invalid pointer: 0x00007f0a9a292158 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f0a999a87e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7f0a999b137a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f0a999b553c]
./test(_ZN3sql9SQLStringD1Ev+0x18)[0x401296]
/lib/x86_64-linux-gnu/libc.so.6(+0x39ff8)[0x7f0a9996aff8]
/lib/x86_64-linux-gnu/libc.so.6(+0x3a045)[0x7f0a9996b045]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf7)[0x7f0a99951837]
./test[0x400e79]
======= Memory map: ========
00400000-00402000 r-xp 00000000 08:01 6167619
/home/lichtsb1/local/src/ddsWork/mysqlTest/test
00601000-00602000 r--p 00001000 08:01 6167619
/home/lichtsb1/local/src/ddsWork/mysqlTest/test
00602000-00603000 rw-p 00002000 08:01 6167619
/home/lichtsb1/local/src/ddsWork/mysqlTest/test
02357000-023aa000 rw-p 00000000 00:00 0
[heap]
7f0a94000000-7f0a94021000 rw-p 00000000 00:00 0
7f0a94021000-7f0a98000000 ---p 00000000 00:00 0
7f0a989a8000-7f0a98ab0000 r-xp 00000000 08:01 43253857
/lib/x86_64-linux-gnu/libm-2.23.so
7f0a98ab0000-7f0a98caf000 ---p 00108000 08:01 43253857
/lib/x86_64-linux-gnu/libm-2.23.so
7f0a98caf000-7f0a98cb0000 r--p 00107000 08:01 43253857
/lib/x86_64-linux-gnu/libm-2.23.so
7f0a98cb0000-7f0a98cb1000 rw-p 00108000 08:01 43253857
/lib/x86_64-linux-gnu/libm-2.23.so
7f0a98cb1000-7f0a98cb4000 r-xp 00000000 08:01 43254080
/lib/x86_64-linux-gnu/libdl-2.23.so
7f0a98cb4000-7f0a98eb3000 ---p 00003000 08:01 43254080
/lib/x86_64-linux-gnu/libdl-2.23.so
7f0a98eb3000-7f0a98eb4000 r--p 00002000 08:01 43254080
/lib/x86_64-linux-gnu/libdl-2.23.so
7f0a98eb4000-7f0a98eb5000 rw-p 00003000 08:01 43254080
/lib/x86_64-linux-gnu/libdl-2.23.so
7f0a98eb5000-7f0a99074000 r-xp 00000000 08:01 7733609
/home/lichtsb1/local/src/ddsWork/mysqlTest/mysql-connector-c++-8.0.13-linux-glibc2.12-x86-64bit/lib64/libcrypto.so.1.0.0
7f0a99074000-7f0a99273000 ---p 001bf000 08:01 7733609
/home/lichtsb1/local/src/ddsWork/mysqlTest/mysql-connector-c++-8.0.13-linux-glibc2.12-x86-64bit/lib64/libcrypto.so.1.0.0
7f0a99273000-7f0a9929a000 rw-p 001be000 08:01 7733609
/home/lichtsb1/local/src/ddsWork/mysqlTest/mysql-connector-c++-8.0.13-linux-glibc2.12-x86-64bit/lib64/libcrypto.so.1.0.0
7f0a9929a000-7f0a9929d000 rw-p 00000000 00:00 0
7f0a9929d000-7f0a99302000 r-xp 00000000 08:01 7733606
/home/lichtsb1/local/src/ddsWork/mysqlTest/mysql-connector-c++-8.0.13-linux-glibc2.12-x86-64bit/lib64/libssl.so.1.0.0
7f0a99302000-7f0a99502000 ---p 00065000 08:01 7733606
/home/lichtsb1/local/src/ddsWork/mysqlTest/mysql-connector-c++-8.0.13-linux-glibc2.12-x86-64bit/lib64/libssl.so.1.0.0
7f0a99502000-7f0a9950c000 rw-p 00065000 08:01 7733606
/home/lichtsb1/local/src/ddsWork/mysqlTest/mysql-connector-c++-8.0.13-linux-glibc2.12-x86-64bit/lib64/libssl.so.1.0.0
7f0a9950c000-7f0a99513000 r-xp 00000000 08:01 43254289
/lib/x86_64-linux-gnu/librt-2.23.so
7f0a99513000-7f0a99712000 ---p 00007000 08:01 43254289
/lib/x86_64-linux-gnu/librt-2.23.so
7f0a99712000-7f0a99713000 r--p 00006000 08:01 43254289
/lib/x86_64-linux-gnu/librt-2.23.so
7f0a99713000-7f0a99714000 rw-p 00007000 08:01 43254289
/lib/x86_64-linux-gnu/librt-2.23.so
7f0a99714000-7f0a9972c000 r-xp 00000000 08:01 43253992
/lib/x86_64-linux-gnu/libpthread-2.23.so
7f0a9972c000-7f0a9992b000 ---p 00018000 08:01 43253992
/lib/x86_64-linux-gnu/libpthread-2.23.so
7f0a9992b000-7f0a9992c000 r--p 00017000 08:01 43253992
/lib/x86_64-linux-gnu/libpthread-2.23.so
7f0a9992c000-7f0a9992d000 rw-p 00018000 08:01 43253992
/lib/x86_64-linux-gnu/libpthread-2.23.so
7f0a9992d000-7f0a99931000 rw-p 00000000 00:00 0
7f0a99931000-7f0a99af1000 r-xp 00000000 08:01 43254051
/lib/x86_64-linux-gnu/libc-2.23.so
7f0a99af1000-7f0a99cf1000 ---p 001c0000 08:01 43254051
/lib/x86_64-linux-gnu/libc-2.23.so
7f0a99cf1000-7f0a99cf5000 r--p 001c0000 08:01 43254051
/lib/x86_64-linux-gnu/libc-2.23.so
7f0a99cf5000-7f0a99cf7000 rw-p 001c4000 08:01 43254051
/lib/x86_64-linux-gnu/libc-2.23.so
7f0a99cf7000-7f0a99cfb000 rw-p 00000000 00:00 0
7f0a99cfb000-7f0a99d11000 r-xp 00000000 08:01 43254905
/lib/x86_64-linux-gnu/libgcc_s.so.1
7f0a99d11000-7f0a99f10000 ---p 00016000 08:01 43254905
/lib/x86_64-linux-gnu/libgcc_s.so.1
7f0a99f10000-7f0a99f11000 rw-p 00015000 08:01 43254905
/lib/x86_64-linux-gnu/libgcc_s.so.1
7f0a99f11000-7f0a9a083000 r-xp 00000000 08:01 20972156
/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f0a9a083000-7f0a9a283000 ---p 00172000 08:01 20972156
/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f0a9a283000-7f0a9a28d000 r--p 00172000 08:01 20972156
/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f0a9a28d000-7f0a9a28f000 rw-p 0017c000 08:01 20972156
/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f0a9a28f000-7f0a9a293000 rw-p 00000000 00:00 0
7f0a9a293000-7f0a9a6ed000 r-xp 00000000 08:01 7733614
/home/lichtsb1/local/src/ddsWork/mysqlTest/mysql-connector-c++-8.0.13-linux-glibc2.12-x86-64bit/lib64/libmysqlcppconn.so.7.8.0.13
7f0a9a6ed000-7f0a9a8ed000 ---p 0045a000 08:01 7733614
/home/lichtsb1/local/src/ddsWork/mysqlTest/mysql-connector-c++-8.0.13-linux-glibc2.12-x86-64bit/lib64/libmysqlcppconn.so.7.8.0.13
7f0a9a8ed000-7f0a9a8f8000 r--p 0045a000 08:01 7733614
/home/lichtsb1/local/src/ddsWork/mysqlTest/mysql-connector-c++-8.0.13-linux-glibc2.12-x86-64bit/lib64/libmysqlcppconn.so.7.8.0.13
7f0a9a8f8000-7f0a9aab7000 rw-p 00465000 08:01 7733614
/home/lichtsb1/local/src/ddsWork/mysqlTest/mysql-connector-c++-8.0.13-linux-glibc2.12-x86-64bit/lib64/libmysqlcppconn.so.7.8.0.13
7f0a9aab7000-7f0a9aabd000 rw-p 00000000 00:00 0
7f0a9aabd000-7f0a9aae3000 r-xp 00000000 08:01 43253979
/lib/x86_64-linux-gnu/ld-2.23.so
7f0a9ac7b000-7f0a9acb7000 r--s 00000000 08:01 16523805
/var/cache/nscd/services
7f0a9acb7000-7f0a9acbe000 rw-p 00000000 00:00 0
7f0a9ace0000-7f0a9ace2000 rw-p 00000000 00:00 0
7f0a9ace2000-7f0a9ace3000 r--p 00025000 08:01 43253979
/lib/x86_64-linux-gnu/ld-2.23.so
7f0a9ace3000-7f0a9ace4000 rw-p 00026000 08:01 43253979
/lib/x86_64-linux-gnu/ld-2.23.so
7f0a9ace4000-7f0a9ace5000 rw-p 00000000 00:00 0
7ffe3b05c000-7ffe3b07e000 rw-p 00000000 00:00 0
[stack]
7ffe3b0dd000-7ffe3b0e0000 r--p 00000000 00:00 0
[vvar]
7ffe3b0e0000-7ffe3b0e2000 r-xp 00000000 00:00 0
[vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0
[vsyscall]
Aborted (core dumped)
This is so basic - what am I doing wrong?
Thank you very much for any help.
I've already ran the following command and killed all the leaks and errors reported to it, but I am still getting some random free(): invalid pointer AFTER the program finished executing.
valgrind -v --tool=memcheck --leak-check=full --track-origins=yes --show-reachable=yes ./blah
Here is the output after I fixed "everything":
--31313-- Discarding syms at 0x883f1f0-0x8847648 in /lib64/libnss_files-2.12.so due to munmap()
--31313-- Discarding syms at 0x8a4c000-0x8a4f328 in /lib64/libnss_dns-2.12.so due to munmap()
--31313-- Discarding syms at 0x8c54930-0x8c63938 in /lib64/libresolv-2.12.so due to munmap()
==31313==
==31313== HEAP SUMMARY:
==31313== in use at exit: 0 bytes in 0 blocks
==31313== total heap usage: 9,190 allocs, 9,190 frees, 1,286,890 bytes allocated
==31313==
==31313== All heap blocks were freed -- no leaks are possible
==31313==
==31313== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 8 from 6)
--31313--
--31313-- used_suppression: 6 U1004-ARM-_dl_relocate_object
--31313-- used_suppression: 2 glibc-2.5.x-on-SUSE-10.2-(PPC)-2a
==31313==
==31313== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 8 from 6)
What else can I try to track this random + AFTER my program executed, mysterious invalid free?
EDIT:
The last 2 lines before it exit...
applog("GODDAMN IT");
return final_rc;
}
Here is the "notification" that I get for the free: invalid pointer:
GODDAMN IT
*** glibc detected *** ./scvpc: free(): invalid pointer: 0x00007f7975fbd6d0 ***
======= Backtrace: =========
/lib64/libc.so.6(+0x373e876166)[0x7f7974134166]
/home/svn/trunk/packages/wvstreams/libwvbase.so.5.2.0(_ZN12WvFastString6unlinkEv+0x1e)[0x7f7975d725be]
/home/svn/trunk/packages/wvstreams/libwvbase.so.5.2.0(_ZN8WvStreamD1Ev+0x491)[0x7f7975d81481]
/lib64/libc.so.6(__cxa_finalize+0x9d)[0x7f79740f41bd]
/home/svn/trunk/packages/wvstreams/libwvbase.so.5.2.0(+0x31e56)[0x7f7975d69e56]
======= Memory map: ========
7f796c000000-7f796c021000 rw-p 00000000 00:00 0
7f796c021000-7f7970000000 ---p 00000000 00:00 0
7f7972180000-7f7972196000 r-xp 00000000 fd:00 406206 /lib64/libresolv-2.12.so
7f7972196000-7f7972396000 ---p 00016000 fd:00 406206 /lib64/libresolv-2.12.so
7f7972396000-7f7972397000 r--p 00016000 fd:00 406206 /lib64/libresolv-2.12.so
7f7972397000-7f7972398000 rw-p 00017000 fd:00 406206 /lib64/libresolv-2.12.so
7f7972398000-7f797239a000 rw-p 00000000 00:00 0
7f797239a000-7f797239f000 r-xp 00000000 fd:00 390955 /lib64/libnss_dns-2.12.so
7f797239f000-7f797259e000 ---p 00005000 fd:00 390955 /lib64/libnss_dns-2.12.so
7f797259e000-7f797259f000 r--p 00004000 fd:00 390955 /lib64/libnss_dns-2.12.so
7f797259f000-7f79725a0000 rw-p 00005000 fd:00 390955 /lib64/libnss_dns-2.12.so
7f79725a0000-7f79725ac000 r-xp 00000000 fd:00 390957 /lib64/libnss_files-2.12.so
7f79725ac000-7f79727ac000 ---p 0000c000 fd:00 390957 /lib64/libnss_files-2.12.so
7f79727ac000-7f79727ad000 r--p 0000c000 fd:00 390957 /lib64/libnss_files-2.12.so
7f79727ad000-7f79727ae000 rw-p 0000d000 fd:00 390957 /lib64/libnss_files-2.12.so
7f79727ae000-7f79727af000 ---p 00000000 00:00 0
7f79727af000-7f79731af000 rw-p 00000000 00:00 0
7f79731af000-7f7973220000 r-xp 00000000 fd:00 392042 /lib64/libfreebl3.so
7f7973220000-7f797341f000 ---p 00071000 fd:00 392042 /lib64/libfreebl3.so
7f797341f000-7f7973421000 r--p 00070000 fd:00 392042 /lib64/libfreebl3.so
7f7973421000-7f7973422000 rw-p 00072000 fd:00 392042 /lib64/libfreebl3.so
7f7973422000-7f7973426000 rw-p 00000000 00:00 0
7f7973426000-7f797343d000 r-xp 00000000 fd:00 392038 /lib64/libaudit.so.1.0.0
7f797343d000-7f797363c000 ---p 00017000 fd:00 392038 /lib64/libaudit.so.1.0.0
7f797363c000-7f797363d000 r--p 00016000 fd:00 392038 /lib64/libaudit.so.1.0.0
7f797363d000-7f7973642000 rw-p 00017000 fd:00 392038 /lib64/libaudit.so.1.0.0
7f7973642000-7f7973644000 r-xp 00000000 fd:00 392041 /lib64/libdl-2.12.so
7f7973644000-7f7973844000 ---p 00002000 fd:00 392041 /lib64/libdl-2.12.so
7f7973844000-7f7973845000 r--p 00002000 fd:00 392041 /lib64/libdl-2.12.so
7f7973845000-7f7973846000 rw-p 00003000 fd:00 392041 /lib64/libdl-2.12.so
7f7973846000-7f797384d000 r-xp 00000000 fd:00 392043 /lib64/libcrypt-2.12.so
7f797384d000-7f7973a4d000 ---p 00007000 fd:00 392043 /lib64/libcrypt-2.12.so
7f7973a4d000-7f7973a4e000 r--p 00007000 fd:00 392043 /lib64/libcrypt-2.12.so
7f7973a4e000-7f7973a4f000 rw-p 00008000 fd:00 392043 /lib64/libcrypt-2.12.so
7f7973a4f000-7f7973a7d000 rw-p 00000000 00:00 0
7f7973a7d000-7f7973a89000 r-xp 00000000 fd:00 392044 /lib64/libpam.so.0.82.2
7f7973a89000-7f7973c89000 ---p 0000c000 fd:00 392044 /lib64/libpam.so.0.82.2
7f7973c89000-7f7973c8a000 r--p 0000c000 fd:00 392044 /lib64/libpam.so.0.82.2
7f7973c8a000-7f7973c8b000 rw-p 0000d000 fd:00 392044 /lib64/libpam.so.0.82.2
7f7973c8b000-7f7973ca2000 r-xp 00000000 fd:00 392046 /lib64/libpthread-2.12.so
7f7973ca2000-7f7973ea2000 ---p 00017000 fd:00 392046 /lib64/libpthread-2.12.so
7f7973ea2000-7f7973ea3000 r--p 00017000 fd:00 392046 /lib64/libpthread-2.12.so
7f7973ea3000-7f7973ea4000 rw-p 00018000 fd:00 392046 /lib64/libpthread-2.12.so
7f7973ea4000-7f7973ea8000 rw-p 00000000 00:00 0
7f7973ea8000-7f7973ebd000 r-xp 00000000 fd:00 392051 /lib64/libz.so.1.2.3
7f7973ebd000-7f79740bc000 ---p 00015000 fd:00 392051 /lib64/libz.so.1.2.3
7f79740bc000-7f79740bd000 r--p 00014000 fd:00 392051 /lib64/libz.so.1.2.3
7f79740bd000-7f79740be000 rw-p 00015000 fd:00 392051 /lib64/libz.so.1.2.3
7f79740be000-7f7974249000 r-xp 00000000 fd:00 391773 /lib64/libc-2.12.so
7f7974249000-7f7974448000 ---p 0018b000 fd:00 391773 /lib64/libc-2.12.so
7f7974448000-7f797444c000 r--p 0018a000 fd:00 391773 /lib64/libc-2.12.so
7f797444c000-7f797444d000 rw-p 0018e000 fd:00 391773 /lib64/libc-2.12.so
7f797444d000-7f7974452000 rw-p 00000000 00:00 0
7f7974452000-7f7974468000 r-xp 00000000 fd:00 392058 /lib64/libgcc_s-4.4.7-20120601.so.1
7f7974468000-7f7974667000 ---p 00016000 fd:00 392058 /lib64/libgcc_s-4.4.7-20120601.so.1
7f7974667000-7f7974668000 rw-p 00015000 fd:00 392058 /lib64/libgcc_s-4.4.7-20120601.so.1
7f7974668000-7f79746eb000 r-xp 00000000 fd:00 392052 /lib64/libm-2.12.so
7f79746eb000-7f79748ea000 ---p 00083000 fd:00 392052 /lib64/libm-2.12.so
7f79748ea000-7f79748eb000 r--p 00082000 fd:00 392052 /lib64/libm-2.12.so
7f79748eb000-7f79748ec000 rw-p 00083000 fd:00 392052 /lib64/libm-2.12.so
7f79748ec000-7f79749d4000 r-xp 00000000 fd:00 922734 /usr/lib64/libstdc++.so.6.0.13
7f79749d4000-7f7974bd4000 ---p 000e8000 fd:00 922734 /usr/lib64/libstdc++.so.6.0.13
7f7974bd4000-7f7974bdb000 r--p 000e8000 fd:00 922734 /usr/lib64/libstdc++.so.6.0.13
7f7974bdb000-7f7974bdd000 rw-p 000ef000 fd:00 922734 /usr/lib64/libstdc++.so.6.0.13
7f7974bdd000-7f7974bf2000 rw-p 00000000 00:00 0
7f7975084000-7f79750f3000 r-xp 00000000 fd:00 8662332 /home/svn/trunk/packages/openssl/libssl.so.1.0.1
7f79750f3000-7f79752f2000 ---p 0006f000 fd:00 8662332 /home/svn/trunk/packages/openssl/libssl.so.1.0.1
7f79752f2000-7f79752fb000 rw-p 0006e000 fd:00 8662332 /home/svn/trunk/packages/openssl/libssl.so.1.0.1
7f79752fb000-7f79754f2000 r-xp 00000000 fd:00 8662328 /home/svn/trunk/packages/openssl/libcrypto.so.1.0.1
7f79754f2000-7f79756f2000 ---p 001f7000 fd:00 8662328 /home/svn/trunk/packages/openssl/libcrypto.so.1.0.1
7f79756f2000-7f7975718000 rw-p 001f7000 fd:00 8662328 /home/svn/trunk/packages/openssl/libcrypto.so.1.0.1
7f7975718000-7f797571b000 rw-p 00000000 00:00 0
7f797571b000-7f7975742000 r-xp 00000000 fd:00 8867973 /home/svn/trunk/packages/wvstreams/libwvutils.so
7f7975742000-7f7975942000 ---p 00027000 fd:00 8867973 /home/svn/trunk/packages/wvstreams/libwvutils.so
7f7975942000-7f7975944000 rw-p 00027000 fd:00 8867973 /home/svn/trunk/packages/wvstreams/libwvutils.so
7f7975944000-7f7975a46000 rw-p 00000000 00:00 0
7f7975a46000-7f7975b2d000 r-xp 00000000 fd:00 8873068 /home/svn/trunk/packages/wvstreams/libwvstreams.so
7f7975b2d000-7f7975d2d000 ---p 000e7000 fd:00 8873068 /home/svn/trunk/packages/wvstreams/libwvstreams.so
7f7975d2d000-7f7975d38000 rw-p 000e7000 fd:00 8873068 /home/svn/trunk/packages/wvstreams/libwvstreams.so
7f7975d38000-7f7975db7000 r-xp 00000000 fd:00 8865320 /home/svn/trunk/packages/wvstreams/libwvbase.so
7f7975db7000-7f7975fb7000 ---p 0007f000 fd:00 8865320 /home/svn/trunk/packages/wvstreams/libwvbase.so
7f7975fb7000-7f7975fbe000 rw-p 0007f000 fd:00 8865320 /home/svn/trunk/packages/wvstreams/libwvbase.so
7f7975fbe000-7f7975fc2000 rw-p 00000000 00:00 0
7f7975fc2000-7f7975fe2000 r-xp 00000000 fd:00 391164 /lib64/ld-2.12.so
7f79761c6000-7f79761cf000 rw-p 00000000 00:00 0
7f79761dd000-7f79761e1000 rw-p 00000000 00:00 0
7f79761e1000-7f79761e2000 r--p 0001f000 fd:00 391164 /lib64/ld-2.12.so
7f79761e2000-7f79761e3000 rw-p 00020000 fd:00 391164 /lib64/ld-2.12.so
7f79761e3000-7f79761e4000 rw-p 00000000 00:00 0
7f79761e4000-7f797623c000 r-xp 00000000 fd:00 4301625 /home/svn/trunk/test
7f797643b000-7f797643f000 r--p 00057000 fd:00 4301625 /home/svn/trunk/test
7f797643f000-7f7976441000 rw-p 0005b000 fd:00 4301625 /home/svn/trunk/test
7f7977c9d000-7f7977d25000 rw-p 00000000 00:00 0 [heap]
7fffabf43000-7fffabf58000 rw-p 00000000 00:00 0 [stack]
7fffabfff000-7fffac000000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
Usually that happens, when you accidentally delete an object, that is owned by a static, or global object, that will try to release it after main() has finished.
Prefer to use std::shared_ptr<> or std::unique_ptr<> depending on the ownership for owning pointers, and raw pointers for non owning pointers. Then any explicit delete in your code is a code smell. delete needs a raw pointer, which can only be a non owning pointer, so another part of the code owns this object and should take care of deleting it.
I am using the code from this tutorial to experiment with OCCI:
http://oradim.blogspot.com.br/2009/08/getting-started-with-occi-linux-version_16.html
When I try to run the application, it gives me the following error:
*** 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]
I am running on ubuntu machine with netbeans to compile. Compilation goes like this:
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
After debugging, I can see that it crashes here (user, password and ip ommited, but I use the same user and password to connect to sqlplus), but I don't know why crashes:
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);
}
From your output it isn't clear your catch block is catching anything.
If you properly cleanup the connection and environment, these errors may go away.
env->terminateConnection(con);
Environment::terminateEnvironment(env);
I'm using boost program options for my project but I can't get program exit without crashing. It crashes after exiting main function.
*** glibc detected *** bin/poolserver: double free or corruption (fasttop): 0x0000000002562100 ***
======= Backtrace: =========
/lib/libc.so.6(+0x71e16)[0x7f64a7a3be16]
/lib/libc.so.6(cfree+0x6c)[0x7f64a7a40b8c]
/usr/lib/libstdc++.so.6(_ZNSsD1Ev+0x39)[0x7f64a826cee9]
/lib/libc.so.6(__cxa_finalize+0xa5)[0x7f64a7a00995]
/usr/local/lib/libboost_program_options.so.1.53.0(+0x2a6d6)[0x7f64a85026d6]
======= Memory map: ========
00400000-004a5000 r-xp 00000000 08:01 29687876 /var/coins/poolserver/cmake/build/bin/poolserver
006a4000-006a6000 rw-p 000a4000 08:01 29687876 /var/coins/poolserver/cmake/build/bin/poolserver
02562000-025a5000 rw-p 00000000 00:00 0 [heap]
7f64a0000000-7f64a0021000 rw-p 00000000 00:00 0
7f64a0021000-7f64a4000000 ---p 00000000 00:00 0
7f64a5b2e000-7f64a5b2f000 ---p 00000000 00:00 0
7f64a5b2f000-7f64a632f000 rw-p 00000000 00:00 0
7f64a632f000-7f64a633b000 r-xp 00000000 08:01 9166850 /lib/libnss_files-2.11.3.so
7f64a633b000-7f64a653a000 ---p 0000c000 08:01 9166850 /lib/libnss_files-2.11.3.so
7f64a653a000-7f64a653b000 r--p 0000b000 08:01 9166850 /lib/libnss_files-2.11.3.so
7f64a653b000-7f64a653c000 rw-p 0000c000 08:01 9166850 /lib/libnss_files-2.11.3.so
7f64a653c000-7f64a653d000 ---p 00000000 00:00 0
7f64a653d000-7f64a6d3d000 rw-p 00000000 00:00 0
7f64a6d3d000-7f64a6d44000 r-xp 00000000 08:01 9166856 /lib/librt-2.11.3.so
7f64a6d44000-7f64a6f43000 ---p 00007000 08:01 9166856 /lib/librt-2.11.3.so
7f64a6f43000-7f64a6f44000 r--p 00006000 08:01 9166856 /lib/librt-2.11.3.so
7f64a6f44000-7f64a6f45000 rw-p 00007000 08:01 9166856 /lib/librt-2.11.3.so
7f64a6f45000-7f64a6f5c000 r-xp 00000000 08:01 22677552 /usr/lib/libz.so.1.2.3.4
7f64a6f5c000-7f64a715b000 ---p 00017000 08:01 22677552 /usr/lib/libz.so.1.2.3.4
7f64a715b000-7f64a715c000 rw-p 00016000 08:01 22677552 /usr/lib/libz.so.1.2.3.4
7f64a715c000-7f64a7171000 r-xp 00000000 08:01 9166863 /lib/libnsl-2.11.3.so
7f64a7171000-7f64a7370000 ---p 00015000 08:01 9166863 /lib/libnsl-2.11.3.so
7f64a7370000-7f64a7371000 r--p 00014000 08:01 9166863 /lib/libnsl-2.11.3.so
7f64a7371000-7f64a7372000 rw-p 00015000 08:01 9166863 /lib/libnsl-2.11.3.so
7f64a7372000-7f64a7374000 rw-p 00000000 00:00 0
7f64a7374000-7f64a737c000 r-xp 00000000 08:01 9166865 /lib/libcrypt-2.11.3.so
7f64a737c000-7f64a757b000 ---p 00008000 08:01 9166865 /lib/libcrypt-2.11.3.so
7f64a757b000-7f64a757c000 r--p 00007000 08:01 9166865 /lib/libcrypt-2.11.3.so
7f64a757c000-7f64a757d000 rw-p 00008000 08:01 9166865 /lib/libcrypt-2.11.3.so
7f64a757d000-7f64a75ab000 rw-p 00000000 00:00 0
7f64a75ab000-7f64a75ae000 r-xp 00000000 08:01 12394545 /usr/local/lib/libboost_system.so.1.53.0
7f64a75ae000-7f64a77ad000 ---p 00003000 08:01 12394545 /usr/local/lib/libboost_system.so.1.53.0
7f64a77ad000-7f64a77ae000 rw-p 00002000 08:01 12394545 /usr/local/lib/libboost_system.so.1.53.0
7f64a77ae000-7f64a77c5000 r-xp 00000000 08:01 9166854 /lib/libpthread-2.11.3.so
7f64a77c5000-7f64a79c4000 ---p 00017000 08:01 9166854 /lib/libpthread-2.11.3.so
7f64a79c4000-7f64a79c5000 r--p 00016000 08:01 9166854 /lib/libpthread-2.11.3.so
7f64a79c5000-7f64a79c6000 rw-p 00017000 08:01 9166854 /lib/libpthread-2.11.3.so
7f64a79c6000-7f64a79ca000 rw-p 00000000 00:00 0
7f64a79ca000-7f64a7b23000 r-xp 00000000 08:01 9166859 /lib/libc-2.11.3.so
7f64a7b23000-7f64a7d22000 ---p 00159000 08:01 9166859 /lib/libc-2.11.3.so
7f64a7d22000-7f64a7d26000 r--p 00158000 08:01 9166859 /lib/libc-2.11.3.so
7f64a7d26000-7f64a7d27000 rw-p 0015c000 08:01 9166859 /lib/libc-2.11.3.so
7f64a7d27000-7f64a7d2c000 rw-p 00000000 00:00 0
7f64a7d2c000-7f64a7d42000 r-xp 00000000 08:01 9166851 /lib/libgcc_s.so.1
7f64a7d42000-7f64a7f41000 ---p 00016000 08:01 9166851 /lib/libgcc_s.so.1
7f64a7f41000-7f64a7f42000 rw-p 00015000 08:01 9166851 /lib/libgcc_s.so.1
7f64a7f42000-7f64a7fc2000 r-xp 00000000 08:01 9166872 /lib/libm-2.11.3.so
7f64a7fc2000-7f64a81c2000 ---p 00080000 08:01 9166872 /lib/libm-2.11.3.so
7f64a81c2000-7f64a81c3000 r--p 00080000 08:01 9166872 /lib/libm-2.11.3.so
7f64a81c3000-7f64a81c4000 rw-p 00081000 08:01 9166872 /lib/libm-2.11.3.so
7f64a81c4000-7f64a82ba000 r-xp 00000000 08:01 22677469 /usr/lib/libstdc++.so.6.0.13
7f64a82ba000-7f64a84ba000 ---p 000f6000 08:01 22677469 /usr/lib/libstdc++.so.6.0.13
7f64a84ba000-7f64a84c1000 r--p 000f6000 08:01 22677469 /usr/lib/libstdc++.so.6.0.13
7f64a84c1000-7f64a84c3000 rw-p 000fd000 08:01 22677469 /usr/lib/libstdc++.so.6.0.13
7f64a84c3000-7f64a84d8000 rw-p 00000000 00:00 0
7f64a84d8000-7f64a853c000 r-xp 00000000 08:01 12394575 /usr/local/lib/libboost_program_options.so.1.53.0
7f64a853c000-7f64a873b000 ---p 00064000 08:01 12394575 /usr/local/lib/libboost_program_options.so.1.53.0
7f64a873b000-7f64a8740000 rw-p 00063000 08:01 12394575 /usr/local/lib/libboost_program_options.so.1.53.0
7f64a8740000-7f64a8757000 r-xp 00000000 08:01 12394559 /usr/local/lib/libboost_thread.so.1.53.0
7f64a8757000-7f64a8956000 ---p 00017000 08:01 12394559 /usr/local/lib/libboost_thread.so.1.53.0
7f64a8956000-7f64a8958000 rw-p 00016000 08:01 12394559 /usr/local/lib/libboost_thread.so.1.53.0
7f64a8958000-7f64a8969000 r-xp 00000000 08:01 22682328 /usr/lib/libboost_date_time.so.1.42.0
7f64a8969000-7f64a8b68000 ---p 00011000 08:01 22682328 /usr/lib/libboost_date_time.so.1.42.0
7f64a8b68000-7f64a8b6a000 rw-p 00010000 08:01 22682328 /usr/lib/libboost_date_time.so.1.42.0Aborted
I'm using cmake with such options:
set(Boost_USE_STATIC_LIBS OFF)
set(Boost_USE_MULTITHREADED ON)
set(Boost_USE_STATIC_RUNTIME OFF)
set(Boost_ALL_DYN_LINK ON)
I tried static linking and it worked for some time but now it crashes with any settings.
OS: Debian Squeeze
If it helps https://github.com/Intel/poolserver this is my source
Your question doesn't give us the code directly, but looking through github, I suspect the boost program options have nothing to do with it.
The error says
double free or corruption
I suspect it's this:
void DatabaseConnectionMySQL::Close()
{
delete this;
}
Problem was with boost package from debian. Compiling newest boost from source fixed crash.
I am having trouble deleting my pointers that I have created. The program creates a double pointer to point to the threads. Then it creates threads dynamically. At the end it deletes them but I am getting a glibc error. It uses boost to create the threads. What is really puzzling is that I delete a similar double pointer the same exact way and that executes fine. The issue is at the end of the code block under the heading of /*clean up*/:
boost :: thread** thrds;
//create threads and bind to p_variantforloop_t
thrds = new boost::thread*[numThreads];
for (int i = 1; i <= numThreads; i++)
thrds[i] = new boost::thread(boost::bind(&p_variantforloop_t,
E, A, D, (i*n-n)/i ,(i*n)/n, numThreads, n));
/* join threads */
for (int i = 0; i < numThreads; i++)
thrds[i]->join();
/* cleanup */
for (int i = 0; i < numThreads; i++)
delete thrds[i];
delete[] thrds;
the error is:
*** glibc detected *** ./hw9: munmap_chunk(): invalid pointer: 0x0957d480 ***
======= Backtrace: =========
/lib/tls/i686/cmov/libc.so.6(+0x6b591)[0x264591]
/lib/tls/i686/cmov/libc.so.6(+0x6c80e)[0x26580e]
/usr/lib/libstdc++.so.6(_ZdlPv+0x21)[0x529741]
./hw9[0x804a0d1]
/lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xe6)[0x20fbd6]
./hw9[0x8049871]
======= Memory map: ========
001f9000-0034c000 r-xp 00000000 08:02 1128663 /lib/tls/i686/cmov/libc-2.11.1.so
0034c000-0034d000 ---p 00153000 08:02 1128663 /lib/tls/i686/cmov/libc-2.11.1.so
0034d000-0034f000 r--p 00153000 08:02 1128663 /lib/tls/i686/cmov/libc-2.11.1.so
0034f000-00350000 rw-p 00155000 08:02 1128663 /lib/tls/i686/cmov/libc-2.11.1.so
00350000-00353000 rw-p 00000000 00:00 0
0046e000-00557000 r-xp 00000000 08:02 982712 /usr/lib/libstdc++.so.6.0.13
00557000-00558000 ---p 000e9000 08:02 982712 /usr/lib/libstdc++.so.6.0.13
00558000-0055c000 r--p 000e9000 08:02 982712 /usr/lib/libstdc++.so.6.0.13
0055c000-0055d000 rw-p 000ed000 08:02 982712 /usr/lib/libstdc++.so.6.0.13
0055d000-00564000 rw-p 00000000 00:00 0
005ad000-005d1000 r-xp 00000000 08:02 1130719 /lib/tls/i686/cmov/libm-2.11.1.so
005d1000-005d2000 r--p 00023000 08:02 1130719 /lib/tls/i686/cmov/libm-2.11.1.so
005d2000-005d3000 rw-p 00024000 08:02 1130719 /lib/tls/i686/cmov/libm-2.11.1.so
00950000-00965000 r-xp 00000000 08:02 1130743 /lib/tls/i686/cmov/libpthread-2.11.1.so
00965000-00966000 r--p 00014000 08:02 1130743 /lib/tls/i686/cmov/libpthread-2.11.1.so
00966000-00967000 rw-p 00015000 08:02 1130743 /lib/tls/i686/cmov/libpthread-2.11.1.so
00967000-00969000 rw-p 00000000 00:00 0
00a67000-00a7a000 r-xp 00000000 08:02 176445 /usr/lib/libboost_thread.so.1.40.0
00a7a000-00a7b000 r--p 00013000 08:02 176445 /usr/lib/libboost_thread.so.1.40.0
00a7b000-00a7c000 rw-p 00014000 08:02 176445 /usr/lib/libboost_thread.so.1.40.0
00bc7000-00be2000 r-xp 00000000 08:02 1128318 /lib/ld-2.11.1.so
00be2000-00be3000 r--p 0001a000 08:02 1128318 /lib/ld-2.11.1.so
00be3000-00be4000 rw-p 0001b000 08:02 1128318 /lib/ld-2.11.1.so
00c34000-00c3b000 r-xp 00000000 08:02 1130745 /lib/tls/i686/cmov/librt-2.11.1.so
00c3b000-00c3c000 r--p 00006000 08:02 1130745 /lib/tls/i686/cmov/librt-2.11.1.so
00c3c000-00c3d000 rw-p 00007000 08:02 1130745 /lib/tls/i686/cmov/librt-2.11.1.so
00ccf000-00cd0000 r-xp 00000000 00:00 0 [vdso]
00e85000-00ea2000 r-xp 00000000 08:02 1128359 /lib/libgcc_s.so.1
00ea2000-00ea3000 r--p 0001c000 08:02 1128359 /lib/libgcc_s.so.1
00ea3000-00ea4000 rw-p 0001d000 08:02 1128359 /lib/libgcc_s.so.1
08048000-0804e000 r-xp 00000000 00:1d 10184 /home/tparisi/Desktop/source_code_hw5/hw9
0804e000-0804f000 r--p 00005000 00:1d 10184 /home/tparisi/Desktop/source_code_hw5/hw9
0804f000-08050000 rw-p 00006000 00:1d 10184 /home/tparisi/Desktop/source_code_hw5/hw9
0957d000-0959e000 rw-p 00000000 00:00 0 [heap]
b68bf000-b68c0000 ---p 00000000 00:00 0
b68c0000-b70c0000 rw-p 00000000 00:00 0
b70c0000-b70c1000 ---p 00000000 00:00 0
b70c1000-b78c4000 rw-p 00000000 00:00 0
b78e8000-b78eb000 rw-p 00000000 00:00 0
bfc07000-bfc1c000 rw-p 00000000 00:00 0 [stack]
Aborted
You omit first element of the array when creating thread object. It stays with uninitialized pointer value, causing the invalid pointer error later.
There is also an issue of writing to memory immediately after the last element of array, which you also do in the problematic loop (i.e. the first for in your code).