|
From: Florian L. <mai...@xg...> - 2016-03-01 13:25:12
|
Hello,
I'm using valgrind 3.11.0 with openmpi 1.10.2. Distribution is Arch, valgrind is properly built with MPI support.
I compile with:
mpicxx -std=c++11 -g -O0 -Wall mpi.cpp
and execute:
LD_PRELOAD=/usr/lib/valgrind/libmpiwrap-amd64-linux.so mpirun -n 2 valgrind ./a.out
Valgrind reports a number of invalid reads and I have no idea why it is so or whether they are false positives...
I appreciate any help!
Thanks,
Florian
CODE mpi.cpp
#include <mpi.h>
#include <iostream>
#include <string>
using namespace std;
void receive(int rankSender) {
int length = 0;
MPI_Status status;
MPI_Probe(rankSender, 0, MPI_COMM_WORLD, &status);
MPI_Get_count(&status, MPI_CHAR, &length);
cout << "Stringlength = " << length << endl;
char cstr[length];
MPI_Recv(&cstr,
length,
MPI_CHAR,
rankSender,
0,
MPI_COMM_WORLD,
MPI_STATUS_IGNORE);
cout << cstr << endl;
}
void send(int rankReceiver) {
std::string s = "Hallo";
MPI_Send(s.c_str(),
s.size() + 1,
MPI_CHAR,
rankReceiver,
0,
MPI_COMM_WORLD);
}
int main(int argc, char* argv[])
{
int rank;
MPI_Init(&argc, &argv);
MPI_Comm_rank(MPI_COMM_WORLD, &rank);
if (rank == 0)
send(1);
else {
receive(0);
}
MPI_Finalize();
return 0;
}
VALGRIND OUTPUT
% LD_PRELOAD=/usr/lib/valgrind/libmpiwrap-amd64-linux.so mpirun -n 2 valgrind ./a.out
==11513== Memcheck, a memory error detector
==11513== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==11513== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==11513== Command: ./a.out
==11513==
==11514== Memcheck, a memory error detector
==11514== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al.
==11514== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright info
==11514== Command: ./a.out
==11514==
valgrind MPI wrappers 11514: Active for pid 11514
valgrind MPI wrappers 11514: Try MPIWRAP_DEBUG=help for possible options
valgrind MPI wrappers 11513: Active for pid 11513
valgrind MPI wrappers 11513: Try MPIWRAP_DEBUG=help for possible options
Stringlength = 6
==11514== Invalid read of size 1
==11514== at 0x4C2DBA2: strlen (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==11514== by 0x56852D8: length (char_traits.h:267)
==11514== by 0x56852D8: std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*) (ostream:562)
==11514== by 0x408A3C: receive(int) (mpi.cpp:22)
==11514== by 0x408B69: main (mpi.cpp:46)
==11514== Address 0xffefff860 is on thread 1's stack
==11514== in frame #2, created by receive(int) (mpi.cpp:8)
==11514==
==11514== Invalid read of size 1
==11514== at 0x4C2DBB4: strlen (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==11514== by 0x56852D8: length (char_traits.h:267)
==11514== by 0x56852D8: std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*) (ostream:562)
==11514== by 0x408A3C: receive(int) (mpi.cpp:22)
==11514== by 0x408B69: main (mpi.cpp:46)
==11514== Address 0xffefff861 is on thread 1's stack
==11514== in frame #2, created by receive(int) (mpi.cpp:8)
==11514==
==11514== Invalid read of size 1
==11514== at 0x60A0FF1: _IO_file_xsputn@@GLIBC_2.2.5 (in /usr/lib/libc-2.23.so)
==11514== by 0x6096D1A: fwrite (in /usr/lib/libc-2.23.so)
==11514== by 0x5684F75: sputn (streambuf:451)
==11514== by 0x5684F75: __ostream_write<char, std::char_traits<char> > (ostream_insert.h:50)
==11514== by 0x5684F75: std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long) (ostream_insert.h:101)
==11514== by 0x56852E6: std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*) (ostream:561)
==11514== by 0x408A3C: receive(int) (mpi.cpp:22)
==11514== by 0x408B69: main (mpi.cpp:46)
==11514== Address 0xffefff864 is on thread 1's stack
==11514== in frame #4, created by receive(int) (mpi.cpp:8)
==11514==
==11514== Invalid read of size 1
==11514== at 0x60A100D: _IO_file_xsputn@@GLIBC_2.2.5 (in /usr/lib/libc-2.23.so)
==11514== by 0x6096D1A: fwrite (in /usr/lib/libc-2.23.so)
==11514== by 0x5684F75: sputn (streambuf:451)
==11514== by 0x5684F75: __ostream_write<char, std::char_traits<char> > (ostream_insert.h:50)
==11514== by 0x5684F75: std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long) (ostream_insert.h:101)
==11514== by 0x56852E6: std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*) (ostream:561)
==11514== by 0x408A3C: receive(int) (mpi.cpp:22)
==11514== by 0x408B69: main (mpi.cpp:46)
==11514== Address 0xffefff863 is on thread 1's stack
==11514== in frame #4, created by receive(int) (mpi.cpp:8)
==11514==
==11514== Invalid read of size 2
==11514== at 0x4C2F9C0: __GI_memcpy (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==11514== by 0x60A0F3A: _IO_file_xsputn@@GLIBC_2.2.5 (in /usr/lib/libc-2.23.so)
==11514== by 0x6096D1A: fwrite (in /usr/lib/libc-2.23.so)
==11514== by 0x5684F75: sputn (streambuf:451)
==11514== by 0x5684F75: __ostream_write<char, std::char_traits<char> > (ostream_insert.h:50)
==11514== by 0x5684F75: std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long) (ostream_insert.h:101)
==11514== by 0x56852E6: std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*) (ostream:561)
==11514== by 0x408A3C: receive(int) (mpi.cpp:22)
==11514== by 0x408B69: main (mpi.cpp:46)
==11514== Address 0xffefff860 is on thread 1's stack
==11514== in frame #5, created by receive(int) (mpi.cpp:8)
==11514==
==11514== Invalid read of size 1
==11514== at 0x4C2F9F8: __GI_memcpy (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==11514== by 0x60A0F3A: _IO_file_xsputn@@GLIBC_2.2.5 (in /usr/lib/libc-2.23.so)
==11514== by 0x6096D1A: fwrite (in /usr/lib/libc-2.23.so)
==11514== by 0x5684F75: sputn (streambuf:451)
==11514== by 0x5684F75: __ostream_write<char, std::char_traits<char> > (ostream_insert.h:50)
==11514== by 0x5684F75: std::basic_ostream<char, std::char_traits<char> >& std::__ostream_insert<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*, long) (ostream_insert.h:101)
==11514== by 0x56852E6: std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*) (ostream:561)
==11514== by 0x408A3C: receive(int) (mpi.cpp:22)
==11514== by 0x408B69: main (mpi.cpp:46)
==11514== Address 0xffefff864 is on thread 1's stack
==11514== in frame #5, created by receive(int) (mpi.cpp:8)
==11514==
Hallo
==11514==
==11514== HEAP SUMMARY:
==11514== in use at exit: 96,351 bytes in 247 blocks
==11514== total heap usage: 15,025 allocs, 14,778 frees, 13,362,600 bytes allocated
==11514==
==11514== LEAK SUMMARY:
==11514== definitely lost: 9,154 bytes in 39 blocks
==11514== indirectly lost: 4,008 bytes in 22 blocks
==11514== possibly lost: 0 bytes in 0 blocks
==11514== still reachable: 83,189 bytes in 186 blocks
==11514== suppressed: 0 bytes in 0 blocks
==11514== Rerun with --leak-check=full to see details of leaked memory
==11514==
==11514== For counts of detected and suppressed errors, rerun with: -v
==11514== ERROR SUMMARY: 14 errors from 6 contexts (suppressed: 0 from 0)
==11513==
==11513== HEAP SUMMARY:
==11513== in use at exit: 96,351 bytes in 247 blocks
==11513== total heap usage: 15,023 allocs, 14,776 frees, 13,370,262 bytes allocated
==11513==
==11513== LEAK SUMMARY:
==11513== definitely lost: 9,154 bytes in 39 blocks
==11513== indirectly lost: 4,008 bytes in 22 blocks
==11513== possibly lost: 0 bytes in 0 blocks
==11513== still reachable: 83,189 bytes in 186 blocks
==11513== suppressed: 0 bytes in 0 blocks
==11513== Rerun with --leak-check=full to see details of leaked memory
==11513==
==11513== For counts of detected and suppressed errors, rerun with: -v
==11513== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0)
florian@asaru ~/scratch (git)-[master] %
|