Am Mittwoch, 2. März 2016, 16:23:02 CET schrieb Jeff Squyres (jsquyres): > There's a bunch of places in OMPI where we don't initialize memory because we > know it doesn't matter (e.g., in padding between unaligned struct members), > but then that memory is accessed when writing the entire struct down a file > descriptor or memcpy'ed elsewhere in memory...etc. It gets even worse with > OS-bypass networks, because valgrind doesn't see the origination of various > buffers, and therefore thinks they're uninitialized (but they *are* actually > initialized). > > If you want to remove spurious valgrind warnings, build Open MPI with the > --enable-memchecker configure option. There's a (slight) performance > penalty, which is why it is not the default.
Hey Jeff, I am using the arch build of openmpi (https://www.archlinux.org/packages/extra/x86_64/openmpi/) and it's already built with enable-memchecker: ./autogen.pl ./configure --prefix=/usr \ --sysconfdir=/etc/${pkgname} \ --enable-mpi-fortran=all \ --libdir=/usr/lib/${pkgname} \ --with-threads=posix \ --enable-smp-locks \ --with-valgrind \ --enable-memchecker \ --enable-pretty-print-stacktrace \ --without-slurm \ --with-hwloc=/usr \ --with-libltdl=/usr \ FC=/usr/bin/gfortran \ LDFLAGS="$LDFLAGS -Wl,-z,noexecstack" make see https://projects.archlinux.org/svntogit/packages.git/tree/trunk/PKGBUILD?h=packages/openmpi Any more ideas? Best, Florian > > > > On Mar 2, 2016, at 9:51 AM, Florian Lindner <mailingli...@xgm.de> wrote: > > > > Hello Gilles, > > > > Am Mittwoch, 2. März 2016, 23:36:56 CET schrieb Gilles Gouaillardet: > >> Florian, > >> > >> under the hood, strlen() can use vector instructions, and then read memory > >> above the end of the string. valgrind is extremely picky and does warn > >> about that. > >> iirc, there are some filter options not to issue these warnings, but I > >> forgot the details. > > > > Ok, i'll try to research in that direction. > > > >> > >> can you try to send "Bonjour" instead of "Halo" and see if the warning > >> disappear ? > > > > They are still there. But, was this meant as a joke or didn't I understand? > > > > Best, > > Florian > > > >> Cheers, > >> > >> Gilles > >> > >> PS if it works, do not jump to the erroneous conclusion valgrind likes > >> French and dislikes German ;-) > >> > >> On Wednesday, March 2, 2016, Florian Lindner <mailingli...@xgm.de> wrote: > >> > >>> Hello, > >>> > >>> using OpenMPI 1.10.2 and valgrind 3.11.0 I try to use the code below to > >>> send a c++ string. > >>> > >>> It works fine, but running through valgrind gives a lot of memory errors, > >>> invalid read of size... > >>> > >>> What is going wrong there? > >>> > >>> Valgrind output, see below. > >>> > >>> Thanks! > >>> Florian > >>> > >>> > >>> // Compile with: mpicxx -std=c++11 -g -O0 -Wall -Wextra mpi.cpp > >>> #include <mpi.h> > >>> #include <iostream> > >>> #include <string> > >>> > >>> using namespace std; > >>> > >>> > >>> void receive() { > >>> int length = 0; > >>> MPI_Status status; > >>> MPI_Probe(MPI_ANY_SOURCE, 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, > >>> MPI_ANY_SOURCE, > >>> MPI_ANY_TAG, > >>> 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(); > >>> } > >>> MPI_Finalize(); > >>> return 0; > >>> } > >>> > >>> > >>> VALGRIND OUTPUT > >>> > >>> % mpicxx -std=c++11 -g -O0 -Wall -Wextra mpi.cpp && mpirun -n 2 ./a.out > >>> Stringlength = 6 > >>> Hallo > >>> florian@asaru ~/scratch (git)-[master] % > >>> LD_PRELOAD=/usr/lib/valgrind/libmpiwrap-amd64-linux.so mpirun -n 2 > >>> valgrind > >>> ./a.out > >>> ==9290== Memcheck, a memory error detector > >>> ==9290== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. > >>> ==9290== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright > >>> info > >>> ==9290== Command: ./a.out > >>> ==9290== > >>> ==9291== Memcheck, a memory error detector > >>> ==9291== Copyright (C) 2002-2015, and GNU GPL'd, by Julian Seward et al. > >>> ==9291== Using Valgrind-3.11.0 and LibVEX; rerun with -h for copyright > >>> info > >>> ==9291== Command: ./a.out > >>> ==9291== > >>> valgrind MPI wrappers 9290: Active for pid 9290 > >>> valgrind MPI wrappers 9291: Active for pid 9291 > >>> valgrind MPI wrappers 9290: Try MPIWRAP_DEBUG=help for possible options > >>> valgrind MPI wrappers 9291: Try MPIWRAP_DEBUG=help for possible options > >>> Stringlength = 6 > >>> ==9291== Invalid read of size 1 > >>> ==9291== at 0x4C2DBA2: strlen (in > >>> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) > >>> ==9291== by 0x56852D8: length (char_traits.h:267) > >>> ==9291== 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) > >>> ==9291== by 0x408A39: receive() (mpi.cpp:22) > >>> ==9291== by 0x408B61: main (mpi.cpp:46) > >>> ==9291== Address 0xffefff870 is on thread 1's stack > >>> ==9291== in frame #2, created by receive() (mpi.cpp:8) > >>> ==9291== > >>> ==9291== Invalid read of size 1 > >>> ==9291== at 0x4C2DBB4: strlen (in > >>> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) > >>> ==9291== by 0x56852D8: length (char_traits.h:267) > >>> ==9291== 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) > >>> ==9291== by 0x408A39: receive() (mpi.cpp:22) > >>> ==9291== by 0x408B61: main (mpi.cpp:46) > >>> ==9291== Address 0xffefff871 is on thread 1's stack > >>> ==9291== in frame #2, created by receive() (mpi.cpp:8) > >>> ==9291== > >>> ==9291== Invalid read of size 1 > >>> ==9291== at 0x60A0FF1: _IO_file_xsputn@@GLIBC_2.2.5 (in /usr/lib/ > >>> libc-2.23.so) > >>> ==9291== by 0x6096D1A: fwrite (in /usr/lib/libc-2.23.so) > >>> ==9291== by 0x5684F75: sputn (streambuf:451) > >>> ==9291== by 0x5684F75: __ostream_write<char, std::char_traits<char> > > >>> (ostream_insert.h:50) > >>> ==9291== 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) > >>> ==9291== 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) > >>> ==9291== by 0x408A39: receive() (mpi.cpp:22) > >>> ==9291== by 0x408B61: main (mpi.cpp:46) > >>> ==9291== Address 0xffefff874 is on thread 1's stack > >>> ==9291== in frame #4, created by receive() (mpi.cpp:8) > >>> ==9291== > >>> ==9291== Invalid read of size 1 > >>> ==9291== at 0x60A100D: _IO_file_xsputn@@GLIBC_2.2.5 (in /usr/lib/ > >>> libc-2.23.so) > >>> ==9291== by 0x6096D1A: fwrite (in /usr/lib/libc-2.23.so) > >>> ==9291== by 0x5684F75: sputn (streambuf:451) > >>> ==9291== by 0x5684F75: __ostream_write<char, std::char_traits<char> > > >>> (ostream_insert.h:50) > >>> ==9291== 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) > >>> ==9291== 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) > >>> ==9291== by 0x408A39: receive() (mpi.cpp:22) > >>> ==9291== by 0x408B61: main (mpi.cpp:46) > >>> ==9291== Address 0xffefff873 is on thread 1's stack > >>> ==9291== in frame #4, created by receive() (mpi.cpp:8) > >>> ==9291== > >>> ==9291== Invalid read of size 2 > >>> ==9291== at 0x4C2F9C0: __GI_memcpy (in > >>> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) > >>> ==9291== by 0x60A0F3A: _IO_file_xsputn@@GLIBC_2.2.5 (in /usr/lib/ > >>> libc-2.23.so) > >>> ==9291== by 0x6096D1A: fwrite (in /usr/lib/libc-2.23.so) > >>> ==9291== by 0x5684F75: sputn (streambuf:451) > >>> ==9291== by 0x5684F75: __ostream_write<char, std::char_traits<char> > > >>> (ostream_insert.h:50) > >>> ==9291== 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) > >>> ==9291== 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) > >>> ==9291== by 0x408A39: receive() (mpi.cpp:22) > >>> ==9291== by 0x408B61: main (mpi.cpp:46) > >>> ==9291== Address 0xffefff870 is on thread 1's stack > >>> ==9291== in frame #5, created by receive() (mpi.cpp:8) > >>> ==9291== > >>> ==9291== Invalid read of size 1 > >>> ==9291== at 0x4C2F9F8: __GI_memcpy (in > >>> /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) > >>> ==9291== by 0x60A0F3A: _IO_file_xsputn@@GLIBC_2.2.5 (in /usr/lib/ > >>> libc-2.23.so) > >>> ==9291== by 0x6096D1A: fwrite (in /usr/lib/libc-2.23.so) > >>> ==9291== by 0x5684F75: sputn (streambuf:451) > >>> ==9291== by 0x5684F75: __ostream_write<char, std::char_traits<char> > > >>> (ostream_insert.h:50) > >>> ==9291== 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) > >>> ==9291== 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) > >>> ==9291== by 0x408A39: receive() (mpi.cpp:22) > >>> ==9291== by 0x408B61: main (mpi.cpp:46) > >>> ==9291== Address 0xffefff874 is on thread 1's stack > >>> ==9291== in frame #5, created by receive() (mpi.cpp:8) > >>> ==9291== > >>> Hallo > >>> ==9291== > >>> ==9291== HEAP SUMMARY: > >>> ==9291== in use at exit: 96,351 bytes in 247 blocks > >>> ==9291== total heap usage: 15,020 allocs, 14,773 frees, 13,362,383 bytes > >>> allocated > >>> ==9291== > >>> ==9291== LEAK SUMMARY: > >>> ==9291== definitely lost: 9,154 bytes in 39 blocks > >>> ==9291== indirectly lost: 4,008 bytes in 22 blocks > >>> ==9291== possibly lost: 0 bytes in 0 blocks > >>> ==9291== still reachable: 83,189 bytes in 186 blocks > >>> ==9291== suppressed: 0 bytes in 0 blocks > >>> ==9291== Rerun with --leak-check=full to see details of leaked memory > >>> ==9291== > >>> ==9291== For counts of detected and suppressed errors, rerun with: -v > >>> ==9291== ERROR SUMMARY: 14 errors from 6 contexts (suppressed: 0 from 0) > >>> ==9290== > >>> ==9290== HEAP SUMMARY: > >>> ==9290== in use at exit: 96,351 bytes in 247 blocks > >>> ==9290== total heap usage: 15,018 allocs, 14,771 frees, 13,370,045 bytes > >>> allocated > >>> ==9290== > >>> ==9290== LEAK SUMMARY: > >>> ==9290== definitely lost: 9,154 bytes in 39 blocks > >>> ==9290== indirectly lost: 4,008 bytes in 22 blocks > >>> ==9290== possibly lost: 0 bytes in 0 blocks > >>> ==9290== still reachable: 83,189 bytes in 186 blocks > >>> ==9290== suppressed: 0 bytes in 0 blocks > >>> ==9290== Rerun with --leak-check=full to see details of leaked memory > >>> ==9290== > >>> ==9290== For counts of detected and suppressed errors, rerun with: -v > >>> ==9290== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 0 from 0) > >>> > >>> _______________________________________________ > >>> users mailing list > >>> us...@open-mpi.org <javascript:;> > >>> Subscription: http://www.open-mpi.org/mailman/listinfo.cgi/users > >>> Link to this post: > >>> http://www.open-mpi.org/community/lists/users/2016/03/28617.php > >>> > >> > > > > _______________________________________________ > > users mailing list > > us...@open-mpi.org > > Subscription: http://www.open-mpi.org/mailman/listinfo.cgi/users > > Link to this post: > > http://www.open-mpi.org/community/lists/users/2016/03/28619.php > > >