Sudden Error in '': free(): invalid pointer - c++

I am having this segmentation fault after a colleague of mine committed some new features on our project. The new feature has no impact on the following function, but only increases the QString argument size.
After some debugging, I've figured out that segmentation fault was happening after the following function return.
I need to know why does it is happening and why my workaround worked, and if the workaround is safe?
I must say that the following snippet it is working on older version of Qt (5.3.1 with gcc 4.8) that I have now installed (Qt 5.9 with gcc 7.0).
It also works nicely on Debug rather that Release compiling mode on Qt.
Finally, I don't want to discuss the effectiveness of this encryption method, but the entitled problem.
The crashes happens immediately after function returning, I have no idea why.
QString Utility::encrypt(QString text)
{
QByteArray textUtf8 = text.toUtf8();
// Convert QString to Char
const char *srcString = textUtf8.constData();
char encrypted[ textUtf8.size() ];
// Copy Char by Char
strcpy(encrypted,srcString);
for(int u=0; u<textUtf8.size(); u++ ){
encrypted[u]++;
}
return QString::fromUtf8(encrypted);
}
The output from Segmentation fault is:
*** Error in `/home/user/workspace/build-swFree-Desktop_Qt_5_9_1_GCC_64bit-Release/swFree': free(): invalid pointer: 0x0000000001cfc800 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7eff199067e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x8037a)[0x7eff1990f37a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7eff1991353c]
/home/user/workspace/build-swFree-Desktop_Qt_5_9_1_GCC_64bit-Release/swFree[0x40171f]
/home/user/workspace/build-swFree-Desktop_Qt_5_9_1_GCC_64bit-Release/swFree[0x401344]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7eff198af830]
/home/user/workspace/build-swFree-Desktop_Qt_5_9_1_GCC_64bit-Release/swFree[0x4014b9]
======= Memory map: ========
00400000-00403000 r-xp 00000000 08:01 2098854 /home/user/workspace/build-swFree-Desktop_Qt_5_9_1_GCC_64bit-Release/swFree
00602000-00603000 r--p 00002000 08:01 2098854 /home/user/workspace/build-swFree-Desktop_Qt_5_9_1_GCC_64bit-Release/swFree
00603000-00604000 rw-p 00003000 08:01 2098854 /home/user/workspace/build-swFree-Desktop_Qt_5_9_1_GCC_64bit-Release/swFree
01cdd000-01d1f000 rw-p 00000000 00:00 0 [heap]
7eff10000000-7eff10021000 rw-p 00000000 00:00 0
7eff10021000-7eff14000000 ---p 00000000 00:00 0
7eff162bb000-7eff16594000 r--p 00000000 08:01 2752945 /usr/lib/locale/locale-archive
7eff16594000-7eff16602000 r-xp 00000000 08:01 529479 /lib/x86_64-linux-gnu/libpcre.so.3.13.2
7eff16602000-7eff16802000 ---p 0006e000 08:01 529479 /lib/x86_64-linux-gnu/libpcre.so.3.13.2
7eff16802000-7eff16803000 r--p 0006e000 08:01 529479 /lib/x86_64-linux-gnu/libpcre.so.3.13.2
7eff16803000-7eff16804000 rw-p 0006f000 08:01 529479 /lib/x86_64-linux-gnu/libpcre.so.3.13.2
7eff16804000-7eff1690c000 r-xp 00000000 08:01 529373 /lib/x86_64-linux-gnu/libm-2.23.so
7eff1690c000-7eff16b0b000 ---p 00108000 08:01 529373 /lib/x86_64-linux-gnu/libm-2.23.so
7eff16b0b000-7eff16b0c000 r--p 00107000 08:01 529373 /lib/x86_64-linux-gnu/libm-2.23.so
7eff16b0c000-7eff16b0d000 rw-p 00108000 08:01 529373 /lib/x86_64-linux-gnu/libm-2.23.so
7eff16b0d000-7eff16c1c000 r-xp 00000000 08:01 529394 /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2
7eff16c1c000-7eff16e1b000 ---p 0010f000 08:01 529394 /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2
7eff16e1b000-7eff16e1c000 r--p 0010e000 08:01 529394 /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2
7eff16e1c000-7eff16e1d000 rw-p 0010f000 08:01 529394 /lib/x86_64-linux-gnu/libglib-2.0.so.0.4800.2
7eff16e1d000-7eff16e1e000 rw-p 00000000 00:00 0
7eff16e1e000-7eff16e1f000 r-xp 00000000 08:01 2763515 /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0.4800.2
7eff16e1f000-7eff1701e000 ---p 00001000 08:01 2763515 /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0.4800.2
7eff1701e000-7eff1701f000 r--p 00000000 08:01 2763515 /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0.4800.2
7eff1701f000-7eff17020000 rw-p 00001000 08:01 2763515 /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0.4800.2
7eff17020000-7eff17023000 r-xp 00000000 08:01 529264 /lib/x86_64-linux-gnu/libdl-2.23.so
7eff17023000-7eff17222000 ---p 00003000 08:01 529264 /lib/x86_64-linux-gnu/libdl-2.23.so
7eff17222000-7eff17223000 r--p 00002000 08:01 529264 /lib/x86_64-linux-gnu/libdl-2.23.so
7eff17223000-7eff17224000 rw-p 00003000 08:01 529264 /lib/x86_64-linux-gnu/libdl-2.23.so
7eff17224000-7eff1723d000 r-xp 00000000 08:01 529327 /lib/x86_64-linux-gnu/libz.so.1.2.8
7eff1723d000-7eff1743c000 ---p 00019000 08:01 529327 /lib/x86_64-linux-gnu/libz.so.1.2.8
7eff1743c000-7eff1743d000 r--p 00018000 08:01 529327 /lib/x86_64-linux-gnu/libz.so.1.2.8
7eff1743d000-7eff1743e000 rw-p 00019000 08:01 529327 /lib/x86_64-linux-gnu/libz.so.1.2.8
7eff1743e000-7eff18c21000 r--p 00000000 08:01 2379568 /opt/Qt5.9.1/5.9.1/gcc_64/lib/libicudata.so.56.1
7eff18c21000-7eff18e20000 ---p 017e3000 08:01 2379568 /opt/Qt5.9.1/5.9.1/gcc_64/lib/libicudata.so.56.1
7eff18e20000-7eff18e21000 r--p 017e2000 08:01 2379568 /opt/Qt5.9.1/5.9.1/gcc_64/lib/libicudata.so.56.1
7eff18e21000-7eff18fc6000 r-xp 00000000 08:01 2379575 /opt/Qt5.9.1/5.9.1/gcc_64/lib/libicuuc.so.56.1
7eff18fc6000-7eff191c6000 ---p 001a5000 08:01 2379575 /opt/Qt5.9.1/5.9.1/gcc_64/lib/libicuuc.so.56.1
7eff191c6000-7eff191d6000 r--p 001a5000 08:01 2379575 /opt/Qt5.9.1/5.9.1/gcc_64/lib/libicuuc.so.56.1
7eff191d6000-7eff191d7000 rw-p 001b5000 08:01 2379575 /opt/Qt5.9.1/5.9.1/gcc_64/lib/libicuuc.so.56.1
7eff191d7000-7eff191d9000 rw-p 00000000 00:00 0
7eff191d9000-7eff19462000 r-xp 00000000 08:01 2379569 /opt/Qt5.9.1/5.9.1/gcc_64/lib/libicui18n.so.56.1
7eff19462000-7eff19661000 ---p 00289000 08:01 2379569 /opt/Qt5.9.1/5.9.1/gcc_64/lib/libicui18n.so.56.1
7eff19661000-7eff1966f000 r--p 00288000 08:01 2379569 /opt/Qt5.9.1/5.9.1/gcc_64/lib/libicui18n.so.56.1
7eff1966f000-7eff19671000 rw-p 00296000 08:01 2379569 /opt/Qt5.9.1/5.9.1/gcc_64/lib/libicui18n.so.56.1
7eff19671000-7eff19672000 rw-p 00000000 00:00 0
7eff19672000-7eff1968a000 r-xp 00000000 08:01 529099 /lib/x86_64-linux-gnu/libpthread-2.23.so
7eff1968a000-7eff19889000 ---p 00018000 08:01 529099 /lib/x86_64-linux-gnu/libpthread-2.23.so
7eff19889000-7eff1988a000 r--p 00017000 08:01 529099 /lib/x86_64-linux-gnu/libpthread-2.23.so
7eff1988a000-7eff1988b000 rw-p 00018000 08:01 529099 /lib/x86_64-linux-gnu/libpthread-2.23.so
7eff1988b000-7eff1988f000 rw-p 00000000 00:00 0
7eff1988f000-7eff19a4f000 r-xp 00000000 08:01 529417 /lib/x86_64-linux-gnu/libc-2.23.so
7eff19a4f000-7eff19c4f000 ---p 001c0000 08:01 529417 /lib/x86_64-linux-gnu/libc-2.23.so
7eff19c4f000-7eff19c53000 r--p 001c0000 08:01 529417 /lib/x86_64-linux-gnu/libc-2.23.so
7eff19c53000-7eff19c55000 rw-p 001c4000 08:01 529417 /lib/x86_64-linux-gnu/libc-2.23.so
7eff19c55000-7eff19c59000 rw-p 00000000 00:00 0
7eff19c59000-7eff19c6f000 r-xp 00000000 08:01 529390 /lib/x86_64-linux-gnu/libgcc_s.so.1
7eff19c6f000-7eff19e6e000 ---p 00016000 08:01 529390 /lib/x86_64-linux-gnu/libgcc_s.so.1
7eff19e6e000-7eff19e6f000 rw-p 00015000 08:01 529390 /lib/x86_64-linux-gnu/libgcc_s.so.1
7eff19e6f000-7eff19fe1000 r-xp 00000000 08:01 2764170 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7eff19fe1000-7eff1a1e1000 ---p 00172000 08:01 2764170 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7eff1a1e1000-7eff1a1eb000 r--p 00172000 08:01 2764170 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7eff1a1eb000-7eff1a1ed000 rw-p 0017c000 08:01 2764170 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7eff1a1ed000-7eff1a1f1000 rw-p 00000000 00:00 0
7eff1a1f1000-7eff1a71b000 r-xp 00000000 08:01 2380819 /opt/Qt5.9.1/5.9.1/gcc_64/lib/libQt5Core.so.5.9.1
7eff1a71b000-7eff1a91a000 ---p 0052a000 08:01 2380819 /opt/Qt5.9.1/5.9.1/gcc_64/lib/libQt5Core.so.5.9.1
7eff1a91a000-7eff1a926000 r--p 00529000 08:01 2380819 /opt/Qt5.9.1/5.9.1/gcc_64/lib/libQt5Core.so.5.9.1
7eff1a926000-7eff1a928000 rw-p 00535000 08:01 2380819 /opt/Qt5.9.1/5.9.1/gcc_64/lib/libQt5Core.so.5.9.1
7eff1a928000-7eff1a92b000 rw-p 00000000 00:00 0
7eff1a92b000-7eff1a951000 r-xp 00000000 08:01 524312 /lib/x86_64-linux-gnu/ld-2.23.so
7eff1ab21000-7eff1ab2b000 rw-p 00000000 00:00 0
7eff1ab4d000-7eff1ab50000 rw-p 00000000 00:00 0
7eff1ab50000-7eff1ab51000 r--p 00025000 08:01 524312 /lib/x86_64-linux-gnu/ld-2.23.so
7eff1ab51000-7eff1ab52000 rw-p 00026000 08:01 524312 /lib/x86_64-linux-gnu/ld-2.23.so
7eff1ab52000-7eff1ab53000 rw-p 00000000 00:00 0
7ffe006ae000-7ffe006cf000 rw-p 00000000 00:00 0 [stack]
7ffe006e2000-7ffe006e4000 r--p 00000000 00:00 0 [vvar]
7ffe006e4000-7ffe006e6000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
The workaround I've figured out was the following:
char encrypted[ textUtf8.size() + 1 ];
However, I confess that I don't know why it worked. Could someone explain it?
Is there any better solution?

The problem is that data in the QByteArray returned by text.toUtf8() is not NUL-terminated, and strcpy() expects a NUL-terminated string... since it doesn't get one, it will happily keep copying extra garbage-bytes past the end of your encrypted array until it finally does encounter a zero-byte somewhere, and corrupt your stack, which leads to the crash when the function returns.
Also, your encrypted array is not large enough to hold the NUL byte that strcpy() wants to place in it.
A fix would be something like this:
char encrypted[ textUtf8.size() + 1 ]; // +1 to hold the NUL terminator byte
memcpy(encrypted, srcString, textUtf8.size() );
encrypted[textUtf8.size()] = '\0'; // place NUL-terminator byte
[...]
Also, a portability note: dynamically-sized arrays aren't part of the C++ standard, so your declaring char encrypted[ textUtf8.size() + 1]; is working for you only because your compiler includes a non-standard extension to enable that. If you want your code to be portable (as all self-respecting Qt code should be ;)), you may want to use a std::vector or other similar higher-level mechanism instead of a dynamically-sized array.

char encrypted[ textUtf8.size() + 1 ];
Because of size we have to use a null character to terminate a string array
For example try this
#include<iostream>
#include<string>
using namespace std;
int main()
{
char textUtf8[5] ="hello";
}
You will see warning "Initializer string for char array is too long"

Related

Why am I getting an invalid pointer error when using MySQL C++ Connector tutorial code?

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.

C++/openCV - why does showing an image create a linux segmentation fault? (openCV bug?)

I am doing some image processing stuff however when I try to show an image which is originated from my webcam I get the following output to my terminal:
debug end of loop
debug 1
*** Error in `./mySoftware': corrupted double-linked list: 0x0917db00 ***
======= Backtrace: =========
/lib/i386-linux-gnu/libc.so.6(+0x67257)[0xb6975257]
/lib/i386-linux-gnu/libc.so.6(+0x6d577)[0xb697b577]
/lib/i386-linux-gnu/libc.so.6(+0x6d854)[0xb697b854]
/lib/i386-linux-gnu/libc.so.6(+0x6f37f)[0xb697d37f]
/lib/i386-linux-gnu/libc.so.6(__libc_malloc+0xc5)[0xb697ee05]
/usr/lib/i386-linux-gnu/libstdc++.so.6(_Znwj+0x27)[0xb6ba7187]
/usr/lib/i386-linux-gnu/libQtGui.so.4(+0x33596d)[0xb609296d]
/usr/lib/i386-linux-gnu/libQtGui.so.4(_ZN8QPainter5beginEP12QPaintDevice+0x17a)[0xb600b2aa]
/usr/lib/i386-linux-gnu/libQtGui.so.4(_ZN8QPainterC2EP12QPaintDevice+0xf9)[0xb600be49]
/usr/lib/i386-linux-gnu/libQtGui.so.4(_ZN14QWidgetPrivate10drawWidgetEP12QPaintDeviceRK7QRegionRK6QPointiP8QPainterP19QWidgetBackingStore+0x549)[0xb5eec1e9]
/usr/lib/i386-linux-gnu/libQtGui.so.4(+0x3842fe)[0xb60e12fe]
/usr/lib/i386-linux-gnu/libQtGui.so.4(_ZN14QWidgetPrivate16syncBackingStoreEv+0xa7)[0xb5ede057]
/usr/lib/i386-linux-gnu/libQtGui.so.4(_ZN7QWidget5eventEP6QEvent+0x536)[0xb5ef2626]
/usr/lib/i386-linux-gnu/libQtGui.so.4(_ZN19QApplicationPrivate13notify_helperEP7QObjectP6QEvent+0x9a)[0xb5e9364a]
/usr/lib/i386-linux-gnu/libQtGui.so.4(_ZN12QApplication6notifyEP7QObjectP6QEvent+0x2e1)[0xb5e9a951]
/usr/lib/i386-linux-gnu/libQtCore.so.4(_ZN16QCoreApplication14notifyInternalEP7QObjectP6QEvent+0x8a)[0xb5bb457a]
/usr/lib/i386-linux-gnu/libQtCore.so.4(_ZN23QCoreApplicationPrivate16sendPostedEventsEP7QObjectiP11QThreadData+0x3a6)[0xb5bb8266]
/usr/lib/i386-linux-gnu/libQtCore.so.4(_ZN16QCoreApplication16sendPostedEventsEP7QObjecti+0x25)[0xb5bb8595]
/usr/lib/i386-linux-gnu/libQtCore.so.4(+0x1b6f91)[0xb5be6f91]
/lib/i386-linux-gnu/libglib-2.0.so.0(g_main_context_dispatch+0x299)[0xb58bced9]
/lib/i386-linux-gnu/libglib-2.0.so.0(+0x47179)[0xb58bd179]
/lib/i386-linux-gnu/libglib-2.0.so.0(g_main_context_iteration+0x34)[0xb58bd244]
/usr/lib/i386-linux-gnu/libQtCore.so.4(_ZN20QEventDispatcherGlib13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE+0x75)[0xb5be70f5]
/usr/lib/i386-linux-gnu/libQtGui.so.4(+0x1f3b66)[0xb5f50b66]
/usr/lib/i386-linux-gnu/libQtCore.so.4(_ZN16QCoreApplication13processEventsE6QFlagsIN10QEventLoop17ProcessEventsFlagEE+0x47)[0xb5bb85e7]
/usr/local/lib/libopencv_highgui.so.3.1(cvWaitKey+0x7e)[0xb729a90e]
/usr/local/lib/libopencv_highgui.so.3.1(_ZN2cv7waitKeyEi+0x1b)[0xb729662b]
./mySoftware[0x804c68f]
/lib/i386-linux-gnu/libc.so.6(__libc_start_main+0xf7)[0xb6926637]
./mySoftware[0x804a851]
======= Memory map: ========
08048000-0805e000 r-xp 00000000 08:01 4194822 /home/John/mySoftware
0805e000-0805f000 r--p 00015000 08:01 4194822 /home/John/mySoftware
0805f000-08060000 rw-p 00016000 08:01 4194822 /home/John/mySoftware
09109000-0973d000 rw-p 00000000 00:00 0 [heap]
ac628000-ac688000 rw-s 00000000 00:05 57147463 /SYSV00000000 (deleted)
ac688000-ac693000 r-xp 00000000 08:01 5250432 /usr/lib/i386-linux-gnu/libjbig.so.0
ac693000-ac694000 r--p 0000a000 08:01 5250432 /usr/lib/i386-linux-gnu/libjbig.so.0
ac694000-ac697000 rw-p 0000b000 08:01 5250432 /usr/lib/i386-linux-gnu/libjbig.so.0
ac697000-ac70d000 r-xp 00000000 08:01 5250908 /usr/lib/i386-linux-gnu/libtiff.so.5.2.4
ac70d000-ac70e000 r--p 00075000 08:01 5250908 /usr/lib/i386-linux-gnu/libtiff.so.5.2.4
ac70e000-ac710000 rw-p 00076000 08:01 5250908 /usr/lib/i386-linux-gnu/libtiff.so.5.2.4
ac710000-ac711000 rw-p 00000000 00:00 0
ac711000-ac765000 r-xp 00000000 08:01 5249612 /usr/lib/i386-linux-gnu/libQtSvg.so.4.8.7
ac765000-ac766000 ---p 00054000 08:01 5249612 /usr/lib/i386-linux-gnu/libQtSvg.so.4.8.7
ac766000-ac767000 r--p 00054000 08:01 5249612 /usr/lib/i386-linux-gnu/libQtSvg.so.4.8.7
ac767000-ac768000 rw-p 00055000 08:01 5249612 /usr/lib/i386-linux-gnu/libQtSvg.so.4.8.7
ac768000-ac7c3000 r-xp 00000000 08:01 5250461 /usr/lib/i386-linux-gnu/liblcms2.so.2.0.6
ac7c3000-ac7c4000 r--p 0005a000 08:01 5250461 /usr/lib/i386-linux-gnu/liblcms2.so.2.0.6
ac7c4000-ac7c8000 rw-p 0005b000 08:01 5250461 /usr/lib/i386-linux-gnu/liblcms2.so.2.0.6
ac7c8000-ac843000 r-xp 00000000 08:01 5250536 /usr/lib/i386-linux-gnu/libmng.so.2.0.2
ac843000-ac844000 r--p 0007b000 08:01 5250536 /usr/lib/i386-linux-gnu/libmng.so.2.0.2
ac844000-ac845000 rw-p 0007c000 08:01 5250536 /usr/lib/i386-linux-gnu/libmng.so.2.0.2
ac865000-ac8c2000 r-xp 00000000 08:01 5250436 /usr/lib/i386-linux-gnu/libjpeg.so.8.0.2
ac8c2000-ac8c3000 r--p 0005c000 08:01 5250436 /usr/lib/i386-linux-gnu/libjpeg.so.8.0.2
ac8c3000-ac8c4000 rw-p 0005d000 08:01 5250436 /usr/lib/i386-linux-gnu/libjpeg.so.8.0.2
ac8cd000-ac8d4000 r-xp 00000000 08:01 5378249 /usr/lib/i386-linux-gnu/qt4/plugins/imageformats/libqtiff.so
ac8d4000-ac8d5000 r--p 00006000 08:01 5378249 /usr/lib/i386-linux-gnu/qt4/plugins/imageformats/libqtiff.so
ac8d5000-ac8d6000 rw-p 00007000 08:01 5378249 /usr/lib/i386-linux-gnu/qt4/plugins/imageformats/libqtiff.so
ac8d6000-ac8db000 r-xp 00000000 08:01 5378247 /usr/lib/i386-linux-gnu/qt4/plugins/imageformats/libqsvg.so
ac8db000-ac8dc000 r--p 00004000 08:01 5378247 /usr/lib/i386-linux-gnu/qt4/plugins/imageformats/libqsvg.so
ac8dc000-ac8dd000 rw-p 00005000 08:01 5378247 /usr/lib/i386-linux-gnu/qt4/plugins/imageformats/libqsvg.so
ac8dd000-ac8e2000 r-xp 00000000 08:01 5378246 /usr/lib/i386-linux-gnu/qt4/plugins/imageformats/libqmng.so
ac8e2000-ac8e3000 r--p 00004000 08:01 5378246 /usr/lib/i386-linux-gnu/qt4/plugins/imageformats/libqmng.so
ac8e3000-ac8e4000 rw-p 00005000 08:01 5378246 /usr/lib/i386-linux-gnu/qt4/plugins/imageformats/libqmng.so
ac8e4000-aca2e000 rw-s 00000000 00:05 57114694 /SYSV00000000 (deleted)
aca2e000-aca39000 r-xp 00000000 08:01 8652185 /lib/i386-linux-gnu/libnss_files-2.23.so
aca39000-aca3a000 r--p 0000a000 08:01 8652185 /lib/i386-linux-gnu/libnss_files-2.23.so
aca3a000-aca3b000 rw-p 0000b000 08:01 8652185 /lib/i386-linux-gnu/libnss_files-2.23.so
aca3b000-aca41000 rw-p 00000000 00:00 0
aca41000-aca4c000 r-xp 00000000 08:01 8652195 /lib/i386-linux-gnu/libnss_nis-2.23.so
aca4c000-aca4d000 r--p 0000a000 08:01 8652195 /lib/i386-linux-gnu/libnss_nis-2.23.so
aca4d000-aca4e000 rw-p 0000b000 08:01 8652195 /lib/i386-linux-gnu/libnss_nis-2.23.so
aca4e000-aca65000 r-xp 00000000 08:01 8652179 /lib/i386-linux-gnu/libnsl-2.23.so
aca65000-aca66000 r--p 00016000 08:01 8652179 /lib/i386-linux-gnu/libnsl-2.23.so
aca66000-aca67000 rw-p 00017000 08:01 8652179 /lib/i386-linux-gnu/libnsl-2.23.so
aca67000-aca69000 rw-p 00000000 00:00 0
aca69000-aca71000 r-xp 00000000 08:01 8652181 /lib/i386-linux-gnu/libnss_compat-2.23.so
aca71000-aca72000 r--p 00007000 08:01 8652181 /lib/i386-linux-gnu/libnss_compat-2.23.so
aca72000-aca73000 rw-p 00008000 08:01 8652181 /lib/i386-linux-gnu/libnss_compat-2.23.so
aca73000-acb55000 rw-p 00000000 00:00 0
acb55000-acba0000 r--p 00000000 08:01 6426266 /usr/share/fonts/truetype/noto/NotoSans-Regular.ttf
acba0000-accf5000 r-xp 00000000 08:01 5249597 /usr/lib/i386-linux-gnu/libQtNetwork.so.4.8.7
accf5000-accf6000 ---p 00155000 08:01 5249597 /usr/lib/i386-linux-gnu/libQtNetwork.so.4.8.7
accf6000-accf9000 r--p 00155000 08:01 5249597 /usr/lib/i386-linux-gnu/libQtNetwork.so.4.8.7
accf9000-accfa000 rw-p 00158000 08:01 5249597 /usr/lib/i386-linux-gnu/libQtNetwork.so.4.8.7
accfa000-ad11a000 r-xp 00000000 08:01 5249624 /usr/lib/i386-linux-gnu/libQtXmlPatterns.so.4.8.7
ad11a000-ad11b000 ---p 00420000 08:01 5249624 /usr/lib/i386-linux-gnu/libQtXmlPatterns.so.4.8.7
ad11b000-ad136000 r--p 00420000 08:01 5249624 /usr/lib/i386-linux-gnu/libQtXmlPatterns.so.4.8.7
ad136000-ad137000 rw-p 0043b000 08:01 5249624 /usr/lib/i386-linux-gnu/libQtXmlPatterns.so.4.8.7
ad137000-ad176000 r-xp 00000000 08:01 5249609 /usr/lib/i386-linux-gnu/libQtSql.so.4.8.7
ad176000-ad177000 r--p 0003e000 08:01 5249609 /usr/lib/i386-linux-gnu/libQtSql.so.4.8.7
ad177000-ad178000 rw-p 0003f000 08:01 5249609 /usr/lib/i386-linux-gnu/libQtSql.so.4.8.7
ad178000-ad410000 r-xp 00000000 08:01 5249603 /usr/lib/i386-linux-gnu/libQtScript.so.4.8.7
ad410000-ad419000 r--p 00297000 08:01 5249603 /usr/lib/i386-linux-gnu/libQtScript.so.4.8.7
ad419000-ad41a000 rw-p 002a0000 08:01 5249603 /usr/lib/i386-linux-gnu/libQtScript.so.4.8.7
ad41a000-ad42a000 rw-p 00000000 00:00 0
ad42a000-ad7c8000 r-xp 00000000 08:01 5249582 /usr/lib/i386-linux-gnu/libQtDeclarative.so.4.8.7
ad7c8000-ad7c9000 ---p 0039e000 08:01 5249582 /usr/lib/i386-linux-gnu/libQtDeclarative.so.4.8.7
ad7c9000-ad7d8000 r--p 0039e000 08:01 5249582 /usr/lib/i386-linux-gnu/libQtDeclarative.so.4.8.7
ad7d8000-ad7da000 rw-p 003ad000 08:01 5249582 /usr/lib/i386-linux-gnu/libQtDeclarative.so.4.8.7
ad7da000-ad827000 r-xp 00000000 08:01 5378229 /usr/lib/i386-linux-gnu/qt4/plugins/accessible/libqtaccessiblewidgets.so
ad827000-ad82a000 r--p 0004c000 08:01 5378229 /usr/lib/i386-linux-gnu/qt4/plugins/accessible/libqtaccessiblewidgets.so
ad82a000-ad82b000 rw-p 0004f000 08:01 5378229 /usr/lib/i386-linux-gnu/qt4/plugins/accessible/libqtaccessiblewidgets.so
ad82b000-ad86d000 r-xp 00000000 08:01 5249621 /usr/lib/i386-linux-gnu/libQtXml.so.4.8.7
ad86d000-ad86e000 ---p 00042000 08:01 5249621 /usr/lib/i386-linux-gnu/libQtXml.so.4.8.7
ad86e000-ad86f000 r--p 00042000 08:01 5249621 /usr/lib/i386-linux-gnu/libQtXml.so.4.8.7
ad86f000-ad870000 rw-p 00043000 08:01 5249621 /usr/lib/i386-linux-gnu/libQtXml.so.4.8.7
ad870000-ad8f5000 r-xp 00000000 08:01 5249579 /usr/lib/i386-linux-gnu/libQtDBus.so.4.8.7
ad8f5000-ad8f6000 r--p 00084000 08:01 5249579 /usr/lib/i386-linux-gnu/libQtDBus.so.4.8.7
ad8f6000-ad8f7000 rw-p 00085000 08:01 5249579 /usr/lib/i386-linux-gnu/libQtDBus.so.4.8.7
ad8f7000-ad934000 r-xp 00000000 08:01 5378230 /usr/lib/i386-linux-gnu/qt4/plugins/accessiblebridge/libqspiaccessiblebridge.so
ad934000-ad935000 r--p 0003c000 08:01 5378230 /usr/lib/i386-linux-gnu/qt4/plugins/accessiblebridge/libqspiaccessiblebridge.so
ad935000-ad936000 rw-p 0003d000 08:01 5378230 /usr/lib/i386-linux-gnu/qt4/plugins/accessiblebridge/libqspiaccessiblebridge.so
ad936000-ad981000 r--p 00000000 08:01 6426266 /usr/share/fonts/truetype/noto/NotoSans-Regular.ttf
ad981000-ad9b6000 r-xp 00000000 08:01 5375962 /usr/lib/i386-linux-gnu/gtk-2.0/2.10.0/engines/libmurrine.so
ad9b6000-ad9b7000 r--p 00034000 08:01 5375962 /usr/lib/i386-linux-gnu/gtk-2.0/2.10.0/engines/libmurrine.so
ad9b7000-ad9b8000 rw-p 00035000 08:01 5375962 /usr/lib/i386-linux-gnu/gtk-2.0/2.10.0/engines/libmurrine.so
ad9b8000-ad9e6000 r-xp 00000000 08:01 5249751 /usr/lib/i386-linux-gnu/libatspi.so.0.0.1
ad9e6000-ad9e8000 r--p 0002d000 08:01 5249751 /usr/lib/i386-linux-gnu/libatspi.so.0.0.1
ad9e8000-ad9e9000 rw-p 0002f000 08:01 5249751 /usr/lib/i386-linux-gnu/libatspi.so.0.0.1
ad9e9000-ada1a000 r-xp 00000000 08:01 5249745 /usr/lib/i386-linux-gnu/libatk-bridge-2.0.so.0.0.0
ada1a000-ada1b000 r--p 00030000 08:01 5249745 /usr/lib/i386-linux-gnu/libatk-bridge-2.0.so.0.0.0
ada1b000-ada1c000 rw-p 00031000 08:01 5249745 /usr/lib/i386-linux-gnu/libatk-bridge-2.0.so.0.0.0
ada1c000-ada1d000 rw-p 00000000 00:00 0
ada1d000-ada21000 r-xp 00000000 08:01 5378248 /usr/lib/i386-linux-gnu/qt4/plugins/imageformats/libqtga.so
ada21000-ada22000 r--p 00003000 08:01 5378248 /usr/lib/i386-linux-gnu/qt4/plugins/imageformats/libqtga.so
ada22000-ada23000 rw-p 00004000 08:01 5378248 /usr/lib/i386-linux-gnu/qt4/plugins/imageformats/libqtga.so
ada23000-ada2a000 r-xp 00000000 08:01 5378245 /usr/lib/i386-linux-gnu/qt4/plugins/imageformats/libqjpeg.so
ada2a000-ada2b000 r--p 00006000 08:01 5378245 /usr/lib/i386-linux-gnu/qt4/plugins/imageformats/libqjpeg.so
ada2b000-ada2c000 rw-p 00007000 08:01 5378245 /usr/lib/i386-linux-gnu/qt4/plugins/imageformats/libqjpeg.so
ada2c000-ada33000 r-xp 00000000 08:01 5378244 /usr/lib/i386-linux-gnu/qt4/plugins/imageformats/libqico.so
ada33000-ada34000 r--p 00006000 08:01 5378244 /usr/lib/i386-linux-gnu/qt4/plugins/imageformats/libqico.so
ada34000-ada35000 rw-p 00007000 08:01 5378244 /usr/lib/i386-linux-gnu/qt4/plugins/imageformats/libqico.so
ada35000-ada3b000 r-xp 00000000 08:01 5378243 /usr/lib/i386-linux-gnu/qt4/plugins/imageformats/libqgif.so
ada3b000-ada3c000 r--p 00005000 08:01 5378243 /usr/lib/i386-linux-gnu/qt4/plugins/imageformats/libqgif.so
ada3c000-ada3d000 rw-p 00006000 08:01 5378243 /usr/lib/i386-linux-gnu/qt4/plugins/imageformats/libqgif.so
ada3d000-ada97000 r-xp 00000000 08:01 5375984 /usr/lib/i386-linux-gnu/gtk-2.0/modules/libgail.so
ada97000-ada98000 r--p 00059000 08:01 5375984 /usr/lib/i386-linux-gnu/gtk-2.0/modules/libgail.so
ada98000-ada99000 rw-p 0005a000 08:01 5375984 /usr/lib/i386-linux-gnu/gtk-2.0/modules/libgail.so
ada99000-adaad000 r-xp 00000000 08:01 8652132 /lib/i386-linux-gnu/libgpg-error.so.0.17.0
adaad000-adaae000 r--p 00013000 08:01 8652132 /lib/i386-linux-gnu/libgpg-error.so.0.17.0
adaae000-adaaf000 rw-p 00014000 08:01 8652132 /lib/i386-linux-gnu/libgpg-error.so.0.17.0
adaaf000-adb5a000 r-xp 00000000 08:01 8652128 /lib/i386-linux-gnu/libgcrypt.so.20.0.5
adb5a000-adb5b000 r--p 000aa000 08:01 8652128 /lib/i386-linux-gnu/libgcrypt.so.20.0.5
adb5b000-adb5e000 rw-p 000ab000 08:01 8652128 /lib/i386-linux-gnu/libgcrypt.so.20.0.5
adb5e000-adbe8000 r-xp 00000000 08:01 5250174 /usr/lib/i386-linux-gnu/libgmp.so.10.3.0
adbe8000-adbe9000 r--p 00089000 08:01 5250174 /usr/lib/i386-linux-gnu/libgmp.so.10.3.0
adbe9000-adbea000 rw-p 0008a000 08:01 5250174 /usr/lib/i386-linux-gnu/libgmp.so.10.3.0
adbea000-adc1d000 r-xp 00000000 08:01 5250349 /usr/lib/i386-linux-gnu/libhogweed.so.4.2
adc1d000-adc1e000 r--p 00032000 08:01 5250349 /usr/lib/i386-linux-gnu/libhogweed.so.4.2
adc1e000-adc1f000 rw-p 00033000 08:01 5250349 /usr/lib/i386-linux-gnu/libhogweed.so.4.2
adc1f000-adc59000 r-xp 00000000 08:01 5250586 /usr/lib/i386-linux-gnu/libnettle.so.6.2
adc59000-adc5a000 r--p 00039000 08:01 5250586 /usr/lib/i386-linux-gnu/libnettle.so.6.2
adc5a000-adc5b000 rw-p 0003a000 08:01 5250586 /usr/lib/i386-linux-gnu/libnettle.so.6.2
adc5b000-adc6e000 r-xp 00000000 08:01 5250885 /usr/lib/i386-linux-gnu/libtasn1.so.6.5.1
adc6e000-adc6f000 r--p 00012000 08:01 5250885 /usr/lib/i386-linux-gnu/libtasn1.so.6.5.1
adc6f000-adc70000 rw-p 00013000 08:01 5250885 /usr/lib/i386-linux-gnu/libtasn1.so.6.5.1
adc70000-adca2000 r-xp 00000000 08:01 5250389 /usr/lib/i386-linux-gnu/libidn.so.11.6.15
adca2000-adca3000 r--p 00031000 08:01 5250389 /usr/lib/i386-linux-gnu/libidn.so.11.6.15
adca3000-adca4000 rw-p 00032000 08:01 5250389 /usr/lib/i386-linux-gnu/libidn.so.11.6.15
adca4000-adcff000 r-xp 00000000 08:01 5250650 /usr/lib/i386-linux-gnu/libp11-kit.so.0.1.0
adcff000-add00000 ---p 0005b000 08:01 5250650 /usr/lib/i386-linux-gnu/libp11-kit.so.0.1.0
add00000-add05000 r--p 0005b000 08:01 5250650 /usr/lib/i386-linux-gnu/libp11-kit.so.0.1.0
add05000-add06000 rw-p 00060000 08:01 5250650 /usr/lib/i386-linux-gnu/libp11-kit.so.0.1.0
add06000-add91000 r-xp 00000000 08:01 8652254 /lib/i386-linux-gnu/libsystemd.so.0.14.0
add91000-add93000 r--p 0008a000 08:01 8652254 /lib/i386-linux-gnu/libsystemd.so.0.14.0
add93000-add94000 rw-p 0008c000 08:01 8652254 /lib/i386-linux-gnu/libsystemd.so.0.14.0
add94000-addb8000 r-xp 00000000 08:01 8652155 /lib/i386-linux-gnu/liblzma.so.5.0.0
addb8000-addb9000 r--p 00023000 08:01 8652155 /lib/i386-linux-gnu/liblzma.so.5.0.0
addb9000-addba000 rw-p 00024000 08:01 8652155 /lib/i386-linux-gnu/liblzma.so.5.0.0
addba000-addcc000 r-xp 00000000 08:01 5249755 /usr/lib/i386-linux-gnu/libavahi-client.so.3.2.9
addcc000-addcd000 r--p 00011000 08:01 5249755 /usr/lib/i386-linux-gnu/libavahi-client.so.3.2.9
addcd000-addce000 rw-p 00012000 08:01 5249755 /usr/lib/i386-linux-gnu/libavahi-client.so.3.2.9
addce000-addda000 r-xp 00000000 08:01 5249757 /usr/lib/i386-linux-gnu/libavahi-common.so.3.5.3
addda000-adddb000 r--p 0000b000 08:01 5249757 /usr/lib/i386-linux-gnu/libavahi-common.so.3.5.3
adddb000-adddc000 rw-p 0000c000 08:01 5249757 /usr/lib/i386-linux-gnu/libavahi-common.so.3.5.3
adddc000-adf2b000 r-xp 00000000 08:01 5250194 /usr/lib/i386-linux-gnu/libgnutls.so.30.6.2
adf2b000-adf2c000 ---p 0014f000 08:01 5250194 /usr/lib/i386-linux-gnu/libgnutls.so.30.6.2
adf2c000-adf32000 r--p 0014f000 08:01 5250194 /usr/lib/i386-linux-gnu/libgnutls.so.30.6.2
adf32000-adf33000 rw-p 00155000 08:01 5250194 /usr/lib/i386-linux-gnu/libgnutls.so.30.6.2
adf33000-adf34000 rw-p 00000000 00:00 0
adf34000-adf8b000 r-xp 00000000 08:01 8652104 /lib/i386-linux-gnu/libdbus-1.so.3.14.6
adf8b000-adf8c000 ---p 00057000 08:01 8652104 /lib/i386-linux-gnu/libdbus-1.so.3.14.6
adf8c000-adf8d000 r--p 00057000 08:01 8652104 /lib/i386-linux-gnu/libdbus-1.so.3.14.6
adf8d000-adf8e000 rw-p 00058000 08:01 8652104 /lib/i386-linux-gnu/libdbus-1.so.3.14.6
adf8e000-adfb7000 r-xp 00000000 08:01 5249911 /usr/lib/i386-linux-gnu/libdbus-glib-1.so.2.3.3
adfb7000-adfb8000 ---p 00029000 08:01 5249911 /usr/lib/i386-linux-gnu/libdbus-glib-1.so.2.3.3
adfb8000-adfb9000 r--p 00029000 08:01 5249911 /usr/lib/i386-linux-gnu/libdbus-glib-1.so.2.3.3
adfb9000-adfba000 rw-p 0002a000 08:01 5249911 /usr/lib/i386-linux-gnu/libdbus-glib-1.so.2.3.3
adfba000-ae191000 r-xp 00000000 08:01 5251112 /usr/lib/i386-linux-gnu/libxml2.so.2.9.3
ae191000-ae192000 ---p 001d7000 08:01 5251112 /usr/lib/i386-linux-gnu/libxml2.so.2.9.3
ae192000-ae196000 r--p 001d7000 08:01 5251112 /usr/lib/i386-linux-gnu/libxml2.so.2.9.3
ae196000-ae197000 rw-p 001db000 08:01 5251112 /usr/lib/i386-linux-gnu/libxml2.so.2.9.3
ae197000-ae198000 rw-p 00000000 00:00 0
ae198000-ae1cb000 r-xp 00000000 08:01 5250108 /usr/lib/i386-linux-gnu/libgconf-2.so.4.1.5
ae1cb000-ae1cc000 r--p 00032000 08:01 5250108 /usr/lib/i386-linux-gnu/libgconf-2.so.4.1.5
ae1cc000-ae1cd000 rw-p 00033000 08:01 5250108 /usr/lib/i386-linux-gnu/libgconf-2.so.4.1.5
ae1cd000-ae23b000 r-xp 00000000 08:01 5250190 /usr/lib/i386-linux-gnu/libgnomevfs-2.so.0.2400.4
ae23b000-ae23d000 r--p 0006d000 08:01 5250190 /usr/lib/i386-linux-gnu/libgnomevfs-2.so.0.2400.4
ae23d000-ae23e000 rw-p 0006f000 08:01 5250190 /usr/lib/i386-linux-gnu/libgnomevfs-2.so.0.2400.4
ae23e000-ae23f000 rw-p 00000000 00:00 0
ae23f000-ae246000 r-xp 00000000 08:01 5249908 /usr/lib/i386-linux-gnu/libdatrie.so.1.3.3
ae246000-ae247000 ---p 00007000 08:01 5249908 /usr/lib/i386-linux-gnu/libdatrie.so.1.3.3
ae247000-ae248000 r--p 00007000 08:01 5249908 /usr/lib/i386-linux-gnu/libdatrie.so.1.3.3
ae248000-ae249000 rw-p 00008000 08:01 5249908 /usr/lib/i386-linux-gnu/libdatrie.so.1.3.3
ae249000-ae26d000 r-xp 00000000 08:01 5250214 /usr/lib/i386-linux-gnu/libgraphite2.so.3.0.1
ae26d000-ae26e000 ---p 00024000 08:01 5250214 /usr/lib/i386-linux-gnu/libgraphite2.so.3.0.1
ae26e000-ae26f000 r--p 00024000 08:01 5250214 /usr/lib/i386-linux-gnu/libgraphite2.so.3.0.1
ae26f000-ae270000 rw-p 00025000 08:01 5250214 /usr/lib/i386-linux-gnu/libgraphite2.so.3.0.1
ae270000-ae279000 r-xp 00000000 08:01 5250897 /usr/lib/i386-linux-gnu/libthai.so.0.2.4
ae279000-ae27a000 r--p 00008000 08:01 5250897 /usr/lib/i386-linux-gnu/libthai.so.0.2.4
ae27a000-ae27b000 rw-p 00009000 08:01 5250897 /usr/lib/i386-linux-gnu/libthai.so.0.2.4
ae27b000-ae2dd000 r-xp 00000000 08:01 5250125 /usr/lib/i386-linux-gnu/libharfbuzz.so.0.10000.1
ae2dd000-ae2de000 r--p 00061000 08:01 5250125 /usr/lib/i386-linux-gnu/libharfbuzz.so.0.10000.1
ae2de000-ae2df000 rw-p 00062000 08:01 5250125 /usr/lib/i386-linux-gnu/libharfbuzz.so.0.10000.1
ae2df000-ae2f3000 r-xp 00000000 08:01 8652238 /lib/i386-linux-gnu/libresolv-2.23.so
ae2f3000-ae2f4000 ---p 00014000 08:01 8652238 /lib/i386-linux-gnu/libresolv-2.23.so
ae2f4000-ae2f5000 r--p 00014000 08:01 8652238 /lib/i386-linux-gnu/libresolv-2.23.so
ae2f5000-ae2f6000 rw-p 00015000 08:01 8652238 /lib/i386-linux-gnu/libresolv-2.23.so
ae2f6000-ae2f8000 rw-p 00000000 00:00 0
ae2f8000-ae31a000 r-xp 00000000 08:01 8652244 /lib/i386-linux-gnu/libselinux.so.1
ae31a000-ae31b000 ---p 00022000 08:01 8652244 /lib/i386-linux-gnu/libselinux.so.1
ae31b000-ae31c000 r--p 00022000 08:01 8652244 /lib/i386-linux-gnu/libselinux.so.1
ae31c000-ae31d000 rw-p 00023000 08:01 8652244 /lib/i386-linux-gnu/libselinux.so.1
ae31d000-ae31e000 rw-p 00000000 00:00 0
ae31e000-ae327000 r-xp 00000000 08:01 5251084 /usr/lib/i386-linux-gnu/libxcb-render.so.0.0.0
ae327000-ae328000 r--p 00008000 08:01 5251084 /usr/lib/i386-linux-gnu/libxcb-render.so.0.0.0
ae328000-ae329000 rw-p 00009000 08:01 5251084 /usr/lib/i386-linux-gnu/libxcb-render.so.0.0.0
ae329000-ae3d2000 r-xp 00000000 08:01 5250690 /usr/lib/i386-linux-gnu/libpixman-1.so.0.33.6
ae3d2000-ae3d8000 r--p 000a8000 08:01 5250690 /usr/lib/i386-linux-gnu/libpixman-1.so.0.33.6
ae3d8000-ae3d9000 rw-p 000ae000 08:01 5250690 /usr/lib/i386-linux-gnu/libpixman-1.so.0.33.6
ae3d9000-ae427000 r-xp 00000000 08:01 5250660 /usr/lib/i386-linux-gnu/libpango-1.0.so.0.3800.1
ae427000-ae428000 ---p 0004e000 08:01 5250660 /usr/lib/i386-linux-gnu/libpango-1.0.so.0.3800.1
ae428000-ae429000 r--p 0004e000 08:01 5250660 /usr/lib/i386-linux-gnu/libpango-1.0.so.0.3800.1
ae429000-ae42a000 rw-p 0004f000 08:01 5250660 /usr/lib/i386-linux-gnu/libpango-1.0.so.0.3800.1
ae42a000-ae5ee000 r-xp 00000000 08:01 5243379 /usr/lib/i386-linux-gnu/libgio-2.0.so.0.4800.1
ae5ee000-ae5ef000 ---p 001c4000 08:01 5243379 /usr/lib/i386-linux-gnu/libgio-2.0.so.0.4800.1
ae5ef000-ae5f1000 r--p 001c4000 08:01 5243379 /usr/lib/i386-linux-gnu/libgio-2.0.so.0.4800.1
ae5f1000-ae5f2000 rw-p 001c6000 08:01 5243379 /usr/lib/i386-linux-gnu/libgio-2.0.so.0.4800.1
ae5f2000-ae5f3000 rw-p 00000000 00:00 0
ae5f3000-ae61a000 r-xp 00000000 08:01 5250171 /usr/lib/i386-linux-gnu/libgdk_pixbuf-2.0.so.0.3200.2
ae61a000-ae61b000 r--p 00026000 08:01 5250171 /usr/lib/i386-linux-gnu/libgdk_pixbuf-2.0.so.0.3200.2
ae61b000-ae61c000 rw-p 00027000 08:01 5250171 /usr/lib/i386-linux-gnu/libgdk_pixbuf-2.0.so.0.3200.2
ae61c000-ae759000 r-xp 00000000 08:01 5249809 /usr/lib/i386-linux-gnu/libcairo.so.2.11400.6
ae759000-ae75b000 r--p 0013c000 08:01 5249809 /usr/lib/i386-linux-gnu/libcairo.so.2.11400.6
ae75b000-ae75c000 rw-p 0013e000 08:01 5249809 /usr/lib/i386-linux-gnu/libcairo.so.2.11400.6
ae75c000-ae75d000 rw-p 00000000 00:00 0
ae75d000-ae781000 r-xp 00000000 08:01 5249743 /usr/lib/i386-linux-gnu/libatk-1.0.so.0.21809.1
ae781000-ae783000 r--p 00023000 08:01 5249743 /usr/lib/i386-linux-gnu/libatk-1.0.so.0.21809.1
ae783000-ae784000 rw-p 00025000 08:01 5249743 /usr/lib/i386-linux-gnu/libatk-1.0.so.0.21809.1
ae784000-ae841000 r-xp 00000000 08:01 5250124 /usr/lib/i386-linux-gnu/libgdk-x11-2.0.so.0.2400.30
ae841000-ae843000 r--p 000bc000 08:01 5250124 /usr/lib/i386-linux-gnu/libgdk-x11-2.0.so.0.2400.30
ae843000-ae844000 rw-p 000be000 08:01 5250124 /usr/lib/i386-linux-gnu/libgdk-x11-2.0.so.0.2400.30
ae844000-aed31000 r-xp 00000000 08:01 5250308 /usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0.2400.30
aed31000-aed32000 ---p 004ed000 08:01 5250308 /usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0.2400.30
aed32000-aed36000 r--p 004ed000 08:01 5250308 /usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0.2400.30
aed36000-aed38000 rw-p 004f1000 08:01 5250308 /usr/lib/i386-linux-gnu/libgtk-x11-2.0.so.0.2400.30
aed38000-aed3a000 rw-p 00000000 00:00 0 Aborted
This is what my code looks like:
int main(int argc, char** argv)
{
while(1)
{
while(1)
{
// some algorithms
cerr<<"debug end of loop"<<endl;
}
imshow("imgFrame", imgFrame);
cerr<<"debug 1"<<endl;
char c = (char)waitKey(10);
cerr<<"debug 2"<<endl;
if( c == 27 ) break;
cap >> imgFrame;
}
return 0;
}
the corresponding valgrind output: https://pastebin.com/ch1h2aFL
Could someone explain me what I may be doing wrong? is this an openCV bug?
the code being used: https://pastebin.com/brtR3eHn
You call imshow first, cap>>imgFrame later which might be the cause at the first run.

C++ CURL - Postfields in a while loop

I wrote simple code to try to post data in CURL in a while loop. I'm getting an error that CURL failed to initialize. I ran the simple tutorial that given online, that works and CURL initialized, but I'm having trouble with my code. Please help
I'm new to C++ and very new to CURL so please do explain in more details how to proceed.
Code:
#include <iostream>
#include <string>
#include <sstream>
#include <stdio.h>
#include <curl/curl.h>
using namespace std;
int main(void)
{
// Variables
const char *Myurl = "http://127.0.0.1:3000";
const char *Myid = "My_ID_0";
CURL *curl;
CURLcode res;
/* In windows, this will init the winsock stuff */
curl_global_init(CURL_GLOBAL_ALL);
/* get a curl handle */
curl = curl_easy_init();
if(curl) {
/* First set the URL that is about to receive our POST. This URL can
just as well be a https:// URL if that is what should receive the
data. */
curl_easy_setopt(curl, CURLOPT_URL, Myurl);
/* Now specify the POST data */
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, Myid);
}
double value1[6] = {-6,-5,-4,-3,-2,-1};
double value2[6] = { 1, 2, 3, 4, 5, 6};
for(int i=0; i<6; i++){
string stringvalue1 = std::to_string(value1[i]);
string stringvalue2 = std::to_string(value2[i]);
const char *Myvalue1 = stringvalue1.c_str();
const char *Myvalue2 = stringvalue2.c_str();
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, Myvalue1);
curl_easy_setopt(curl, CURLOPT_POSTFIELDS, Myvalue2);
/* Perform the request, res will get the return code */
res = curl_easy_perform(curl);
/* Check for errors */
if(res != CURLE_OK)
fprintf(stderr, "curl_easy_perform() failed: %s\n",
curl_easy_strerror(res));
/* always cleanup */
curl_easy_cleanup(curl);
cout << "URL output should be: " << Myurl << "/" << Myid;
cout << "/" << Myvalue1 << "/" << Myvalue2 << endl;
}
curl_global_cleanup();
return 0;
}
Error:
curl_easy_perform() failed: Failed initialization
*** Error in `/home/me/me_workplace/Stacksocial-cURL-postURL-example/Debug/Stacksocial-cURL-postURL-example': double free or corruption (!prev): 0x0000000001a6c6d0 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f66af5307e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x7fe0a)[0x7f66af538e0a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f66af53c98c]
/usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4(+0x20c9c)[0x7f66afe3ac9c]
/home/me/me_workplace/Stacksocial-cURL-postURL-example/Debug/Stacksocial-cURL-postURL-example[0x4019b2]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f66af4d9830]
/home/me/me_workplace/Stacksocial-cURL-postURL-example/Debug/Stacksocial-cURL-postURL-example[0x401689]
======= Memory map: ========
00400000-00403000 r-xp 00000000 08:01 3147659 /home/me/me_workplace/Stacksocial-cURL-postURL-example/Debug/Stacksocial-cURL-postURL-example
00602000-00603000 r--p 00002000 08:01 3147659 /home/me/me_workplace/Stacksocial-cURL-postURL-example/Debug/Stacksocial-cURL-postURL-example
00603000-00604000 rw-p 00003000 08:01 3147659 /home/me/me_workplace/Stacksocial-cURL-postURL-example/Debug/Stacksocial-cURL-postURL-example
01a3c000-01a8d000 rw-p 00000000 00:00 0 [heap]
7f66a4000000-7f66a4021000 rw-p 00000000 00:00 0
7f66a4021000-7f66a8000000 ---p 00000000 00:00 0
7f66aa74b000-7f66aa754000 r-xp 00000000 08:01 1703998 /lib/x86_64-linux-gnu/libcrypt-2.23.so
7f66aa754000-7f66aa953000 ---p 00009000 08:01 1703998 /lib/x86_64-linux-gnu/libcrypt-2.23.so
7f66aa953000-7f66aa954000 r--p 00008000 08:01 1703998 /lib/x86_64-linux-gnu/libcrypt-2.23.so
7f66aa954000-7f66aa955000 rw-p 00009000 08:01 1703998 /lib/x86_64-linux-gnu/libcrypt-2.23.so
7f66aa955000-7f66aa983000 rw-p 00000000 00:00 0
7f66aa983000-7f66aaa52000 r-xp 00000000 08:01 3549154 /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6
7f66aaa52000-7f66aac52000 ---p 000cf000 08:01 3549154 /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6
7f66aac52000-7f66aac55000 r--p 000cf000 08:01 3549154 /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6
7f66aac55000-7f66aac57000 rw-p 000d2000 08:01 3549154 /usr/lib/x86_64-linux-gnu/libsqlite3.so.0.8.6
7f66aac57000-7f66aac58000 rw-p 00000000 00:00 0
7f66aac58000-7f66aac9e000 r-xp 00000000 08:01 3548692 /usr/lib/x86_64-linux-gnu/libhx509.so.5.0.0
7f66aac9e000-7f66aae9e000 ---p 00046000 08:01 3548692 /usr/lib/x86_64-linux-gnu/libhx509.so.5.0.0
7f66aae9e000-7f66aaea0000 r--p 00046000 08:01 3548692 /usr/lib/x86_64-linux-gnu/libhx509.so.5.0.0
7f66aaea0000-7f66aaea2000 rw-p 00048000 08:01 3548692 /usr/lib/x86_64-linux-gnu/libhx509.so.5.0.0
7f66aaea2000-7f66aaea3000 rw-p 00000000 00:00 0
7f66aaea3000-7f66aaeb1000 r-xp 00000000 08:01 3548674 /usr/lib/x86_64-linux-gnu/libheimbase.so.1.0.0
7f66aaeb1000-7f66ab0b0000 ---p 0000e000 08:01 3548674 /usr/lib/x86_64-linux-gnu/libheimbase.so.1.0.0
7f66ab0b0000-7f66ab0b1000 r--p 0000d000 08:01 3548674 /usr/lib/x86_64-linux-gnu/libheimbase.so.1.0.0
7f66ab0b1000-7f66ab0b2000 rw-p 0000e000 08:01 3548674 /usr/lib/x86_64-linux-gnu/libheimbase.so.1.0.0
7f66ab0b2000-7f66ab0d9000 r-xp 00000000 08:01 3549319 /usr/lib/x86_64-linux-gnu/libwind.so.0.0.0
7f66ab0d9000-7f66ab2d9000 ---p 00027000 08:01 3549319 /usr/lib/x86_64-linux-gnu/libwind.so.0.0.0
7f66ab2d9000-7f66ab2da000 r--p 00027000 08:01 3549319 /usr/lib/x86_64-linux-gnu/libwind.so.0.0.0
7f66ab2da000-7f66ab2db000 rw-p 00028000 08:01 3549319 /usr/lib/x86_64-linux-gnu/libwind.so.0.0.0
7f66ab2db000-7f66ab2f0000 r-xp 00000000 08:01 3549072 /usr/lib/x86_64-linux-gnu/libroken.so.18.1.0
7f66ab2f0000-7f66ab4ef000 ---p 00015000 08:01 3549072 /usr/lib/x86_64-linux-gnu/libroken.so.18.1.0
7f66ab4ef000-7f66ab4f0000 r--p 00014000 08:01 3549072 /usr/lib/x86_64-linux-gnu/libroken.so.18.1.0
7f66ab4f0000-7f66ab4f1000 rw-p 00015000 08:01 3549072 /usr/lib/x86_64-linux-gnu/libroken.so.18.1.0
7f66ab4f1000-7f66ab521000 r-xp 00000000 08:01 3548672 /usr/lib/x86_64-linux-gnu/libhcrypto.so.4.1.0
7f66ab521000-7f66ab721000 ---p 00030000 08:01 3548672 /usr/lib/x86_64-linux-gnu/libhcrypto.so.4.1.0
7f66ab721000-7f66ab722000 r--p 00030000 08:01 3548672 /usr/lib/x86_64-linux-gnu/libhcrypto.so.4.1.0
7f66ab722000-7f66ab723000 rw-p 00031000 08:01 3548672 /usr/lib/x86_64-linux-gnu/libhcrypto.so.4.1.0
7f66ab723000-7f66ab724000 rw-p 00000000 00:00 0
7f66ab724000-7f66ab7c3000 r-xp 00000000 08:01 3548117 /usr/lib/x86_64-linux-gnu/libasn1.so.8.0.0
7f66ab7c3000-7f66ab9c2000 ---p 0009f000 08:01 3548117 /usr/lib/x86_64-linux-gnu/libasn1.so.8.0.0
7f66ab9c2000-7f66ab9c3000 r--p 0009e000 08:01 3548117 /usr/lib/x86_64-linux-gnu/libasn1.so.8.0.0
7f66ab9c3000-7f66ab9c6000 rw-p 0009f000 08:01 3548117 /usr/lib/x86_64-linux-gnu/libasn1.so.8.0.0
7f66ab9c6000-7f66aba4a000 r-xp 00000000 08:01 3548768 /usr/lib/x86_64-linux-gnu/libkrb5.so.26.0.0
7f66aba4a000-7f66abc49000 ---p 00084000 08:01 3548768 /usr/lib/x86_64-linux-gnu/libkrb5.so.26.0.0
7f66abc49000-7f66abc4c000 r--p 00083000 08:01 3548768 /usr/lib/x86_64-linux-gnu/libkrb5.so.26.0.0
7f66abc4c000-7f66abc4f000 rw-p 00086000 08:01 3548768 /usr/lib/x86_64-linux-gnu/libkrb5.so.26.0.0
7f66abc4f000-7f66abc50000 rw-p 00000000 00:00 0
7f66abc50000-7f66abc58000 r-xp 00000000 08:01 3548676 /usr/lib/x86_64-linux-gnu/libheimntlm.so.0.1.0
7f66abc58000-7f66abe57000 ---p 00008000 08:01 3548676 /usr/lib/x86_64-linux-gnu/libheimntlm.so.0.1.0
7f66abe57000-7f66abe58000 r--p 00007000 08:01 3548676 /usr/lib/x86_64-linux-gnu/libheimntlm.so.0.1.0
7f66abe58000-7f66abe59000 rw-p 00008000 08:01 3548676 /usr/lib/x86_64-linux-gnu/libheimntlm.so.0.1.0
7f66abe59000-7f66abe5c000 r-xp 00000000 08:01 1708766 /lib/x86_64-linux-gnu/libkeyutils.so.1.5
7f66abe5c000-7f66ac05b000 ---p 00003000 08:01 1708766 /lib/x86_64-linux-gnu/libkeyutils.so.1.5
7f66ac05b000-7f66ac05c000 r--p 00002000 08:01 1708766 /lib/x86_64-linux-gnu/libkeyutils.so.1.5
7f66ac05c000-7f66ac05d000 rw-p 00003000 08:01 1708766 /lib/x86_64-linux-gnu/libkeyutils.so.1.5
7f66ac05d000-7f66ac060000 r-xp 00000000 08:01 1703969 /lib/x86_64-linux-gnu/libdl-2.23.so
7f66ac060000-7f66ac25f000 ---p 00003000 08:01 1703969 /lib/x86_64-linux-gnu/libdl-2.23.so
7f66ac25f000-7f66ac260000 r--p 00002000 08:01 1703969 /lib/x86_64-linux-gnu/libdl-2.23.so
7f66ac260000-7f66ac261000 rw-p 00003000 08:01 1703969 /lib/x86_64-linux-gnu/libdl-2.23.so
7f66ac261000-7f66ac268000 r-xp 00000000 08:01 3548409 /usr/lib/x86_64-linux-gnu/libffi.so.6.0.4
7f66ac268000-7f66ac467000 ---p 00007000 08:01 3548409 /usr/lib/x86_64-linux-gnu/libffi.so.6.0.4
7f66ac467000-7f66ac468000 r--p 00006000 08:01 3548409 /usr/lib/x86_64-linux-gnu/libffi.so.6.0.4
7f66ac468000-7f66ac469000 rw-p 00007000 08:01 3548409 /usr/lib/x86_64-linux-gnu/libffi.so.6.0.4
7f66ac469000-7f66ac4a6000 r-xp 00000000 08:01 3548597 /usr/lib/x86_64-linux-gnu/libgssapi.so.3.0.0
7f66ac4a6000-7f66ac6a6000 ---p 0003d000 08:01 3548597 /usr/lib/x86_64-linux-gnu/libgssapi.so.3.0.0
7f66ac6a6000-7f66ac6a7000 r--p 0003d000 08:01 3548597 /usr/lib/x86_64-linux-gnu/libgssapi.so.3.0.0
7f66ac6a7000-7f66ac6a9000 rw-p 0003e000 08:01 3548597 /usr/lib/x86_64-linux-gnu/libgssapi.so.3.0.0
7f66ac6a9000-7f66ac6aa000 rw-p 00000000 00:00 0
7f66ac6aa000-7f66ac6c3000 r-xp 00000000 08:01 3549099 /usr/lib/x86_64-linux-gnu/libsasl2.so.2.0.25
7f66ac6c3000-7f66ac8c3000 ---p 00019000 08:01 3549099 /usr/lib/x86_64-linux-gnu/libsasl2.so.2.0.25
7f66ac8c3000-7f66ac8c4000 r--p 00019000 08:01 3549099 /usr/lib/x86_64-linux-gnu/libsasl2.so.2.0.25
7f66ac8c4000-7f66ac8c5000 rw-p 0001a000 08:01 3549099 /usr/lib/x86_64-linux-gnu/libsasl2.so.2.0.25
7f66ac8c5000-7f66ac8dc000 r-xp 00000000 08:01 1703995 /lib/x86_64-linux-gnu/libresolv-2.23.so
7f66ac8dc000-7f66acadc000 ---p 00017000 08:01 1703995 /lib/x86_64-linux-gnu/libresolv-2.23.so
7f66acadc000-7f66acadd000 r--p 00017000 08:01 1703995 /lib/x86_64-linux-gnu/libresolv-2.23.so
7f66acadd000-7f66acade000 rw-p 00018000 08:01 1703995 /lib/x86_64-linux-gnu/libresolv-2.23.so
7f66acade000-7f66acae0000 rw-p 00000000 00:00 0
7f66acae0000-7f66acaea000 r-xp 00000000 08:01 3548772 /usr/lib/x86_64-linux-gnu/libkrb5support.so.0.1
7f66acaea000-7f66acce9000 ---p 0000a000 08:01 3548772 /usr/lib/x86_64-linux-gnu/libkrb5support.so.0.1
7f66acce9000-7f66accea000 r--p 00009000 08:01 3548772 /usr/lib/x86_64-linux-gnu/libkrb5support.so.0.1
7f66accea000-7f66acceb000 rw-p 0000a000 08:01 3548772 /usr/lib/x86_64-linux-gnu/libkrb5support.so.0.1
7f66acceb000-7f66accee000 r-xp 00000000 08:01 1708714 /lib/x86_64-linux-gnu/libcom_err.so.2.1
7f66accee000-7f66aceed000 ---p 00003000 08:01 1708714 /lib/x86_64-linux-gnu/libcom_err.so.2.1
7f66aceed000-7f66aceee000 r--p 00002000 08:01 1708714 /lib/x86_64-linux-gnu/libcom_err.so.2.1
7f66aceee000-7f66aceef000 rw-p 00003000 08:01 1708714 /lib/x86_64-linux-gnu/libcom_err.so.2.1
7f66aceef000-7f66acf1b000 r-xp 00000000 08:01 3548764 /usr/lib/x86_64-linux-gnu/libk5crypto.so.3.1
7f66acf1b000-7f66ad11a000 ---p 0002c000 08:01 3548764 /usr/lib/x86_64-linux-gnu/libk5crypto.so.3.1
7f66ad11a000-7f66ad11c000 r--p 0002b000 08:01 3548764 /usr/lib/x86_64-linux-gnu/libk5crypto.so.3.1
7f66ad11c000-7f66ad11d000 rw-p 0002d000 08:01 3548764 /usr/lib/x86_64-linux-gnu/libk5crypto.so.3.1
7f66ad11d000-7f66ad11e000 rw-p 00000000 00:00 0
7f66ad11e000-7f66ad1e1000 r-xp 00000000 08:01 3548770 /usr/lib/x86_64-linux-gnu/libkrb5.so.3.3
7f66ad1e1000-7f66ad3e1000 ---p 000c3000 08:01 3548770 /usr/lib/x86_64-linux-gnu/libkrb5.so.3.3
7f66ad3e1000-7f66ad3ee000 r--p 000c3000 08:01 3548770 /usr/lib/x86_64-linux-gnu/libkrb5.so.3.3
7f66ad3ee000-7f66ad3f0000 rw-p 000d0000 08:01 3548770 /usr/lib/x86_64-linux-gnu/libkrb5.so.3.3
7f66ad3f0000-7f66ad401000 r-xp 00000000 08:01 3541039 /usr/lib/x86_64-linux-gnu/libtasn1.so.6.5.1
7f66ad401000-7f66ad601000 ---p 00011000 08:01 3541039 /usr/lib/x86_64-linux-gnu/libtasn1.so.6.5.1
7f66ad601000-7f66ad602000 r--p 00011000 08:01 3541039 /usr/lib/x86_64-linux-gnu/libtasn1.so.6.5.1
7f66ad602000-7f66ad603000 rw-p 00012000 08:01 3541039 /usr/lib/x86_64-linux-gnu/libtasn1.so.6.5.1
7f66ad603000-7f66ad65c000 r-xp 00000000 08:01 3539179 /usr/lib/x86_64-linux-gnu/libp11-kit.so.0.1.0
7f66ad65c000-7f66ad85b000 ---p 00059000 08:01 3539179 /usr/lib/x86_64-linux-gnu/libp11-kit.so.0.1.0
7f66ad85b000-7f66ad865000 r--p 00058000 08:01 3539179 /usr/lib/x86_64-linux-gnu/libp11-kit.so.0.1.0
7f66ad865000-7f66ad867000 rw-p 00062000 08:01 3539179 /usr/lib/x86_64-linux-gnu/libp11-kit.so.0.1.0
7f66ad867000-7f66ad8e6000 r-xp 00000000 08:01 3548542 /usr/lib/x86_64-linux-gnu/libgmp.so.10.3.0
7f66ad8e6000-7f66adae5000 ---p 0007f000 08:01 3548542 /usr/lib/x86_64-linux-gnu/libgmp.so.10.3.0
7f66adae5000-7f66adae6000 r--p 0007e000 08:01 3548542 /usr/lib/x86_64-linux-gnu/libgmp.so.10.3.0
7f66adae6000-7f66adae7000 rw-p 0007f000 08:01 3548542 /usr/lib/x86_64-linux-gnu/libgmp.so.10.3.0
7f66adae7000-7f66adb19000 r-xp 00000000 08:01 3542647 /usr/lib/x86_64-linux-gnu/libhogweed.so.4.2
7f66adb19000-7f66add18000 ---p 00032000 08:01 3542647 /usr/lib/x86_64-linux-gnu/libhogweed.so.4.2
7f66add18000-7f66add19000 r--p 00031000 08:01 3542647 /usr/lib/x86_64-linux-gnu/libhogweed.so.4.2
7f66add19000-7f66add1a000 rw-p 00032000 08:01 3542647 /usr/lib/x86_64-linux-gnu/libhogweed.so.4.2
7f66add1a000-7f66ade22000 r-xp 00000000 08:01 1703971 /lib/x86_64-linux-gnu/libm-2.23.so
7f66ade22000-7f66ae021000 ---p 00108000 08:01 1703971 /lib/x86_64-linux-gnu/libm-2.23.so
7f66ae021000-7f66ae022000 r--p 00107000 08:01 1703971 /lib/x86_64-linux-gnu/libm-2.23.so
7f66ae022000-7f66ae023000 rw-p 00108000 08:01 1703971 /lib/x86_64-linux-gnu/libm-2.23.so
7f66ae023000-7f66ae03b000 r-xp 00000000 08:01 1703993 /lib/x86_64-linux-gnu/libpthread-2.23.so
7f66ae03b000-7f66ae23a000 ---p 00018000 08:01 1703993 /lib/x86_64-linux-gnu/libpthread-2.23.so
7f66ae23a000-7f66ae23b000 r--p 00017000 08:01 1703993 /lib/x86_64-linux-gnu/libpthread-2.23.so
7f66ae23b000-7f66ae23c000 rw-p 00018000 08:01 1703993 /lib/x86_64-linux-gnu/libpthread-2.23.so
7f66ae23c000-7f66ae240000 rw-p 00000000 00:00 0
7f66ae240000-7f66ae259000 r-xp 00000000 08:01 1708896 /lib/x86_64-linux-gnu/libz.so.1.2.8
7f66ae259000-7f66ae458000 ---p 00019000 08:01 1708896 /lib/x86_64-linux-gnu/libz.so.1.2.8
7f66ae458000-7f66ae459000 r--p 00018000 08:01 1708896 /lib/x86_64-linux-gnu/libz.so.1.2.8
7f66ae459000-7f66ae45a000 rw-p 00019000 08:01 1708896 /lib/x86_64-linux-gnu/libz.so.1.2.8
7f66ae45a000-7f66ae4a7000 r-xp 00000000 08:01 3544162 /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2.10.5
7f66ae4a7000-7f66ae6a6000 ---p 0004d000 08:01 3544162 /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2.10.5
7f66ae6a6000-7f66ae6a8000 r--p 0004c000 08:01 3544162 /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2.10.5
7f66ae6a8000-7f66ae6a9000 rw-p 0004e000 08:01 3544162 /usr/lib/x86_64-linux-gnu/libldap_r-2.4.so.2.10.5
7f66ae6a9000-7f66ae6ab000 rw-p 00000000 00:00 0
7f66ae6ab000-7f66ae6b8000 r-xp 00000000 08:01 3544163 /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2.10.5
7f66ae6b8000-7f66ae8b8000 ---p 0000d000 08:01 3544163 /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2.10.5
7f66ae8b8000-7f66ae8b9000 r--p 0000d000 08:01 3544163 /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2.10.5
7f66ae8b9000-7f66ae8ba000 rw-p 0000e000 08:01 3544163 /usr/lib/x86_64-linux-gnu/liblber-2.4.so.2.10.5
7f66ae8ba000-7f66ae901000 r-xp 00000000 08:01 3548599 /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2.2
7f66ae901000-7f66aeb00000 ---p 00047000 08:01 3548599 /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2.2
7f66aeb00000-7f66aeb02000 r--p 00046000 08:01 3548599 /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2.2
7f66aeb02000-7f66aeb04000 rw-p 00048000 08:01 3548599 /usr/lib/x86_64-linux-gnu/libgssapi_krb5.so.2.2
7f66aeb04000-7f66aec27000 r-xp 00000000 08:01 3542652 /usr/lib/x86_64-linux-gnu/libgnutls.so.30.6.2
7f66aec27000-7f66aee26000 ---p 00123000 08:01 3542652 /usr/lib/x86_64-linux-gnu/libgnutls.so.30.6.2
7f66aee26000-7f66aee31000 r--p 00122000 08:01 3542652 /usr/lib/x86_64-linux-gnu/libgnutls.so.30.6.2
7f66aee31000-7f66aee33000 rw-p 0012d000 08:01 3542652 /usr/lib/x86_64-linux-gnu/libgnutls.so.30.6.2
7f66aee33000-7f66aee34000 rw-p 00000000 00:00 0
7f66aee34000-7f66aee68000 r-xp 00000000 08:01 3542650 /usr/lib/x86_64-linux-gnu/libnettle.so.6.2
7f66aee68000-7f66af067000 ---p 00034000 08:01 3542650 /usr/lib/x86_64-linux-gnu/libnettle.so.6.2
7f66af067000-7f66af069000 r--p 00033000 08:01 3542650 /usr/lib/x86_64-linux-gnu/libnettle.so.6.2
7f66af069000-7f66af06a000 rw-p 00035000 08:01 3542650 /usr/lib/x86_64-linux-gnu/libnettle.so.6.2
7f66af06a000-7f66af085000 r-xp 00000000 08:01 3549080 /usr/lib/x86_64-linux-gnu/librtmp.so.1
7f66af085000-7f66af284000 ---p 0001b000 08:01 3549080 /usr/lib/x86_64-linux-gnu/librtmp.so.1
7f66af284000-7f66af285000 r--p 0001a000 08:01 3549080 /usr/lib/x86_64-linux-gnu/librtmp.so.1
7f66af285000-7f66af286000 rw-p 0001b000 08:01 3549080 /usr/lib/x86_64-linux-gnu/librtmp.so.1
7f66af286000-7f66af2b7000 r-xp 00000000 08:01 3539421 /usr/lib/x86_64-linux-gnu/libidn.so.11.6.15
7f66af2b7000-7f66af4b7000 ---p 00031000 08:01 3539421 /usr/lib/x86_64-linux-gnu/libidn.so.11.6.15
7f66af4b7000-7f66af4b8000 r--p 00031000 08:01 3539421 /usr/lib/x86_64-linux-gnu/libidn.so.11.6.15
7f66af4b8000-7f66af4b9000 rw-p 00032000 08:01 3539421 /usr/lib/x86_64-linux-gnu/libidn.so.11.6.15
7f66af4b9000-7f66af678000 r-xp 00000000 08:01 1703973 /lib/x86_64-linux-gnu/libc-2.23.so
7f66af678000-7f66af878000 ---p 001bf000 08:01 1703973 /lib/x86_64-linux-gnu/libc-2.23.so
7f66af878000-7f66af87c000 r--p 001bf000 08:01 1703973 /lib/x86_64-linux-gnu/libc-2.23.so
7f66af87c000-7f66af87e000 rw-p 001c3000 08:01 1703973 /lib/x86_64-linux-gnu/libc-2.23.so
7f66af87e000-7f66af882000 rw-p 00000000 00:00 0
7f66af882000-7f66af898000 r-xp 00000000 08:01 1708743 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f66af898000-7f66afa97000 ---p 00016000 08:01 1708743 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f66afa97000-7f66afa98000 rw-p 00015000 08:01 1708743 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f66afa98000-7f66afc0a000 r-xp 00000000 08:01 3543844 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f66afc0a000-7f66afe0a000 ---p 00172000 08:01 3543844 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f66afe0a000-7f66afe14000 r--p 00172000 08:01 3543844 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f66afe14000-7f66afe16000 rw-p 0017c000 08:01 3543844 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f66afe16000-7f66afe1a000 rw-p 00000000 00:00 0
7f66afe1a000-7f66afe83000 r-xp 00000000 08:01 3553596 /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.4.0
7f66afe83000-7f66b0083000 ---p 00069000 08:01 3553596 /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.4.0
7f66b0083000-7f66b0086000 r--p 00069000 08:01 3553596 /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.4.0
7f66b0086000-7f66b0087000 rw-p 0006c000 08:01 3553596 /usr/lib/x86_64-linux-gnu/libcurl-gnutls.so.4.4.0
7f66b0087000-7f66b00ad000 r-xp 00000000 08:01 1703974 /lib/x86_64-linux-gnu/ld-2.23.so
7f66b0252000-7f66b0266000 rw-p 00000000 00:00 0
7f66b02a9000-7f66b02ac000 rw-p 00000000 00:00 0
7f66b02ac000-7f66b02ad000 r--p 00025000 08:01 1703974 /lib/x86_64-linux-gnu/ld-2.23.so
7f66b02ad000-7f66b02ae000 rw-p 00026000 08:01 1703974 /lib/x86_64-linux-gnu/ld-2.23.so
7f66b02ae000-7f66b02af000 rw-p 00000000 00:00 0
7ffe077e9000-7ffe0780a000 rw-p 00000000 00:00 0 [stack]
7ffe078c4000-7ffe078c6000 r--p 00000000 00:00 0 [vvar]
7ffe078c6000-7ffe078c8000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
<html><body><h1>POST!</h1><p>URL Path: /</p></body></html>URL output should be: http://127.0.0.1:3000/My_ID_0/-6.000000/1.000000

C++ Boost program_options crash

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.

program crashing on this delete[] of a buffer that is valid..I think

I have a file that I am trying to use both cuComplex and std::complex in some functions.
When I run the softwar, I get a crash in this block of code, from a function trying to use std::complex and not cuComplex:
else
{ // data is 16 bit complex
offset rowLengthInBytes = numCols * sizeof(std::complex<unsigned short>);
std::complex<unsigned short> *buff16 = new std::complex<unsigned short>[(unsigned int)numCols];
//complex<unsigned short> *buff16 = (complex<unsigned short> *)malloc(numCols * sizeof(complex<unsigned short>));
//printf("Size of buff16: %i \n", sizeof(buff16));
offset startOfData = NitfFile.getSegmentDataOffset(cNitfReader::IMAGE, 0);
startOfData += (rowNum * rowLengthInBytes);
#ifdef _WIN32
_fseeki64(dataFile, startOfData, SEEK_SET);
#else
fseeko64(dataFile, startOfData, SEEK_SET);
#endif
fread((char*)buff16, 1, (size_t)rowLengthInBytes, dataFile);
for (size_t i = 0 ; i < numCols ; i++)
{
int re = buff16[i].real();
int im = buff16[i].imag();
#ifdef IDT_LITTLE_ENDIAN
endianSwap(&re, sizeof(re));
endianSwap(&im, sizeof(im));
#endif
buffer[i] = std::complex<float>((float)re, (float)im);
}
delete[] buff16; //program stops on this line
}
I cannot figure out why that delete[] is causing problems. I thoguht maybe there was a naming conflict, so I added std:: in front of all the complex types, but that didnt help.
Additionally, I made a test program to call these functions and it runs fine, however, the crash is happening whenever I instantiate some of these classes from QT. Using QT's debugger is how I got it to show me which line it is stopping at, beacuse normally it is just causing my program to end.
How can I figure out what is causing this crash?
edit:
I have verified that i is = numCols after the loop, which is how many spots were allocated for buffer.
Output from gdb:
*** glibc detected *** /work/ext/bin/TEST: double free or corruption (top): 0x00000000818dbd60 ***
======= Backtrace: =========
/lib64/libc.so.6[0x34eca7230f]
/lib64/libc.so.6(cfree+0x4b)[0x34eca7276b]
/work/ext/bin/TEST[0x415511]
/work/ext/bin/TEST[0x415543]
/work/ext/bin/TEST[0x415584]
/work/ext/bin/TEST[0x4155db]
/work/ext/bin/TEST[0x414927]
/work/ext/bin/TEST[0x423a5b]
/work/ext/bin/TEST[0x423d30]
/work/ext/bin/TEST[0x408742]
/work/ext/bin/TEST[0x407595]
/lib64/libc.so.6(__libc_start_main+0xf4)[0x34eca1d994]
/work/ext/bin/TEST(__gxx_personality_v0+0x229)[0x4062e9]
======= Memory map: ========
00400000-00466000 r-xp 00000000 fd:00 254345223 /work/ext/bin/TEST
00666000-00668000 rw-p 00066000 fd:00 254345223 /work/ext/bin/TEST
00668000-818f8000 rw-p 00668000 00:00 0 [heap]
343a400000-343a446000 r-xp 00000000 fd:00 49741877 /lib64/libssl.so.0.9.8e
343a446000-343a646000 ---p 00046000 fd:00 49741877 /lib64/libssl.so.0.9.8e
343a646000-343a64c000 rw-p 00046000 fd:00 49741877 /lib64/libssl.so.0.9.8e
343a800000-343a83b000 r-xp 00000000 fd:00 270302783 /usr/lib64/libcurl.so.3.0.0
343a83b000-343aa3b000 ---p 0003b000 fd:00 270302783 /usr/lib64/libcurl.so.3.0.0
343aa3b000-343aa3d000 rw-p 0003b000 fd:00 270302783 /usr/lib64/libcurl.so.3.0.0
34eba00000-34eba1c000 r-xp 00000000 fd:00 49741826 /lib64/ld-2.5.so
34ebc1b000-34ebc1c000 r--p 0001b000 fd:00 49741826 /lib64/ld-2.5.so
34ebc1c000-34ebc1d000 rw-p 0001c000 fd:00 49741826 /lib64/ld-2.5.so
34eca00000-34ecb4e000 r-xp 00000000 fd:00 49741833 /lib64/libc-2.5.so
34ecb4e000-34ecd4d000 ---p 0014e000 fd:00 49741833 /lib64/libc-2.5.so
34ecd4d000-34ecd51000 r--p 0014d000 fd:00 49741833 /lib64/libc-2.5.so
34ecd51000-34ecd52000 rw-p 00151000 fd:00 49741833 /lib64/libc-2.5.so
34ecd52000-34ecd57000 rw-p 34ecd52000 00:00 0
34ece00000-34ece82000 r-xp 00000000 fd:00 49741837 /lib64/libm-2.5.so
34ece82000-34ed081000 ---p 00082000 fd:00 49741837 /lib64/libm-2.5.so
34ed081000-34ed082000 r--p 00081000 fd:00 49741837 /lib64/libm-2.5.so
34ed082000-34ed083000 rw-p 00082000 fd:00 49741837 /lib64/libm-2.5.so
34ed200000-34ed202000 r-xp 00000000 fd:00 49741849 /lib64/libdl-2.5.so
34ed202000-34ed402000 ---p 00002000 fd:00 49741849 /lib64/libdl-2.5.so
34ed402000-34ed403000 r--p 00002000 fd:00 49741849 /lib64/libdl-2.5.so
34ed403000-34ed404000 rw-p 00003000 fd:00 49741849 /lib64/libdl-2.5.so
34ed600000-34ed616000 r-xp 00000000 fd:00 49741839 /lib64/libpthread-2.5.so
34ed616000-34ed815000 ---p 00016000 fd:00 49741839 /lib64/libpthread-2.5.so
34ed815000-34ed816000 r--p 00015000 fd:00 49741839 /lib64/libpthread-2.5.so
34ed816000-34ed817000 rw-p 00016000 fd:00 49741839 /lib64/libpthread-2.5.so
34ed817000-34ed81b000 rw-p 34ed817000 00:00 0
34eda00000-34eda14000 r-xp 00000000 fd:00 270295239 /usr/lib64/libz.so.1.2.3
34eda14000-34edc13000 ---p 00014000 fd:00 270295239 /usr/lib64/libz.so.1.2.3
34edc13000-34edc14000 rw-p 00013000 fd:00 270295239 /usr/lib64/libz.so.1.2.3
34ede00000-34ede07000 r-xp 00000000 fd:00 49741841 /lib64/librt-2.5.so
34ede07000-34ee007000 ---p 00007000 fd:00 49741841 /lib64/librt-2.5.so
34ee007000-34ee008000 r--p 00007000 fd:00 49741841 /lib64/librt-2.5.so
34ee008000-34ee009000 rw-p 00008000 fd:00 49741841 /lib64/librt-2.5.so
34f4800000-34f4815000 r-xp 00000000 fd:00 49742011 /lib64/libnsl-2.5.so
34f4815000-34f4a14000 ---p 00015000 fd:00 49742011 /lib64/libnsl-2.5.so
34f4a14000-34f4a15000 r--p 00014000 fd:00 49742011 /lib64/libnsl-2.5.so
34f4a15000-34f4a16000 rw-p 00015000 fd:00 49742011 /lib64/libnsl-2.5.so
34f4a16000-34f4a18000 rw-p 34f4a16000 00:00 0
34f6800000-34f692d000 r-xp 00000000 fd:00 49742042 /lib64/libcrypto.so.0.9.8e
34f692d000-34f6b2c000 ---p 0012d000 fd:00 49742042 /lib64/libcrypto.so.0.9.8e
34f6b2c000-34f6b4d000 rw-p 0012c000 fd:00 49742042 /lib64/libcrypto.so.0.9.8e
34f6b4d000-34f6b51000 rw-p 34f6b4d000 00:00 0
34f7000000-34f7011000 r-xp 00000000 fd:00 49742019 /lib64/libresolv-2.5.so
34f7011000-34f7211000 ---p 00011000 fd:00 49742019 /lib64/libresolv-2.5.so
34f7211000-34f7212000 r--p 00011000 fd:00 49742019 /lib64/libresolv-2.5.so
34f7212000-34f7213000 rw-p 00012000 fd:00 49742019 /lib64/libresolv-2.5.so
34f7213000-34f7215000 rw-p 34f7213000 00:00 0
34f7400000-34f7402000 r-xp 00000000 fd:00 49742018 /lib64/libkeyutils-1.2.so
34f7402000-34f7601000 ---p 00002000 fd:00 49742018 /lib64/libkeyutils-1.2.so
34f7601000-34f7602000 rw-p 00001000 fd:00 49742018 /lib64/libkeyutils-1.2.so
34f7800000-34f7802000 r-xp 00000000 fd:00 49742040 /lib64/libcom_err.so.2.1
34f7802000-34f7a01000 ---p 00002000 fd:00 49742040 /lib64/libcom_err.so.2.1
34f7a01000-34f7a02000 rw-p 00001000 fd:00 49742040 /lib64/libcom_err.so.2.1
34fdc00000-34fdc0d000 r-xp 00000000 fd:00 49742037 /lib64/libgcc_s-4.1.2-20080825.so.1
34fdc0d000-34fde0d000 ---p 0000d000 fd:00 49742037 /lib64/libgcc_s-4.1.2-20080825.so.1
34fde0d000-34fde0e000 rw-p 0000d000 fd:00 49742037 /lib64/libgcc_s-4.1.2-20080825.so.1
34ff000000-34ff0e6000 r-xp 00000000 fd:00 270284428 /usr/lib64/libstdc++.so.6.0.8
34ff0e6000-34ff2e5000 ---p 000e6000 fd:00 270284428 /usr/lib64/libstdc++.so.6.0.8
34ff2e5000-34ff2eb000 r--p 000e5000 fd:00 270284428 /usr/lib64/libstdc++.so.6.0.8
34ff2eb000-34ff2ee000 rw-p 000eb000 fd:00 270284428 /usr/lib64/libstdc++.so.6.0.8
34ff2ee000-34ff300000 rw-p 34ff2ee000 00:00 0
3bf9c00000-3bf9c31000 r-xp 00000000 fd:00 270298839 /usr/lib64/libidn.so.11.5.19
3bf9c31000-3bf9e30000 ---p 00031000 fd:00 270298839 /usr/lib64/libidn.so.11.5.19
3bf9e30000-3bf9e31000 rw-p 00030000 fd:00 270298839 /usr/lib64/libidn.so.11.5.19
3bfc800000-3bfc808000 r-xp 00000000 fd:00 270298915 /usr/lib64/libkrb5support.so.0.1
3bfc808000-3bfca07000 ---p 00008000 fd:00 270298915 /usr/lib64/libkrb5support.so.0.1
3bfca07000-3bfca08000 rw-p 00007000 fd:00 270298915 /usr/lib64/libkrb5support.so.0.1
3bfcc00000-3bfcc15000 r-xp 00000000 fd:00 25198595 /lib64/libselinux.so.1
3bfcc15000-3bfce15000 ---p 00015000 fd:00 25198595 /lib64/libselinux.so.1
3bfce15000-3bfce17000 rw-p 00015000 fd:00 25198595 /lib64/libselinux.so.1
3bfce17000-3bfce18000 rw-p 3bfce17000 00:00 0
3bfd000000-3bfd091000 r-xp 00000000 fd:00 270299139 /usr/lib64/libkrb5.so.3.3
3bfd091000-3bfd291000 ---p 00091000 fd:00 270299139 /usr/lib64/libkrb5.so.3.3
3bfd291000-3bfd295000 rw-p 00091000 fd:00 270299139 /usr/lib64/libkrb5.so.3.3
3bfd400000-3bfd424000 r-xp 00000000 fd:00 270299138 /usr/lib64/libk5crypto.so.3.1
3bfd424000-3bfd623000 ---p 00024000 fd:00 270299138 /usr/lib64/libk5crypto.so.3.1
3bfd623000-3bfd625000 rw-p 00023000 fd:00 270299138 /usr/lib64/libk5crypto.so.3.1
3bfd800000-3bfd83b000 r-xp 00000000 fd:00 25198594 /lib64/libsepol.so.1
3bfd83b000-3bfda3b000 ---p 0003b000 fd:00 25198594 /lib64/libsepol.so.1
3bfda3b000-3bfda3c000 rw-p 0003b000 fd:00 25198594 /lib64/libsepol.so.1
3bfda3c000-3bfda46000 rw-p 3bfda3c000 00:00 0
3bfdc00000-3bfdc2c000 r-xp 00000000 fd:00 270299140 /usr/lib64/libgssapi_krb5.so.2.2
3bfdc2c000-3bfde2c000 ---p 0002c000 fd:00 270299140 /usr/lib64/libgssapi_krb5.so.2.2
3bfde2c000-3bfde2e000 rw-p 0002c000 fd:00 270299140 /usr/lib64/libgssapi_krb5.so.2.2
2aaaaaaab000-2aaaaaaae000 rw-p 2aaaaaaab000 00:00 0
2aaaaaaae000-2aaaaaab5000 r--s 00000000 fd:00 147620082 /usr/lib64/gconv/gconv-modules.cache
2aaaaaacf000-2aaaaaad0000 rw-p 2aaaaaacf000 00:00 0
2aaaaaad0000-2aaaab25d000 r-xp 00000000 fd:00 270295189 /usr/lib64/libcuda.so.260.19.26
2aaaab25d000-2aaaab45c000 ---p 0078d000 fd:00 270295189 /usr/lib64/libcuda.so.260.19.26
2aaaab45c000-2aaaab528000 rw-p 0078c000 fd:00 270295189 /usr/lib64/libcuda.so.260.19.26
2aaaab528000-2aaaab54c000 rw-p 2aaaab528000 00:00 0
2aaaab54c000-2aaaab902000 r-xp 00000000 fd:00 254312453 /work/ext/lib/Linux/libxerces-c-3.1.so
2aaaab902000-2aaaabb02000 ---p 003b6000 fd:00 254312453 /work/ext/lib/Linux/libxerces-c-3.1.so
2aaaabb02000-2aaaabb43000 rw-p 003b6000 fd:00 254312453 /work/ext/lib/Linux/libxerces-c-3.1.so
2aaaabb43000-2aaaabba2000 r-xp 00000000 fd:00 271156027 /usr/local/cuda/lib64/libcudart.so.3.2.16
2aaaabba2000-2aaaabda2000 ---p 0005f000 fd:00 271156027 /usr/local/cuda/lib64/libcudart.so.3.2.16
2aaaabda2000-2aaaabda3000 rw-p 0005f000 fd:00 271156027 /usr/local/cuda/lib64/libcudart.so.3.2.16
2aaaabda3000-2aaaabdae000 rw-p 2aaaabda3000 00:00 0
2aaaabdae000-2aaaabdb0000 r-xp 00000000 fd:00 147620070 /usr/lib64/gconv/UTF-16.so
2aaaabdb0000-2aaaabfaf000 ---p 00002000 fd:00 147620070 /usr/lib64/gconv/UTF-16.so
2aaaabfaf000-2aaaabfb1000 rw-p 00001000 fd:00 147620070 /usr/lib64/gconv/UTF-16.so
2aaaabfb1000-2aaaabfb6000 rw-p 2aaaabfb1000 00:00 0
2aaaabfda000-2aaaabfdb000 rw-p 2aaaabfda000 00:00 0
7ffffffea000-7ffffffff000 rwxp 7ffffffe9000 00:00 0 [stack]
ffffffffff600000-ffffffffffe00000 ---p 00000000 00:00 0 [vdso]
Program received signal SIGABRT, Aborted.
0x00000034eca30265 in raise () from /lib64/libc.so.6
What you are trying to do is called serialization. You are strongly discouraged to do it by just reading/writing memory buffers in which your objects instances are stored. This way some unrelated internal data like memory pointers may get written to the file verbatim — and later, when read in, it won't be valid.
Consider using some existing serialization library for operating instances of vector<complex<float> >, for example Boost.Serialization.
You may look at this question for examples too.
The posted code seems valid to me, too (although it's impossible to be certain of the parts that we know only something of - like most variables). A bug that's showing up for no reason could indicate heap corruption - caused by something, elsewhere in the program.
However, there's no need for new[]/delete[] in a case like this. Why not just use std::vector - it's only better, and built for this purpose (among others).
{
std::vector<std::complex<unsigned short> > vector(numCols);
std::complex<unsigned short>* buff16 = &vector[0];
/* code */
}
Nothing obvious stands out, but the most likely problem is that buffer isn't big enough to hold numCols items and it's actually overflowing and overwriting buff16.