Open MPI logo

Open MPI Development Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Development mailing list

Subject: Re: [OMPI devel] MPI_Recv pre memory checks
From: Rainer Keller (keller_at_[hidden])
Date: 2009-07-07 18:07:38


Hello,
the checks inside of ompi/mpi/c/send.c and ompi/mpi/c/recv.c are checking the
user's parameters to the p2p functions (and others).
As You report, one of the checks done are checking whether the caller has
properly allocated enough memory (recv-side) and that the data to be send is
properly initialized (send-side).
The opal_memchecker_base_isaddressable test is telling valgrind-memcheck to
issue error-messages if the passed count & datatype does not match with the
allocated buffer sizes.

These checks however are unrelated to the MPI-semantics of sending more data,
then expected, or sending less data (truncation). The latter is allowed...

Whether more checks are required? Hmm, I may be wrong, but (at least for p2p)
as we're checking the definedness on the sender side, there should not be any
further need to check on the receiver side, that the communicated data has
actually been written. (at least not for end-user correctness)...

With best regards,
Rainer

On Tuesday 07 July 2009 04:35:26 pm Prasadcse Perera wrote:
> I'm new to open mpi and I'm currently studying the code and writing my own
> simple parallel test programs. I wrote a simple program to send and receive
> a character buffer using
> MPI::COMM_WORLD.Send, MPI::COMM_WORLD.Recv function calls. After playing
> with some stupid parameters I could observe the following:
> When I passed a buffer of length say 10, and set the receiving count to say
> 100, I could see that even the sending buffer (around 30 - 40) exceeds
> the receiving buffer, the characters were successfully copied. And at some
> points, after increasing these values, the receiving buffer started to
> show some garbage characters due to usage of unassigned memory. I took a
> look at the implementation and saw that opal_memchecker_base_isaddressable
> is used to check if the buffer is addressible and OMPI_WANT_MEMCHECKER is
> used as a flag too. But unfortunately I couldnt find the impl of
> opal_memchecker_base_isaddressable.
>
> So my questions is, Do we have to set OMPI_WANT_MEMCHECKER in order to
> verify the recieving buffer internally? if it is, then shouldn't it be
> always done ?
> I know its a stupid thing to burden these functions to do this since its up
> to the programmer to make the sanity checks or make sure not to feed up
> with wrong parameters, yet since it leaves to dangerous memory
> allocation/usage, doesn't it serve as a security threat ?
>
> Pardon me if I misunderstood things since I'm still learning and testing
> with these codes...
>
> Thanks,
> Prasad.

-- 
------------------------------------------------------------------------
Rainer Keller, PhD                  Tel: +1 (865) 241-6293
Oak Ridge National Lab          Fax: +1 (865) 241-4811
PO Box 2008 MS 6164           Email: keller_at_[hidden]
Oak Ridge, TN 37831-2008    AIM/Skype: rusraink