MPI Job crash with stack smashing detected - fortran

I have a very small piece of MPI code in Fortran 90 that I found online to test my cluster with heterogeneous nodes. The code likes like this
program MPI
include "mpif.h"
integer :: myrank,size,ierr
integer :: resultlen
character (len=8) :: name
call MPI_Init(ierr)
call MPI_Comm_rank(MPI_COMM_WORLD,myrank,ierr)
call MPI_Comm_size(MPI_COMM_WORLD,size,ierr)
call mpi_get_processor_name(name, resultlen, ierr)
write(*,*) "Processor ",myrank," of ",size,"on ",name,": Hello World!"
call MPI_Finalize(ierr)
end program
It was successfully compiled with the default mpif90 from the mpich package on CentOS 7.
> which mpif90
/usr/lib64/mpich/bin/mpif90
> mpif90 hello_mpi.f90 -o hello_mpi.exe
This code ran perfectly fine on one node.
> mpirun -host node1 -np 2 ./hello_mpi.exe
Processor 0 of 2 on node1: Hello World!
Processor 1 of 2 on node1: Hello World!
>
But on the other node, it crashed every time. These two nodes are very similar in hardware (both AMD Opteron processors, 64-core vs 48-core, and memory size are different), but identical on the software side (both CentOS7 with exactly the same packages). Here is what I got when running the code on node2
> mpirun -host node2 -np 2 ./hello_mpi.exe
Processor 0 of 2 on node2: Hello World!
Processor 1 of 2 on node2: Hello World!
*** stack smashing detected ***: ./hello_mpi.exe terminated
======= Backtrace: =========
*** stack smashing detected ***: ./hello_mpi.exe terminated
/lib64/libc.so.6(__fortify_fail+0x37)[0x7fc61aee3597]
/lib64/libc.so.6(__fortify_fail+0x0)[0x7fc61aee3560]
./hello_mpi.exe[0x400e66]
./hello_mpi.exe[0x400bff]
======= Backtrace: =========
/lib64/libc.so.6(__libc_start_main+0xf5)[0x7fc61adf6b15]
./hello_mpi.exe[0x400c31]
======= Memory map: ========
/lib64/libc.so.6(__fortify_fail+0x37)[0x7f394c8c3597]
00400000-00402000 r-xp 00000000 00:2e 493967 /home/user/tmp/hello_mpi.exe
00601000-00602000 r--p 00001000 00:2e 493967 /home/user/tmp/hello_mpi.exe
00602000-00603000 rw-p 00002000 00:2e 493967 /home/user/tmp/hello_mpi.exe
01e96000-01eb7000 rw-p 00000000 00:00 0 [heap]
7fc61a395000-7fc61a3a1000 r-xp 00000000 fd:00 201382493 /usr/lib64/libnss_files-2.17.so
7fc61a3a1000-7fc61a5a0000 ---p 0000c000 fd:00 201382493 /usr/lib64/libnss_files-2.17.so
7fc61a5a0000-7fc61a5a1000 r--p 0000b000 fd:00 201382493 /usr/lib64/libnss_files-2.17.so
7fc61a5a1000-7fc61a5a2000 rw-p 0000c000 fd:00 201382493 /usr/lib64/libnss_files-2.17.so
7fc61a5a2000-7fc61a5a8000 rw-p 00000000 00:00 0
7fc61add5000-7fc61af8c000 r-xp 00000000 fd:00 201382897 /usr/lib64/libc-2.17.so
7fc61af8c000-7fc61b18c000 ---p 001b7000 fd:00 201382897 /u/lib64/libc.so.6(__fortify_fail+0x0)[0x7f394c8c3560]
./hello_mpi.exe[0x400e66]
./hello_mpi.exe[0x400bff]
sr/lib64/libc-2.17.so
7fc61b18c000-7fc61b190000 r--p 001b7000 fd:00 201382897 /usr/lib64/libc-2.17.so
7fc61b190000-7fc61b192000 rw-p 001bb000 fd:00 201382897 /usr/lib64/libc-2.17.so
7fc61b192000-7fc61b197000 rw-p 00000000 00:00 0
7fc61b19d000-7fc61b1d8000 r-xp 00000000 fd:00 202328431 /usr/lib64/libquadmath.so.0.0.0
7fc61b1d8000-7fc61b3d7000 ---p 0003b000 fd:00 202328431 /usr/lib64/libquadmath.so.0.0.0
7fc61b3d7000-7fc61b3d8000 r--p 0003a000 fd:00 202328431 /usr/lib64/libquadmath.so.0.0.0
7fc61b3d8000-7fc61b3d9000 rw-p 0003b000 fd:00 202328431 /usr/lib64/libquadmath.so.0.0.0
7fc61b3dd000-7fc61b3f2000 r-xp 00000000 fd:00 201326729 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7fc61b3f2000-7fc61b5f1000 ---p 00015000 fd:00 201326729 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7fc61b5f1000-7fc61b5f2000 r--p 00014000 fd:00 201326729 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7fc61b5f2000-7fc61b5f3000 rw-p 00015000 fd:00 201326729 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7fc61b5f5000-7fc61b6f6000 r-xp 00000000 fd:00 201382905 /usr/lib64/libm-2.17.so
7fc61b6f6000-7fc61b8f5000 ---p 00101000 fd:00 201382905 /usr/lib64/libm-2.17.so
7fc61b8f5000-7fc61b8f6000 r--p 00100000 fd:00 201382905 /usr/lib64/libm-2.17.so
7fc61b8f6000-7fc61b8f7000 rw-p 00101000 fd:00 201382905 /usr/lib64/libm-2.17.so
7fc61b8fd000-7fc61ba1c000 r-xp 00000000 fd:00 202328443 /usr/lib64/libgfortran.so.3.0.0
7fc61ba1c000-7fc61bc1c000 ---p 0011f000 fd:00 202328443 /usr/lib64/libgfortran.so.3.0.0
7fc61bc1c000-7fc61bc1d000 r--p 0011f000 fd:00 202328443 /usr/lib64/libgfortran.so.3.0.0
7fc61bc1d000-7fc61bc1f000 rw-p 00120000 fd:00 202328443 /usr/lib64/libgfortran.so.3.0.0
7fc61bc25000-7fc61bc3b000 r-xp 00000000 fd:00 201382505 /usr/lib64/libpthread-2.17.so
/lib64/libc.so.6(__libc_start_main+0xf5)[0x7f394c7d6b15]
./hello_mpi.exe[0x400c31]
======= Memory map: ========
7fc61bc3b000-7fc61be3b000 ---p 00016000 fd:00 201382505 /usr/lib64/libpthread-2.17.so
7fc61be3b000-7fc61be3c000 r--p 00016000 fd:00 201382505 /usr/lib64/libpthread-2.17.so
7fc61be3c000-7fc61be3d000 rw-p 00017000 fd:00 201382505 /usr/lib64/libpthread-2.17.so
7fc61be3d000-7fc61be41000 rw-p 00000000 00:00 0
7fc61be45000-7fc61be4c000 r-xp 00000000 fd:00 201382510 /usr/lib64/librt-2.17.so
7fc61be4c000-7fc61c04b000 ---p 00007000 fd:00 201382510 /usr/lib64/librt-2.17.so
7fc61c04b000-7fc61c04c000 r--p 00006000 fd:00 201382510 /usr/lib64/librt-2.17.so
7fc61c04c000-7fc61c04d000 rw-p 00007000 fd:00 201382510 /usr/lib64/librt-2.17.so
7fc61c04d000-7fc61c052000 r-xp 00000000 fd:00 136205960 /usr/lib64/mpich/lib/libmpl.so.1.0.0
7fc61c052000-7fc61c251000 ---p 00005000 fd:00 136205960 /usr/lib64/mpich/lib/libmpl.so.1.0.0
7fc61c251000-7fc61c252000 r--p 00004000 fd:00 1362059600400000-00402000 r-xp 00000000 00:2e 493967 /home/user/tmp/hello_mpi.exe
00601000-00602000 r--p 00001000 00:2e 493967 /home/user/tmp/hello_mpi.exe
00602000-00603000 rw-p 00002000 00:2e 493967 /home/user/tmp/hello_mpi.exe
01ca0000-01cc1000 rw-p 00000000 00:00 0 [heap]
7f394bd75000-7f394bd81000 r-xp 00000000 fd:00 201382493 /usr/lib64/libnss_files-2.17.so
7f394bd81000-7f394bf80000 ---p 0000c000 fd:00 201382493 /usr/lib64/libnss_files-2.17.so
7f394bf80000-7f394bf81000 r--p 0000b000 fd:00 201382493 /usr/lib64/libnss_files-2.17.so
7f394bf81000-7f394bf82000 rw-p 0000c000 fd:00 201382493 /usr/lib64/libnss_files-2.17.so
7f394bf82000-7f394bf88000 rw-p 00000000 00:00 0
7f394c7b5000-7f394c96c000 r-xp 00000000 fd:00 201382897 /usr/lib64/libc-2.17.so
7f394c96c000-7f394cb6c000 ---p 001b7000 fd:00 201382897 /u0 /usr/lib64/mpich/lib/libmpl.so.1.0.0
7fc61c252000-7fc61c253000 rw-p 00005000 fd:00 136205960 /usr/lib64/mpich/lib/libmpl.so.1.0.0
7fc61c255000-7fc61c256000 r-xp 00000000 fd:00 136205962 /usr/lib64/mpich/lib/libopa.so.1.0.0
7fc61c256000-7fc61c455000 ---p 00001000 fd:00 136205962 /usr/lib64/mpich/lib/libopa.so.1.0.0
7fc61c455000-7fc61c456000 r--p 00000000 fd:00 136205962 /usr/lib64/mpich/lib/libopa.so.1.0.0
7fc61c456000-7fc61c457000 rw-p 00001000 fd:00 136205962 /usr/lib64/mpich/lib/libopa.so.1.0.0
7fc61c45d000-7fc61c67e000 r-xp 00000000 fd:00 136205954 /usr/lib64/mpich/lib/libmpich.so.10.0.4
7fc61c67e000-7fc61c87d000 ---p 00221000 fd:00 136205954 /usr/lib64/mpich/lib/libmpich.so.10.0.4
7fc61c87d000-7fc61c88a000 r--p 00220000 fd:00 136205954 /usr/lib64/mpich/lib/libmpich.so.10.0.4
7fc61c88a000-7fc61c88f000 rw-p 0022d000 fd:00 136205954 /usr/lib64/mpich/lib/libmpich.so.10.0.4
7fc61c88f000-7fc61c8c8000 rw-p 00000000 00:00 0
7fc61c8cd000-7fc61c8cf000 r-xp 00000000 fd:00 136205958 /usr/lib64/mpich/lib/libmpichf90.so.10.0.4
7fc61c8cf000-7fc61cace000 ---p 00002000 fd:00 136205958 /usr/lib64/mpich/lib/libmpichf90.so.10.0.4
7fc61cace000-7fc61cacf000 r--p 00001000 fd:00 136205958 /usr/lib64/mpich/lib/libmpichf90.so.10.0.4
7fc61cacf000-7fc61cad0000 rw-p 00002000 fd:00 136205958 /usr/lib64/mpich/lib/libmpichf90.so.10.0.4
7fc61cad5000-7fc61caf6000 r-xp 00000000 fd:00 201382890 /usr/lib64/ld-2.17.so
7fc61cce1000-7fc61cce5000 rw-p 00000000 00:00 0
7fc61ccf5000-7fc61ccf6000 rw-p 00000000 00:00 0
7fc61ccf6000-7fc61ccf7000 r--p 00021000 fd:00 201382890 /usr/lib64/ld-2.17.so
7fc61ccf7000-7fc61ccf8000 rw-p 00022000 fd:00 201382890 /usr/lib64/ld-2.17.so
7fc61ccf8000-7fc61ccfa000 rw-p 00000000 00:00 0
7fc61ccfa000-7fc61ccfd000 rw-p 00000000 00:00sr/lib64/libc-2.17.so
7f394cb6c000-7f394cb70000 r--p 001b7000 fd:00 201382897 /usr/lib64/libc-2.17.so
7f394cb70000-7f394cb72000 rw-p 001bb000 fd:00 201382897 /usr/lib64/libc-2.17.so
7f394cb72000-7f394cb77000 rw-p 00000000 00:00 0
7f394cb7d000-7f394cbb8000 r-xp 00000000 fd:00 202328431 /usr/lib64/libquadmath.so.0.0.0
7f394cbb8000-7f394cdb7000 ---p 0003b000 fd:00 202328431 /usr/lib64/libquadmath.so.0.0.0
7f394cdb7000-7f394cdb8000 r--p 0003a000 fd:00 202328431 /usr/lib64/libquadmath.so.0.0.0
7f394cdb8000-7f394cdb9000 rw-p 0003b000 fd:00 202328431 /usr/lib64/libquadmath.so.0.0.0
7f394cdbd000-7f394cdd2000 r-xp 00000000 fd:00 201326729 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7f394cdd2000-7f394cfd1000 ---p 00015000 fd:00 201326729 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7f394cfd1000-7f394cfd2000 r--p 00014000 fd:00 201326729 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
0
7ffcdf655000-7ffcdf676000 rw-p 00000000 00:00 0 [stack]
7ffcdf70d000-7ffcdf70f000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
7f394cfd2000-7f394cfd3000 rw-p 00015000 fd:00 201326729 /usr/lib64/libgcc_s-4.8.5-20150702.so.1
7f394cfd5000-7f394d0d6000 r-xp 00000000 fd:00 201382905 /usr/lib64/libm-2.17.so
7f394d0d6000-7f394d2d5000 ---p 00101000 fd:00 201382905 /usr/lib64/libm-2.17.so
7f394d2d5000-7f394d2d6000 r--p 00100000 fd:00 201382905 /usr/lib64/libm-2.17.so
7f394d2d6000-7f394d2d7000 rw-p 00101000 fd:00 201382905 /usr/lib64/libm-2.17.so
7f394d2dd000-7f394d3fc000 r-xp 00000000 fd:00 202328443 /usr/lib64/libgfortran.so.3.0.0
7f394d3fc000-7f394d5fc000 ---p 0011f000 fd:00 202328443 /usr/lib64/libgfortran.so.3.0.0
7f394d5fc000-7f394d5fd000 r--p 0011f000 fd:00 202328443 /usr/lib64/libgfortran.so.3.0.0
7f394d5fd000-7f394d5ff000 rw-p 00120000 fd:00 202328443 /usr/lib64/libgfortran.so.3.0.0
7f394d605000-7f394d61b000 r-xp 00000000 fd:00 201382505 /usr/lib64/libpthread-2.17.so
Program received signal SIGABRT: Process abort signal.
Backtrace for this error:
7f394d61b000-7f394d81b000 ---p 00016000 fd:00 201382505 /usr/lib64/libpthread-2.17.so
7f394d81b000-7f394d81c000 r--p 00016000 fd:00 201382505 /usr/lib64/libpthread-2.17.so
7f394d81c000-7f394d81d000 rw-p 00017000 fd:00 201382505 /usr/lib64/libpthread-2.17.so
7f394d81d000-7f394d821000 rw-p 00000000 00:00 0
7f394d825000-7f394d82c000 r-xp 00000000 fd:00 201382510 /usr/lib64/librt-2.17.so
7f394d82c000-7f394da2b000 ---p 00007000 fd:00 201382510 /usr/lib64/librt-2.17.so
7f394da2b000-7f394da2c000 r--p 00006000 fd:00 201382510 /usr/lib64/librt-2.17.so
7f394da2c000-7f394da2d000 rw-p 00007000 fd:00 201382510 /usr/lib64/librt-2.17.so
7f394da2d000-7f394da32000 r-xp 00000000 fd:00 136205960 /usr/lib64/mpich/lib/libmpl.so.1.0.0
7f394da32000-7f394dc31000 ---p 00005000 fd:00 136205960 /usr/lib64/mpich/lib/libmpl.so.1.0.0
7f394dc31000-7f394dc32000 r--p 00004000 fd:00 136205960 /usr/lib64/mpich/lib/libmpl.so.1.0.0
7f394dc32000-7f394dc33000 rw-p 00005000 fd:00 136205960 /usr/lib64/mpich/lib/libmpl.so.1.0.0
7f394dc35000-7f394dc36000 r-xp 00000000 fd:00 136205962 /usr/lib64/mpich/lib/libopa.so.1.0.0
7f394dc36000-7f394de35000 ---p 00001000 fd:00 136205962 /usr/lib64/mpich/lib/libopa.so.1.0.0
7f394de35000-7f394de36000 r--p 00000000 fd:00 136205962 /usr/lib64/mpich/lib/libopa.so.1.0.0
7f394de36000-7f394de37000 rw-p 00001000 fd:00 136205962 /usr/lib64/mpich/lib/libopa.so.1.0.0
7f394de3d000-7f394e05e000 r-xp 00000000 fd:00 136205954 /usr/lib64/mpich/lib/libmpich.so.10.0.4
7f394e05e000-7f394e25d000 ---p 00221000 fd:00 136205954 /usr/lib64/mpich/lib/libmpich.so.10.0.4
7f394e25d000-7f394e26a000 r--p 00220000 fd:00 136205954 /usr/lib64/mpich/lib/libmpich.so.10.0.4
7f394e26a000-7f394e26f000 rw-p 0022d000 fd:00 136205954 /usr/lib64/mpich/lib/libmpich.so.10.0.4
7f394e26f000-7f394e2a8000 rw-p 00000000 00:00 0
7f394e2ad000-7f394e2af000 r-xp 00000000 fd:00 136205958 /usr/lib64/mpich/lib/libmpichf90.so.10.0.4
7f394e2af000-7f394e4ae000 ---p 00002000 fd:00 136205958 /usr/lib64/mpich/lib/libmpichf90.so.10.0.4
7f394e4ae000-7f394e4af000 r--p 00001000 fd:00 136205958 /usr/lib64/mpich/lib/libmpichf90.so.10.0.4
7f394e4af000-7f394e4b0000 rw-p 00002000 fd:00 136205958 /usr/lib64/mpich/lib/libmpichf90.so.10.0.4
7f394e4b5000-7f394e4d6000 r-xp 00000000 fd:00 201382890 /usr/lib64/ld-2.17.so
7f394e6ce000-7f394e6d6000 rw-p 00000000 00:00 0
7f394e6d6000-7f394e6d7000 r--p 00021000 fd:00 201382890 /usr/lib64/ld-2.17.so
7f394e6d7000-7f394e6d8000 rw-p 00022000 fd:00 201382890 /usr/lib64/ld-2.17.so
7f394e6d8000-7f394e6da000 rw-p 00000000 00:00 0
7fffabb37000-7fffabb58000 rw-p 00000000 00:00 0 [stack]
7fffabbed000-7fffabbef000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
Program received signal SIGABRT: Process abort signal.
Backtrace for this error:
#0 0x7FC61B916467
#1 0x7FC61B916AAE
#2 0x7FC61AE0A66F
#3 0x7FC61AE0A5F7
#4 0x7FC61AE0BCE7
#0 0x7F394D2F6467
#1 0x#5 0x7FC61AE4A326
#6 0x7FC61AEE3596
#7 0x7FC61AEE355F
7F394D2F6AAE
#2 0x7F394C7EA66F
#3 0x7F394C7EA5F7
#4 0x7F394C7EBCE7
#5 0x7F394C82A326
#6 0x7F394C8C3596
#7 0x7F394C8C355F
#8 0x400E65 in mpi at hello_mpi.f90:16
#8 0x400E65 in mpi at hello_mpi.f90:16
===================================================================================
= BAD TERMINATION OF ONE OF YOUR APPLICATION PROCESSES
= EXIT CODE: 6
= CLEANING UP REMAINING PROCESSES
= YOU CAN IGNORE THE BELOW CLEANUP MESSAGES
===================================================================================
YOUR APPLICATION TERMINATED WITH THE EXIT STRING: Aborted (signal 6)
This typically refers to a problem with your application.
Please see the FAQ page for debugging suggestions
So my question is, what could be causing this problem? The interesting thing is a similar piece of MPI code in C (shown below, obtained from the internet) worked just fine on both nodes without the above problem.
#include <mpi.h>
#include <stdio.h>
int main(int argc, char** argv) {
// Initialize the MPI environment
MPI_Init(NULL, NULL);
// Get the number of processes
int world_size;
MPI_Comm_size(MPI_COMM_WORLD, &world_size);
// Get the rank of the process
int world_rank;
MPI_Comm_rank(MPI_COMM_WORLD, &world_rank);
// Get the name of the processor
char processor_name[MPI_MAX_PROCESSOR_NAME];
int name_len;
MPI_Get_processor_name(processor_name, &name_len);
// Print off a hello world message
printf("Hello world from processor %s, rank %d"
" out of %d processors\n",
processor_name, world_rank, world_size);
// Finalize the MPI environment.
MPI_Finalize();
}
Could this be hardware related? Or something else?

name is too short. The MPI specification states:
The argument name must represent storage that is at least
MPI_MAX_PROCESSOR_NAME characters long. MPI_GET_PROCESSOR_NAME may write up to this many characters into name.
If that does not fix the problem, then your MPI implementation might be broken.

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.

Simple tutorial SFML code crashes on Ubuntu 16.04

So I just installed manually SFML 2.4.2 library and wanted to compile example code from first tutorial which is:
#include <SFML/Graphics.hpp>
int main() {
sf::RenderWindow window(sf::VideoMode(200, 200), "SFML works!");
sf::CircleShape shape(100.f);
shape.setFillColor(sf::Color::Green);
while (window.isOpen()) {
sf::Event event;
while (window.pollEvent(event)) {
if (event.type == sf::Event::Closed)
window.close();
}
window.clear();
window.draw(shape);
window.display();
}
return 0;
}
Everything compiles with g++ 5.4.0 and clang++ 3.8.0 on Ubuntu 16.04, but when I'm trying to run the program, it shows a black window for 1 second and outputs this to the terminal:
*** Error in `./main': free(): invalid pointer: 0x000000000155cb08 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x777e5)[0x7f2d572537e5]
/lib/x86_64-linux-gnu/libc.so.6(+0x7fe0a)[0x7f2d5725be0a]
/lib/x86_64-linux-gnu/libc.so.6(cfree+0x4c)[0x7f2d5725f98c]
./main[0x4015d0]
./main[0x401580]
./main[0x401492]
./main[0x4013d1]
./main[0x401368]
./main(_ZN2sf6StringD2Ev+0x15)[0x401325]
./main[0x4010a6]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xf0)[0x7f2d571fc830]
./main[0x400ed9]
======= Memory map: ========
00400000-00402000 r-xp 00000000 08:02 7080173 /home/octothorp/code/terrain_rendering/main
00601000-00602000 r--p 00001000 08:02 7080173 /home/octothorp/code/terrain_rendering/main
00602000-00603000 rw-p 00002000 08:02 7080173 /home/octothorp/code/terrain_rendering/main
01549000-0186b000 rw-p 00000000 00:00 0 [heap]
40144000-401e4000 rw-p 00000000 00:00 0
406bb000-406bd000 r-xs 00000000 08:02 262928 /tmp/.gljLFg1G (deleted)
4081a000-408ba000 rw-p 00000000 00:00 0
7f2d4c000000-7f2d4c021000 rw-p 00000000 00:00 0
7f2d4c021000-7f2d50000000 ---p 00000000 00:00 0
7f2d517fa000-7f2d518c3000 rw-p 00000000 00:00 0
7f2d518c3000-7f2d518c8000 r-xp 00000000 08:02 795718 /usr/lib/x86_64-linux-gnu/libXfixes.so.3.1.0
7f2d518c8000-7f2d51ac7000 ---p 00005000 08:02 795718 /usr/lib/x86_64-linux-gnu/libXfixes.so.3.1.0
7f2d51ac7000-7f2d51ac8000 r--p 00004000 08:02 795718 /usr/lib/x86_64-linux-gnu/libXfixes.so.3.1.0
7f2d51ac8000-7f2d51ac9000 rw-p 00005000 08:02 795718 /usr/lib/x86_64-linux-gnu/libXfixes.so.3.1.0
7f2d51ac9000-7f2d51ad2000 r-xp 00000000 08:02 795710 /usr/lib/x86_64-linux-gnu/libXcursor.so.1.0.2
7f2d51ad2000-7f2d51cd1000 ---p 00009000 08:02 795710 /usr/lib/x86_64-linux-gnu/libXcursor.so.1.0.2
7f2d51cd1000-7f2d51cd2000 r--p 00008000 08:02 795710 /usr/lib/x86_64-linux-gnu/libXcursor.so.1.0.2
7f2d51cd2000-7f2d51cd3000 rw-p 00009000 08:02 795710 /usr/lib/x86_64-linux-gnu/libXcursor.so.1.0.2
7f2d51cf5000-7f2d51d75000 rw-s 1e3593000 00:06 591 /dev/nvidiactl
7f2d51d75000-7f2d51df5000 rw-s 1e3512000 00:06 591 /dev/nvidiactl
7f2d51df5000-7f2d51e75000 rw-s 1e348a000 00:06 591 /dev/nvidiactl
7f2d51e75000-7f2d51f75000 rw-s 1eb766000 00:06 591 /dev/nvidiactl
7f2d51f75000-7f2d51f88000 rw-s 1eb5f8000 00:06 591 /dev/nvidiactl
7f2d51f88000-7f2d51fa8000 rw-s c03c0000 00:06 592 /dev/nvidia0
7f2d51fa8000-7f2d51fe8000 rw-s 1eb6cb000 00:06 591 /dev/nvidiactl
7f2d51fe8000-7f2d52028000 rw-s 1eb574000 00:06 591 /dev/nvidiactl
7f2d52028000-7f2d521d9000 rw-p 00000000 00:00 0
7f2d521d9000-7f2d535d9000 r-xp 00000000 08:02 3030116 /usr/lib/nvidia-378/libnvidia-glcore.so.378.13
7f2d535d9000-7f2d535fa000 rwxp 01400000 08:02 3030116 /usr/lib/nvidia-378/libnvidia-glcore.so.378.13
7f2d535fa000-7f2d539cc000 r-xp 01421000 08:02 3030116 /usr/lib/nvidia-378/libnvidia-glcore.so.378.13
7f2d539cc000-7f2d53bcb000 ---p 017f3000 08:02 3030116 /usr/lib/nvidia-378/libnvidia-glcore.so.378.13
7f2d53bcb000-7f2d53fb7000 rw-p 017f2000 08:02 3030116 /usr/lib/nvidia-378/libnvidia-glcore.so.378.13
7f2d53fb7000-7f2d53fcf000 rw-p 00000000 00:00 0
7f2d53fcf000-7f2d53fd2000 r-xp 00000000 08:02 3030149 /usr/lib/nvidia-378/tls/libnvidia-tls.so.378.13
7f2d53fd2000-7f2d541d2000 ---p 00003000 08:02 3030149 /usr/lib/nvidia-378/tls/libnvidia-tls.so.378.13
7f2d541d2000-7f2d541d3000 rw-p 00003000 08:02 3030149 /usr/lib/nvidia-378/tls/libnvidia-tls.so.378.13
7f2d541d3000-7f2d5429d000 r-xp 00000000 08:02 3030139 /usr/lib/nvidia-378/libGLX_nvidia.so.378.13
7f2d5429d000-7f2d542d1000 rwxp 000ca000 08:02 3030139 /usr/lib/nvidia-378/libGLX_nvidia.so.378.13
7f2d542d1000-7f2d542e5000 r-xp 000fe000 08:02 3030139 /usr/lib/nvidia-378/libGLX_nvidia.so.378.13
7f2d542e5000-7f2d544e5000 ---p 00112000 08:02 3030139 /usr/lib/nvidia-378/libGLX_nvidia.so.378.13
7f2d544e5000-7f2d5450d000 rw-p 00112000 08:02 3030139 /usr/lib/nvidia-378/libGLX_nvidia.so.378.13
7f2d5450d000-7f2d54514000 rw-p 00000000 00:00 0
7f2d54514000-7f2d54519000 r-xp 00000000 08:02 795714 /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
7f2d54519000-7f2d54718000 ---p 00005000 08:02 795714 /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
7f2d54718000-7f2d54719000 r--p 00004000 08:02 795714 /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
7f2d54719000-7f2d5471a000 rw-p 00005000 08:02 795714 /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
7f2d5471a000-7f2d5471c000 r-xp 00000000 08:02 795703 /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
7f2d5471c000-7f2d5491c000 ---p 00002000 08:02 795703 /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
7f2d5491c000-7f2d5491d000 r--p 00002000 08:02 795703 /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
7f2d5491d000-7f2d5491e000 rw-p 00003000 08:02 795703 /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
7f2d5491e000-7f2d54927000 r-xp 00000000 08:02 795736 /usr/lib/x86_64-linux-gnu/libXrender.so.1.3.0
7f2d54927000-7f2d54b26000 ---p 00009000 08:02 795736 /usr/lib/x86_64-linux-gnu/libXrender.so.1.3.0
7f2d54b26000-7f2d54b27000 r--p 00008000 08:02 795736 /usr/lib/x86_64-linux-gnu/libXrender.so.1.3.0
7f2d54b27000-7f2d54b28000 rw-p 00009000 08:02 795736 /usr/lib/x86_64-linux-gnu/libXrender.so.1.3.0
7f2d54b28000-7f2d54b4c000 r-xp 00000000 08:02 2101871 /lib/x86_64-linux-gnu/libpng12.so.0.54.0
7f2d54b4c000-7f2d54d4b000 ---p 00024000 08:02 2101871 /lib/x86_64-linux-gnu/libpng12.so.0.54.0
7f2d54d4b000-7f2d54d4c000 r--p 00023000 08:02 2101871 /lib/x86_64-linux-gnu/libpng12.so.0.54.0
7f2d54d4c000-7f2d54d4d000 rw-p 00024000 08:02 2101871 /lib/x86_64-linux-gnu/libpng12.so.0.54.0
7f2d54d4d000-7f2d54d66000 r-xp 00000000 08:02 2101920 /lib/x86_64-linux-gnu/libz.so.1.2.8
7f2d54d66000-7f2d54f65000 ---p 00019000 08:02 2101920 /lib/x86_64-linux-gnu/libz.so.1.2.8
7f2d54f65000-7f2d54f66000 r--p 00018000 08:02 2101920 /lib/x86_64-linux-gnu/libz.so.1.2.8
7f2d54f66000-7f2d54f67000 rw-p 00019000 08:02 2101920 /lib/x86_64-linux-gnu/libz.so.1.2.8
7f2d54f67000-7f2d54f88000 r-xp 00000000 08:02 797052 /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
7f2d54f88000-7f2d55187000 ---p 00021000 08:02 797052 /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
7f2d55187000-7f2d55188000 r--p 00020000 08:02 797052 /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
7f2d55188000-7f2d55189000 rw-p 00021000 08:02 797052 /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
7f2d55189000-7f2d5518d000 r-xp 00000000 08:02 2097793 /lib/x86_64-linux-gnu/libuuid.so.1.3.0
7f2d5518d000-7f2d5538c000 ---p 00004000 08:02 2097793 /lib/x86_64-linux-gnu/libuuid.so.1.3.0
7f2d5538c000-7f2d5538d000 r--p 00003000 08:02 2097793 /lib/x86_64-linux-gnu/libuuid.so.1.3.0
7f2d5538d000-7f2d5538e000 rw-p 00004000 08:02 2097793 /lib/x86_64-linux-gnu/libuuid.so.1.3.0
7f2d5538e000-7f2d553dc000 r-xp 00000000 08:02 3030118 /usr/lib/nvidia-378/libGLdispatch.so.0
7f2d553dc000-7f2d5540e000 r-xp 0004e000 08:02 3030118 /usr/lib/nvidia-378/libGLdispatch.so.0
7f2d5540e000-7f2d55448000 r-xp 00080000 08:02 3030118 /usr/lib/nvidia-378/libGLdispatch.so.0
7f2d55448000-7f2d55648000 ---p 000ba000 08:02 3030118 /usr/lib/nvidia-378/libGLdispatch.so.0
7f2d55648000-7f2d55657000 rw-p 000ba000 08:02 3030118 /usr/lib/nvidia-378/libGLdispatch.so.0
7f2d55657000-7f2d55677000 rw-p 00000000 00:00 0
7f2d55677000-7f2d55686000 r-xp 00000000 08:02 3030153 /usr/lib/nvidia-378/libGLX.so.0
7f2d55686000-7f2d55886000 ---p 0000f000 08:02 3030153 /usr/lib/nvidia-378/libGLX.so.0
7f2d55886000-7f2d55887000 rw-p 0000f000 08:02 3030153 /usr/lib/nvidia-378/libGLX.so.0
7f2d55887000-7f2d558a7000 rw-p 00000000 00:00 0
7f2d558a7000-7f2d558aa000 r-xp 00000000 08:02 2100368 /lib/x86_64-linux-gnu/libdl-2.23.so
7f2d558aa000-7f2d55aa9000 ---p 00003000 08:02 2100368 /lib/x86_64-linux-gnu/libdl-2.23.so
7f2d55aa9000-7f2d55aaa000 r--p 00002000 08:02 2100368 /lib/x86_64-linux-gnu/libdl-2.23.so
7f2d55aaa000-7f2d55aab000 rw-p 00003000 08:02 2100368 /lib/x86_64-linux-gnu/libdl-2.23.so
7f2d55aab000-7f2d55ab5000 r-xp 00000000 08:02 795734 /usr/lib/x86_64-linux-gnu/libXrandr.so.2.2.0
7f2d55ab5000-7f2d55cb4000 ---p 0000a000 08:02 795734 /usr/lib/x86_64-linux-gnu/libXrandr.so.2.2.0
7f2d55cb4000-7f2d55cb5000 r--p 00009000 08:02 795734 /usr/lib/x86_64-linux-gnu/libXrandr.so.2.2.0
7f2d55cb5000-7f2d55cb6000 rw-p 0000a000 08:02 795734 /usr/lib/x86_64-linux-gnu/libXrandr.so.2.2.0
7f2d55cb6000-7f2d55cbd000 r-xp 00000000 08:02 2100360 /lib/x86_64-linux-gnu/librt-2.23.so
7f2d55cbd000-7f2d55ebc000 ---p 00007000 08:02 2100360 /lib/x86_64-linux-gnu/librt-2.23.so
7f2d55ebc000-7f2d55ebd000 r--p 00006000 08:02 2100360 /lib/x86_64-linux-gnu/librt-2.23.so
7f2d55ebd000-7f2d55ebe000 rw-p 00007000 08:02 2100360 /lib/x86_64-linux-gnu/librt-2.23.so
7f2d55ebe000-7f2d55ed6000 r-xp 00000000 08:02 2100382 /lib/x86_64-linux-gnu/libpthread-2.23.so
7f2d55ed6000-7f2d560d5000 ---p 00018000 08:02 2100382 /lib/x86_64-linux-gnu/libpthread-2.23.so
7f2d560d5000-7f2d560d6000 r--p 00017000 08:02 2100382 /lib/x86_64-linux-gnu/libpthread-2.23.so
7f2d560d6000-7f2d560d7000 rw-p 00018000 08:02 2100382 /lib/x86_64-linux-gnu/libpthread-2.23.so
7f2d560d7000-7f2d560db000 rw-p 00000000 00:00 0
7f2d560db000-7f2d56132000 r-xp 00000000 08:02 796440 /usr/lib/x86_64-linux-gnu/libjpeg.so.8.0.2
7f2d56132000-7f2d56332000 ---p 00057000 08:02 796440 /usr/lib/x86_64-linux-gnu/libjpeg.so.8.0.2
7f2d56332000-7f2d56333000 r--p 00057000 08:02 796440 /usr/lib/x86_64-linux-gnu/libjpeg.so.8.0.2
7f2d56333000-7f2d56334000 rw-p 00058000 08:02 796440 /usr/lib/x86_64-linux-gnu/libjpeg.so.8.0.2
7f2d56334000-7f2d563d8000 r-xp 00000000 08:02 796120 /usr/lib/x86_64-linux-gnu/libfreetype.so.6.12.1
7f2d563d8000-7f2d565d7000 ---p 000a4000 08:02 796120 /usr/lib/x86_64-linux-gnu/libfreetype.so.6.12.1
7f2d565d7000-7f2d565dd000 r--p 000a3000 08:02 796120 /usr/lib/x86_64-linux-gnu/libfreetype.so.6.12.1
7f2d565dd000-7f2d565de000 rw-p 000a9000 08:02 796120 /usr/lib/x86_64-linux-gnu/libfreetype.so.6.12.1
7f2d565de000-7f2d565ef000 r-xp 00000000 08:02 795716 /usr/lib/x86_64-linux-gnu/libXext.so.6.4.0
7f2d565ef000-7f2d567ee000 ---p 00011000 08:02 795716 /usr/lib/x86_64-linux-gnu/libXext.so.6.4.0
7f2d567ee000-7f2d567ef000 r--p 00010000 08:02 795716 /usr/lib/x86_64-linux-gnu/libXext.so.6.4.0
7f2d567ef000-7f2d567f0000 rw-p 00011000 08:02 795716 /usr/lib/x86_64-linux-gnu/libXext.so.6.4.0
7f2d567f0000-7f2d56925000 r-xp 00000000 08:02 795699 /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0
7f2d56925000-7f2d56b25000 ---p 00135000 08:02 795699 /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0
7f2d56b25000-7f2d56b26000 r--p 00135000 08:02 795699 /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0
7f2d56b26000-7f2d56b2a000 rw-p 00136000 08:02 795699 /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0
7f2d56b2a000-7f2d56b40000 r-xp 00000000 08:02 795623 /usr/lib/x86_64-linux-gnu/libICE.so.6.3.0
7f2d56b40000-7f2d56d3f000 ---p 00016000 08:02 795623 /usr/lib/x86_64-linux-gnu/libICE.so.6.3.0
7f2d56d3f000-7f2d56d40000 r--p 00015000 08:02 795623 /usr/lib/x86_64-linux-gnu/libICE.so.6.3.0
7f2d56d40000-7f2d56d41000 rw-p 00016000 08:02 795623 /usr/lib/x86_64-linux-gnu/libICE.so.6.3.0
7f2d56d41000-7f2d56d44000 rw-p 00000000 00:00 0
7f2d56d44000-7f2d56d4b000 r-xp 00000000 08:02 795695 /usr/lib/x86_64-linux-gnu/libSM.so.6.0.1
7f2d56d4b000-7f2d56f4a000 ---p 00007000 08:02 795695 /usr/lib/x86_64-linux-gnu/libSM.so.6.0.1
7f2d56f4a000-7f2d56f4b000 r--p 00006000 08:02 795695 /usr/lib/x86_64-linux-gnu/libSM.so.6.0.1
7f2d56f4b000-7f2d56f4c000 rw-p 00007000 08:02 795695 /usr/lib/x86_64-linux-gnu/libSM.so.6.0.1
7f2d56f4c000-7f2d56f7e000 r-xp 00000000 08:02 3030150 /usr/lib/nvidia-378/libGL.so.1.0.0
7f2d56f7e000-7f2d56fb0000 r-xp 00032000 08:02 3030150 /usr/lib/nvidia-378/libGL.so.1.0.0
7f2d56fb0000-7f2d56fda000 r-xp 00064000 08:02 3030150 /usr/lib/nvidia-378/libGL.so.1.0.0
7f2d56fda000-7f2d571da000 ---p 0008e000 08:02 3030150 /usr/lib/nvidia-378/libGL.so.1.0.0
7f2d571da000-7f2d571db000 rw-p 0008e000 08:02 3030150 /usr/lib/nvidia-378/libGL.so.1.0.0
7f2d571db000-7f2d571dc000 rw-p 00000000 00:00 0
7f2d571dc000-7f2d5739b000 r-xp 00000000 08:02 2100370 /lib/x86_64-linux-gnu/libc-2.23.so
7f2d5739b000-7f2d5759b000 ---p 001bf000 08:02 2100370 /lib/x86_64-linux-gnu/libc-2.23.so
7f2d5759b000-7f2d5759f000 r--p 001bf000 08:02 2100370 /lib/x86_64-linux-gnu/libc-2.23.so
7f2d5759f000-7f2d575a1000 rw-p 001c3000 08:02 2100370 /lib/x86_64-linux-gnu/libc-2.23.so
7f2d575a1000-7f2d575a5000 rw-p 00000000 00:00 0
7f2d575a5000-7f2d575bb000 r-xp 00000000 08:02 2101769 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f2d575bb000-7f2d577ba000 ---p 00016000 08:02 2101769 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f2d577ba000-7f2d577bb000 rw-p 00015000 08:02 2101769 /lib/x86_64-linux-gnu/libgcc_s.so.1
7f2d577bb000-7f2d578c3000 r-xp 00000000 08:02 2100380 /lib/x86_64-linux-gnu/libm-2.23.so
7f2d578c3000-7f2d57ac2000 ---p 00108000 08:02 2100380 /lib/x86_64-linux-gnu/libm-2.23.so
7f2d57ac2000-7f2d57ac3000 r--p 00107000 08:02 2100380 /lib/x86_64-linux-gnu/libm-2.23.so
7f2d57ac3000-7f2d57ac4000 rw-p 00108000 08:02 2100380 /lib/x86_64-linux-gnu/libm-2.23.so
7f2d57ac4000-7f2d57c36000 r-xp 00000000 08:02 787980 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f2d57c36000-7f2d57e36000 ---p 00172000 08:02 787980 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f2d57e36000-7f2d57e40000 r--p 00172000 08:02 787980 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f2d57e40000-7f2d57e42000 rw-p 0017c000 08:02 787980 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.21
7f2d57e42000-7f2d57e46000 rw-p 00000000 00:00 0
7f2d57e46000-7f2d57e53000 r-xp 00000000 08:02 3015624 /usr/lib/libsfml-system.so.2.4.2
7f2d57e53000-7f2d58052000 ---p 0000d000 08:02 3015624 /usr/lib/libsfml-system.so.2.4.2
7f2d58052000-7f2d58053000 rw-p 0000c000 08:02 3015624 /usr/lib/libsfml-system.so.2.4.2
7f2d58053000-7f2d58075000 r-xp 00000000 08:02 3015627 /usr/lib/libsfml-window.so.2.4.2
7f2d58075000-7f2d58275000 ---p 00022000 08:02 3015627 /usr/lib/libsfml-window.so.2.4.2
7f2d58275000-7f2d58276000 rw-p 00022000 08:02 3015627 /usr/lib/libsfml-window.so.2.4.2
7f2d58276000-7f2d58277000 rw-p 00000000 00:00 0
7f2d58277000-7f2d582c4000 r-xp 00000000 08:02 3015633 /usr/lib/libsfml-graphics.so.2.4.2
7f2d582c4000-7f2d584c3000 ---p 0004d000 08:02 3015633 /usr/lib/libsfml-graphics.so.2.4.2
7f2d584c3000-7f2d584c5000 rw-p 0004c000 08:02 3015633 /usr/lib/libsfml-graphics.so.2.4.2
7f2d584c5000-7f2d584c6000 rw-p 00000000 00:00 0
7f2d584c6000-7f2d584d6000 r-xp 00000000 08:02 2100348 /lib/x86_64-linux-gnu/ld-2.23.so
7f2d584d6000-7f2d584d7000 r-xp 00010000 08:02 2100348 /lib/x86_64-linux-gnu/ld-2.23.so
7f2d584d7000-7f2d584ec000 r-xp 00011000 08:02 2100348 /lib/x86_64-linux-gnu/ld-2.23.so
7f2d584f2000-7f2d58512000 rw-s 1eb561000 00:06 591 /dev/nvidiactl
7f2d58512000-7f2d58532000 rw-s 1eb65b000 00:06 591 /dev/nvidiactl
7f2d58532000-7f2d58572000 rw-s a20b8000 00:06 591 /dev/nvidiactl
7f2d58572000-7f2d58592000 rw-s a214e000 00:06 591 /dev/nvidiactl
7f2d58592000-7f2d58697000 rw-s 0ade7000 00:06 591 /dev/nvidiactl
7f2d58697000-7f2d586a1000 rw-p 00000000 00:00 0
7f2d586a1000-7f2d586bf000 r-xp 00000000 08:02 2097534 /lib/x86_64-linux-gnu/libudev.so.1.6.4
7f2d586bf000-7f2d586c0000 r--p 0001d000 08:02 2097534 /lib/x86_64-linux-gnu/libudev.so.1.6.4
7f2d586c0000-7f2d586c1000 rw-p 0001e000 08:02 2097534 /lib/x86_64-linux-gnu/libudev.so.1.6.4
7f2d586c1000-7f2d586c7000 rw-p 00000000 00:00 0
7f2d586d1000-7f2d586d2000 rw-p 00000000 00:00 0
7f2d586d2000-7f2d586d4000 rw-s 00000000 08:02 262928 /tmp/.gljLFg1G (deleted)
7f2d586d4000-7f2d586d5000 rw-s 1eb5f7000 00:06 591 /dev/nvidiactl
7f2d586d5000-7f2d586d9000 rw-s 1eb5f3000 00:06 591 /dev/nvidiactl
7f2d586d9000-7f2d586da000 rw-s cfde6000 00:06 592 /dev/nvidia0
7f2d586da000-7f2d586e5000 rw-p 00000000 00:00 0
7f2d586e5000-7f2d586e6000 rw-s cfde6000 00:06 592 /dev/nvidia0
7f2d586e6000-7f2d586e7000 rw-s cfde6000 00:06 592 /dev/nvidia0
7f2d586e7000-7f2d586e8000 rw-s 343e7000 00:06 591 /dev/nvidiactl
7f2d586e8000-7f2d586e9000 rw-s fa060000 00:06 592 /dev/nvidia0
7f2d586e9000-7f2d586eb000 rw-p 00000000 00:00 0
7f2d586eb000-7f2d586ec000 r--p 00025000 08:02 2100348 /lib/x86_64-linux-gnu/ld-2.23.so
7f2d586ec000-7f2d586ed000 rw-p 00026000 08:02 2100348 /lib/x86_64-linux-gnu/ld-2.23.so
7f2d586ed000-7f2d586ee000 rw-p 00000000 00:00 0
7ffd483cb000-7ffd483ec000 rw-p 00000000 00:00 0 [stack]
7ffd483f8000-7ffd483fa000 r--p 00000000 00:00 0 [vvar]
7ffd483fa000-7ffd483fc000 r-xp 00000000 00:00 0 [vdso]
ffffffffff600000-ffffffffff601000 r-xp 00000000 00:00 0 [vsyscall]
Aborted (core dumped)
I tried installing the newest nvidia drivers and restarting the system, no luck with this one. Do I lack some dependencies?
EDIT:
I tried debugging with GDB and this is the backtrace I got:
Program received signal SIGABRT, Aborted.
0x00007ffff6dc2428 in __GI_raise (sig=sig#entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
54 ../sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 0x00007ffff6dc2428 in __GI_raise (sig=sig#entry=6) at ../sysdeps/unix/sysv/linux/raise.c:54
#1 0x00007ffff6dc402a in __GI_abort () at abort.c:89
#2 0x00007ffff6e047ea in __libc_message (do_abort=do_abort#entry=2, fmt=fmt#entry=0x7ffff6f1d2e0 "*** Error in `%s': %s: 0x%s ***\n") at ../sysdeps/posix/libc_fatal.c:175
#3 0x00007ffff6e0ce0a in malloc_printerr (ar_ptr=<optimised out>, ptr=<optimised out>, str=0x7ffff6f1a0b2 "free(): invalid pointer", action=3) at malloc.c:5004
#4 _int_free (av=<optimised out>, p=<optimised out>, have_lock=0) at malloc.c:3865
#5 0x00007ffff6e1098c in __GI___libc_free (mem=<optimised out>) at malloc.c:2966
#6 0x0000000000401750 in __gnu_cxx::new_allocator<unsigned int>::deallocate(unsigned int*, unsigned long) ()
#7 0x000000000040171f in __gnu_cxx::__alloc_traits<std::allocator<unsigned int> >::deallocate(std::allocator<unsigned int>&, unsigned int*, unsigned long) ()
#8 0x00000000004016ae in std::__cxx11::basic_string<unsigned int, std::char_traits<unsigned int>, std::allocator<unsigned int> >::_M_destroy(unsigned long) ()
#9 0x0000000000401624 in std::__cxx11::basic_string<unsigned int, std::char_traits<unsigned int>, std::allocator<unsigned int> >::_M_dispose() ()
#10 0x00000000004015a3 in std::__cxx11::basic_string<unsigned int, std::char_traits<unsigned int>, std::allocator<unsigned int> >::~basic_string() ()
#11 0x000000000040156a in sf::String::~String() ()
#12 0x00007ffff7934f27 in (anonymous namespace)::ewmhSupported () at /usr/local/share/buildslave/debian-gcc-64/build/src/SFML/Window/Unix/WindowImplX11.cpp:253
#13 0x00007ffff7935da9 in sf::priv::WindowImplX11::WindowImplX11 (this=0x83c480, mode=..., title=..., style=7, settings=...)
at /usr/local/share/buildslave/debian-gcc-64/build/src/SFML/Window/Unix/WindowImplX11.cpp:451
#14 0x00007ffff792f229 in sf::priv::WindowImpl::create (mode=..., title=..., style=7, settings=...) at /usr/local/share/buildslave/debian-gcc-64/build/src/SFML/Window/WindowImpl.cpp:71
#15 0x00007ffff792e7b3 in sf::Window::create (this=0x7fffffffdc20, mode=..., title=..., style=7, settings=...) at /usr/local/share/buildslave/debian-gcc-64/build/src/SFML/Window/Window.cpp:124
#16 0x00007ffff7ba796b in sf::RenderWindow::RenderWindow (this=0x7fffffffdc20, mode=..., title=..., style=7, settings=...)
at /usr/local/share/buildslave/debian-gcc-64/build/src/SFML/Graphics/RenderWindow.cpp:45
#17 0x000000000040131e in main ()
So the answer should probably be: build SFML 2.4.2 yourself. But using my self-built SFML also produces errors while compiling simple SFML example code, this time during linking stage due to some known bug in Ubuntu. There's a simple fix though:
Download the SFML source code. Unpack it. Navigate to the root directory of the unzipped source code.
vim ./SFML/src/SFML/Graphics/CMakeLists.txt
Find the line on about line 149 -ish... yours may be different, since this is line 149 AFTER I made changes... which reads:
149 # ImageLoader.cpp must be compiled with the -fno-strict-aliasing
150 # when gcc is used; otherwise saving PNGs may crash in stb_image_write
151 if(SFML_COMPILER_GCC)
152 set_source_files_properties(${SRCROOT}/ImageLoader.cpp PROPERTIES COMPILE_FLAGS -fno-strict-aliasing)
153 endif()
Add the following lines BELOW
156 if(SFML_COMPILER_GCC AND BUILD_SHARED_LIBS)
157 message(WARNING "Applying workaround for https://bugs.launchpad.net/ubuntu/+source/gcc-5/+bug/1568899")
158 list(APPEND GRAPHICS_EXT_LIBS "-lgcc_s -lgcc")
159 endif()
Then cd to root dir of unpacked source
cmake .
make all
sudo make install
which I found on the SFML forums: http://en.sfml-dev.org/forums/index.php?topic=20638.0.
There's also SFML 2.3 if you don't care about getting the latest build in Ubuntu repositories which you can install with apt-get.

How to track random free() invalid pointer AFTER program exit?

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.

After I execute a certain function, attempting to read files always causes errors

This probably has nothing to do with the problem, but here's the context: I have been following a tutorial on OpenGL and decided to try creating my own bone system before looking up a potentially better implementation.
Here's the problem: I have created a simple text-based format for my skeleton file. I also load an OBJ file, two GLSL shaders, and a texture in PNG format. (In case it matters, I load the texture using STB Image from nothings.org). All of my file loading has been successful before. Loading the skeleton file is successful, but after I load the skeleton file, all subsequent attempts to load files fail, producing various errors, depending on the placement of the function call. In the position I prefer to have it, it produces a SIGABRT.
Here is my code to initialize a skeleton, plus includes:
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <fstream>
#include <cstring>
#include <glm/glm.hpp>
#include <glm/gtc/matrix_transform.hpp>
#include "model_stuff.hpp"
#include "skeleton_stuff.hpp"
void Skeleton::init(const char *sklfile) {
std::ifstream in(sklfile, std::ios::in);
if (!in) { std::cerr << "Cannot open " << sklfile << std::endl; exit(1); }
std::string line;
getline(in, line);
if(line.substr(0,2) == "i ") {
std::istringstream s(line.substr(2));
s >> this->numBinds;
this->boneBinds = new BoneBind[numBinds];
} else {
std::cerr << "Error: Missing information line for " << sklfile << std::endl; exit(1);
}
while (getline(in, line)) {
if(line.substr(0,2) == "b ") {
std::istringstream s(line.substr(2));
std::string name;
s >> name;
glm::vec4 pos;
s >> pos.x; s >> pos.y; s >> pos.z; pos.w = 1.0f;
} else if(line.substr(0,2) == "v ") {
std::istringstream s(line.substr(2));
int v;
s >> v;
std::vector<Bone*> bones;
while(!s.eof()) {
std::string str;
s >> str;
bones.push_back(this->boneNamed(str));
}
float boneweight = 1.0f;
if(bones.size() > 0) {
boneweight = 0.5f;
}
boneBinds[v].boneweight = bones.size();
boneBinds[v].childbone = bones[0];
if(boneweight != 1.0f) {
boneBinds[v].superbone = bones[1];
} else {
boneBinds[v].superbone = bones[0];
}
}
}
}
Here is the output from gdb:
(gdb) run
Starting program: /home/pitzik4/Dropbox/Pitzik4/cppWorkspaces/glTestWorkspace/Triangle2/bin/model
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
*** glibc detected *** /home/pitzik4/Dropbox/Pitzik4/cppWorkspaces/glTestWorkspace/Triangle2/bin/model: free(): invalid next size (normal): 0x0000000000d630c0 ***
======= Backtrace: =========
/lib/x86_64-linux-gnu/libc.so.6(+0x7e626)[0x7ffff6b7a626]
/usr/lib/x86_64-linux-gnu/dri/libdricore.so(_mesa_symbol_table_dtor+0x55)[0x7ffff4537bb5]
/usr/lib/x86_64-linux-gnu/dri/libglsl.so(_ZN17glsl_symbol_tableD1Ev+0xd)[0x7ffff41024dd]
/usr/lib/x86_64-linux-gnu/dri/libglsl.so(_Z22cross_validate_globalsP17gl_shader_programPP9gl_shaderjb+0x116)[0x7ffff4112306]
/usr/lib/x86_64-linux-gnu/dri/libglsl.so(_Z12link_shadersP10gl_contextP17gl_shader_program+0x260)[0x7ffff4113e40]
/usr/lib/x86_64-linux-gnu/dri/libdricore.so(_mesa_glsl_link_shader+0xfb)[0x7ffff459e21b]
/usr/lib/x86_64-linux-gnu/dri/libdricore.so(_mesa_get_fixed_func_fragment_program+0xa59)[0x7ffff4592c39]
/usr/lib/x86_64-linux-gnu/dri/libdricore.so(_mesa_update_state_locked+0x872)[0x7ffff44978e2]
/usr/lib/x86_64-linux-gnu/dri/libdricore.so(_mesa_update_state+0x11)[0x7ffff4497d51]
/usr/lib/x86_64-linux-gnu/dri/libdricore.so(+0xcfc48)[0x7ffff44a9c48]
/usr/lib/x86_64-linux-gnu/dri/libdricore.so(_mesa_TexImage2D+0x54)[0x7ffff44aa364]
/home/pitzik4/Dropbox/Pitzik4/cppWorkspaces/glTestWorkspace/Triangle2/bin/model[0x418b1d]
/home/pitzik4/Dropbox/Pitzik4/cppWorkspaces/glTestWorkspace/Triangle2/bin/model[0x419a28]
/lib/x86_64-linux-gnu/libc.so.6(__libc_start_main+0xed)[0x7ffff6b1d76d]
/home/pitzik4/Dropbox/Pitzik4/cppWorkspaces/glTestWorkspace/Triangle2/bin/model[0x403339]
======= Memory map: ========
00400000-00423000 r-xp 00000000 08:05 4456901 /home/pitzik4/Dropbox/Pitzik4/cppWorkspaces/glTestWorkspace/Triangle2/bin/model
00622000-00623000 r--p 00022000 08:05 4456901 /home/pitzik4/Dropbox/Pitzik4/cppWorkspaces/glTestWorkspace/Triangle2/bin/model
00623000-00624000 rw-p 00023000 08:05 4456901 /home/pitzik4/Dropbox/Pitzik4/cppWorkspaces/glTestWorkspace/Triangle2/bin/model
00624000-00d7e000 rw-p 00000000 00:00 0 [heap]
7ffff2efb000-7ffff3841000 rw-p 00000000 00:00 0
7ffff3841000-7ffff3857000 r-xp 00000000 08:05 1576592 /lib/x86_64-linux-gnu/libz.so.1.2.3.4
7ffff3857000-7ffff3a56000 ---p 00016000 08:05 1576592 /lib/x86_64-linux-gnu/libz.so.1.2.3.4
7ffff3a56000-7ffff3a57000 r--p 00015000 08:05 1576592 /lib/x86_64-linux-gnu/libz.so.1.2.3.4
7ffff3a57000-7ffff3a58000 rw-p 00016000 08:05 1576592 /lib/x86_64-linux-gnu/libz.so.1.2.3.4
7ffff3a58000-7ffff3a60000 r-xp 00000000 08:05 5120173 /usr/lib/x86_64-linux-gnu/libpciaccess.so.0.11.0
7ffff3a60000-7ffff3c5f000 ---p 00008000 08:05 5120173 /usr/lib/x86_64-linux-gnu/libpciaccess.so.0.11.0
7ffff3c5f000-7ffff3c60000 r--p 00007000 08:05 5120173 /usr/lib/x86_64-linux-gnu/libpciaccess.so.0.11.0
7ffff3c60000-7ffff3c61000 rw-p 00008000 08:05 5120173 /usr/lib/x86_64-linux-gnu/libpciaccess.so.0.11.0
7ffff3c61000-7ffff3c7d000 r-xp 00000000 08:05 5119862 /usr/lib/x86_64-linux-gnu/libdrm_intel.so.1.0.0
7ffff3c7d000-7ffff3e7c000 ---p 0001c000 08:05 5119862 /usr/lib/x86_64-linux-gnu/libdrm_intel.so.1.0.0
7ffff3e7c000-7ffff3e7d000 r--p 0001b000 08:05 5119862 /usr/lib/x86_64-linux-gnu/libdrm_intel.so.1.0.0
7ffff3e7d000-7ffff3e7e000 rw-p 0001c000 08:05 5119862 /usr/lib/x86_64-linux-gnu/libdrm_intel.so.1.0.0
7ffff3e7e000-7ffff3ea5000 r-xp 00000000 08:05 1576499 /lib/x86_64-linux-gnu/libexpat.so.1.5.2
7ffff3ea5000-7ffff40a5000 ---p 00027000 08:05 1576499 /lib/x86_64-linux-gnu/libexpat.so.1.5.2
7ffff40a5000-7ffff40a7000 r--p 00027000 08:05 1576499 /lib/x86_64-linux-gnu/libexpat.so.1.5.2
7ffff40a7000-7ffff40a8000 rw-p 00029000 08:05 1576499 /lib/x86_64-linux-gnu/libexpat.so.1.5.2
7ffff40a8000-7ffff41ce000 r-xp 00000000 08:05 1569 /usr/lib/x86_64-linux-gnu/dri/libglsl.so
7ffff41ce000-7ffff43cd000 ---p 00126000 08:05 1569 /usr/lib/x86_64-linux-gnu/dri/libglsl.so
7ffff43cd000-7ffff43d6000 r--p 00125000 08:05 1569 /usr/lib/x86_64-linux-gnu/dri/libglsl.so
7ffff43d6000-7ffff43d9000 rw-p 0012e000 08:05 1569 /usr/lib/x86_64-linux-gnu/dri/libglsl.so
7ffff43d9000-7ffff43da000 rw-p 00000000 00:00 0
7ffff43da000-7ffff4618000 r-xp 00000000 08:05 1570 /usr/lib/x86_64-linux-gnu/dri/libdricore.so
7ffff4618000-7ffff4818000 ---p 0023e000 08:05 1570 /usr/lib/x86_64-linux-gnu/dri/libdricore.so
7ffff4818000-7ffff4822000 r--p 0023e000 08:05 1570 /usr/lib/x86_64-linux-gnu/dri/libdricore.so
7ffff4822000-7ffff4825000 rw-p 00248000 08:05 1570 /usr/lib/x86_64-linux-gnu/dri/libdricore.so
7ffff4825000-7ffff483b000 rw-p 00000000 00:00 0
7ffff483b000-7ffff4909000 r-xp 00000000 08:05 1334 /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
7ffff4909000-7ffff4b09000 ---p 000ce000 08:05 1334 /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
7ffff4b09000-7ffff4b0c000 r--p 000ce000 08:05 1334 /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
7ffff4b0c000-7ffff4b10000 rw-p 000d1000 08:05 1334 /usr/lib/x86_64-linux-gnu/dri/i965_dri.so
7ffff4b10000-7ffff4b17000 r-xp 00000000 08:05 1576567 /lib/x86_64-linux-gnu/librt-2.15.so
7ffff4b17000-7ffff4d16000 ---p 00007000 08:05 1576567 /lib/x86_64-linux-gnu/librt-2.15.so
7ffff4d16000-7ffff4d17000 r--p 00006000 08:05 1576567 /lib/x86_64-linux-gnu/librt-2.15.so
7ffff4d17000-7ffff4d18000 rw-p 00007000 08:05 1576567 /lib/x86_64-linux-gnu/librt-2.15.so
7ffff4d18000-7ffff4d1d000 r-xp 00000000 08:05 5119694 /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
7ffff4d1d000-7ffff4f1c000 ---p 00005000 08:05 5119694 /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
7ffff4f1c000-7ffff4f1d000 r--p 00004000 08:05 5119694 /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
7ffff4f1d000-7ffff4f1e000 rw-p 00005000 08:05 5119694 /usr/lib/x86_64-linux-gnu/libXdmcp.so.6.0.0
7ffff4f1e000-7ffff4f20000 r-xp 00000000 08:05 5119681 /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
7ffff4f20000-7ffff511f000 ---p 00002000 08:05 5119681 /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
7ffff511f000-7ffff5120000 r--p 00001000 08:05 5119681 /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
7ffff5120000-7ffff5121000 rw-p 00002000 08:05 5119681 /usr/lib/x86_64-linux-gnu/libXau.so.6.0.0
7ffff5121000-7ffff5123000 r-xp 00000000 08:05 1576494 /lib/x86_64-linux-gnu/libdl-2.15.so
7ffff5123000-7ffff5323000 ---p 00002000 08:05 1576494 /lib/x86_64-linux-gnu/libdl-2.15.so
7ffff5323000-7ffff5324000 r--p 00002000 08:05 1576494 /lib/x86_64-linux-gnu/libdl-2.15.so
7ffff5324000-7ffff5325000 rw-p 00003000 08:05 1576494 /lib/x86_64-linux-gnu/libdl-2.15.so
7ffff5325000-7ffff532f000 r-xp 00000000 08:05 5119860 /usr/lib/x86_64-linux-gnu/libdrm.so.2.4.0
7ffff532f000-7ffff552e000 ---p 0000a000 08:05 5119860 /usr/lib/x86_64-linux-gnu/libdrm.so.2.4.0
7ffff552e000-7ffff552f000 r--p 00009000 08:05 5119860 /usr/lib/x86_64-linux-gnu/libdrm.so.2.4.0
7ffff552f000-7ffff5530000 rw-p 0000a000 08:05 5119860 /usr/lib/x86_64-linux-gnu/libdrm.so.2.4.0
7ffff5530000-7ffff5534000 r-xp 00000000 08:05 5119726 /usr/lib/x86_64-linux-gnu/libXxf86vm.so.1.0.0
7ffff5534000-7ffff5733000 ---p 00004000 08:05 5119726 /usr/lib/x86_64-linux-gnu/libXxf86vm.so.1.0.0
7ffff5733000-7ffff5734000 r--p 00003000 08:05 5119726 /usr/lib/x86_64-linux-gnu/libXxf86vm.so.1.0.0
7ffff5734000-7ffff5735000 rw-p 00004000 08:05 5119726 /usr/lib/x86_64-linux-gnu/libXxf86vm.so.1.0.0
7ffff5735000-7ffff5752000 r-xp 00000000 08:05 5120366 /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
7ffff5752000-7ffff5951000 ---p 0001d000 08:05 5120366 /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
7ffff5951000-7ffff5952000 r--p 0001c000 08:05 5120366 /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
7ffff5952000-7ffff5953000 rw-p 0001d000 08:05 5120366 /usr/lib/x86_64-linux-gnu/libxcb.so.1.1.0
7ffff5953000-7ffff5968000 r-xp 00000000 08:05 5120350 /usr/lib/x86_64-linux-gnu/libxcb-glx.so.0.0.0
7ffff5968000-7ffff5b67000 ---p 00015000 08:05 5120350 /usr/lib/x86_64-linux-gnu/libxcb-glx.so.0.0.0
7ffff5b67000-7ffff5b69000 r--p 00014000 08:05 5120350 /usr/lib/x86_64-linux-gnu/libxcb-glx.so.0.0.0
7ffff5b69000-7ffff5b6a000 rw-p 00016000 08:05 5120350 /usr/lib/x86_64-linux-gnu/libxcb-glx.so.0.0.0
7ffff5b6a000-7ffff5b6b000 r-xp 00000000 08:05 5119673 /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1.0.0
7ffff5b6b000-7ffff5d6a000 ---p 00001000 08:05 5119673 /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1.0.0
7ffff5d6a000-7ffff5d6b000 r--p 00000000 08:05 5119673 /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1.0.0
7ffff5d6b000-7ffff5d6c000 rw-p 00001000 08:05 5119673 /usr/lib/x86_64-linux-gnu/libX11-xcb.so.1.0.0
7ffff5d6c000-7ffff5d71000 r-xp 00000000 08:05 5119698 /usr/lib/x86_64-linux-gnu/libXfixes.so.3.1.0
7ffff5d71000-7ffff5f70000 ---p 00005000 08:05 5119698 /usr/lib/x86_64-linux-gnu/libXfixes.so.3.1.0
7ffff5f70000-7ffff5f71000 r--p 00004000 08:05 5119698 /usr/lib/x86_64-linux-gnu/libXfixes.so.3.1.0
7ffff5f71000-7ffff5f72000 rw-p 00005000 08:05 5119698 /usr/lib/x86_64-linux-gnu/libXfixes.so.3.1.0
7ffff5f72000-7ffff5f74000 r-xp 00000000 08:05 5119690 /usr/lib/x86_64-linux-gnu/libXdamage.so.1.1.0
7ffff5f74000-7ffff6173000 ---p 00002000 08:05 5119690 /usr/lib/x86_64-linux-gnu/libXdamage.so.1.1.0
7ffff6173000-7ffff6174000 r--p 00001000 08:05 5119690 /usr/lib/x86_64-linux-gnu/libXdamage.so.1.1.0
7ffff6174000-7ffff6175000 rw-p 00002000 08:05 5119690 /usr/lib/x86_64-linux-gnu/libXdamage.so.1.1.0
7ffff6175000-7ffff6185000 r-xp 00000000 08:05 5119696 /usr/lib/x86_64-linux-gnu/libXext.so.6.4.0
7ffff6185000-7ffff6384000 ---p 00010000 08:05 5119696 /usr/lib/x86_64-linux-gnu/libXext.so.6.4.0
7ffff6384000-7ffff6385000 r--p 0000f000 08:05 5119696 /usr/lib/x86_64-linux-gnu/libXext.so.6.4.0
7ffff6385000-7ffff6386000 rw-p 00010000 08:05 5119696 /usr/lib/x86_64-linux-gnu/libXext.so.6.4.0
7ffff6386000-7ffff63a7000 r-xp 00000000 08:05 5126526 /usr/lib/x86_64-linux-gnu/libglapi.so.0.0.0
7ffff63a7000-7ffff65a6000 ---p 00021000 08:05 5126526 /usr/lib/x86_64-linux-gnu/libglapi.so.0.0.0
7ffff65a6000-7ffff65a9000 r--p 00020000 08:05 5126526 /usr/lib/x86_64-linux-gnu/libglapi.so.0.0.0
7ffff65a9000-7ffff65aa000 rw-p 00023000 08:05 5126526 /usr/lib/x86_64-linux-gnu/libglapi.so.0.0.0
7ffff65aa000-7ffff65ab000 rw-p 00000000 00:00 0
7ffff65ab000-7ffff66da000 r-xp 00000000 08:05 5119677 /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0
7ffff66da000-7ffff68da000 ---p 0012f000 08:05 5119677 /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0
7ffff68da000-7ffff68db000 r--p 0012f000 08:05 5119677 /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0
7ffff68db000-7ffff68df000 rw-p 00130000 08:05 5119677 /usr/lib/x86_64-linux-gnu/libX11.so.6.3.0
7ffff68df000-7ffff68f7000 r-xp 00000000 08:05 1576561 /lib/x86_64-linux-gnu/libpthread-2.15.so
7ffff68f7000-7ffff6af6000 ---p 00018000 08:05 1576561 /lib/x86_64-linux-gnu/libpthread-2.15.so
7ffff6af6000-7ffff6af7000 r--p 00017000 08:05 1576561 /lib/x86_64-linux-gnu/libpthread-2.15.so
7ffff6af7000-7ffff6af8000 rw-p 00018000 08:05 1576561 /lib/x86_64-linux-gnu/libpthread-2.15.so
7ffff6af8000-7ffff6afc000 rw-p 00000000 00:00 0
7ffff6afc000-7ffff6caf000 r-xp 00000000 08:05 1576481 /lib/x86_64-linux-gnu/libc-2.15.so
7ffff6caf000-7ffff6eae000 ---p 001b3000 08:05 1576481 /lib/x86_64-linux-gnu/libc-2.15.so
7ffff6eae000-7ffff6eb2000 r--p 001b2000 08:05 1576481 /lib/x86_64-linux-gnu/libc-2.15.so
7ffff6eb2000-7ffff6eb4000 rw-p 001b6000 08:05 1576481 /lib/x86_64-linux-gnu/libc-2.15.so
7ffff6eb4000-7ffff6eb9000 rw-p 00000000 00:00 0
7ffff6eb9000-7ffff6ece000 r-xp 00000000 08:05 1576502 /lib/x86_64-linux-gnu/libgcc_s.so.1
7ffff6ece000-7ffff70cd000 ---p 00015000 08:05 1576502 /lib/x86_64-linux-gnu/libgcc_s.so.1
7ffff70cd000-7ffff70ce000 r--p 00014000 08:05 1576502 /lib/x86_64-linux-gnu/libgcc_s.so.1
7ffff70ce000-7ffff70cf000 rw-p 00015000 08:05 1576502 /lib/x86_64-linux-gnu/libgcc_s.so.1
7ffff70cf000-7ffff71c8000 r-xp 00000000 08:05 1576513 /lib/x86_64-linux-gnu/libm-2.15.so
7ffff71c8000-7ffff73c7000 ---p 000f9000 08:05 1576513 /lib/x86_64-linux-gnu/libm-2.15.so
7ffff73c7000-7ffff73c8000 r--p 000f8000 08:05 1576513 /lib/x86_64-linux-gnu/libm-2.15.so
7ffff73c8000-7ffff73c9000 rw-p 000f9000 08:05 1576513 /lib/x86_64-linux-gnu/libm-2.15.so
7ffff73c9000-7ffff74ab000 r-xp 00000000 08:05 5120266 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
7ffff74ab000-7ffff76aa000 ---p 000e2000 08:05 5120266 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
7ffff76aa000-7ffff76b2000 r--p 000e1000 08:05 5120266 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
7ffff76b2000-7ffff76b4000 rw-p 000e9000 08:05 5120266 /usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.16
7ffff76b4000-7ffff76c9000 rw-p 00000000 00:00 0
7ffff76c9000-7ffff7726000 r-xp 00000000 08:05 2898 /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2
7ffff7726000-7ffff7925000 ---p 0005d000 08:05 2898 /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2
7ffff7925000-7ffff7927000 r--p 0005c000 08:05 2898 /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2
7ffff7927000-7ffff7928000 rw-p 0005e000 08:05 2898 /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1.2
7ffff7928000-7ffff7929000 rw-p 00000000 00:00 0
7ffff7929000-7ffff798a000 r-xp 00000000 08:05 5119616 /usr/lib/x86_64-linux-gnu/libGLEW.so.1.6.0
7ffff798a000-7ffff7b89000 ---p 00061000 08:05 5119616 /usr/lib/x86_64-linux-gnu/libGLEW.so.1.6.0
7ffff7b89000-7ffff7b8f000 r--p 00060000 08:05 5119616 /usr/lib/x86_64-linux-gnu/libGLEW.so.1.6.0
7ffff7b8f000-7ffff7b90000 rw-p 00066000 08:05 5119616 /usr/lib/x86_64-linux-gnu/libGLEW.so.1.6.0
7ffff7b90000-7ffff7b94000 rw-p 00000000 00:00 0
Program received signal SIGABRT, Aborted.
0x00007ffff6b32445 in raise () from /lib/x86_64-linux-gnu/libc.so.6
(gdb) bt
#0 0x00007ffff6b32445 in raise () from /lib/x86_64-linux-gnu/libc.so.6
#1 0x00007ffff6b35bab in abort () from /lib/x86_64-linux-gnu/libc.so.6
#2 0x00007ffff6b6fe2e in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#3 0x00007ffff6b7a626 in ?? () from /lib/x86_64-linux-gnu/libc.so.6
#4 0x00007ffff4537bb5 in _mesa_symbol_table_dtor ()
from /usr/lib/x86_64-linux-gnu/dri/libdricore.so
#5 0x00007ffff41024dd in glsl_symbol_table::~glsl_symbol_table() ()
from /usr/lib/x86_64-linux-gnu/dri/libglsl.so
#6 0x00007ffff4112306 in cross_validate_globals(gl_shader_program*, gl_shader**, unsigned int, bool) () from /usr/lib/x86_64-linux-gnu/dri/libglsl.so
#7 0x00007ffff4113e40 in link_shaders(gl_context*, gl_shader_program*) ()
from /usr/lib/x86_64-linux-gnu/dri/libglsl.so
#8 0x00007ffff459e21b in _mesa_glsl_link_shader ()
from /usr/lib/x86_64-linux-gnu/dri/libdricore.so
#9 0x00007ffff4592c39 in _mesa_get_fixed_func_fragment_program ()
from /usr/lib/x86_64-linux-gnu/dri/libdricore.so
#10 0x00007ffff44978e2 in _mesa_update_state_locked ()
from /usr/lib/x86_64-linux-gnu/dri/libdricore.so
#11 0x00007ffff4497d51 in _mesa_update_state ()
from /usr/lib/x86_64-linux-gnu/dri/libdricore.so
#12 0x00007ffff44a9c48 in ?? ()
from /usr/lib/x86_64-linux-gnu/dri/libdricore.so
#13 0x00007ffff44aa364 in _mesa_TexImage2D ()
---Type <return> to continue, or q <return> to quit---
from /usr/lib/x86_64-linux-gnu/dri/libdricore.so
#14 0x0000000000418b1d in initResources () at src/model.cpp:126
#15 0x0000000000419a28 in main (argc=1, args=0x7fffffffe7e8)
at src/model.cpp:350
I am using make to compile with g++ -g. I'm running 64-bit Linux Mint.
That's all of the potentially useful information I could think of. If I did not supply enough information here to find a solution to this problem, just add a comment and I'll put in an edit with the info.
So... What can I do to fix this problem? I've been intermittently Googling it and trying to fix it for hours now, to no avail.

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.