Open MPI logo

Open MPI User's Mailing List Archives

  |   Home   |   Support   |   FAQ   |   all Open MPI User's mailing list

Subject: [OMPI users] freeing attributes on communicators
From: Robert Latham (robl_at_[hidden])
Date: 2009-03-12 12:43:42


Hello all.

I'm using openmpi-1.3 in this example, linux, gcc-4.3.2, configured
with nothing special.

If I run the following simple C code under valgrind, single process, I
get some errors about reading and writing already-freed memory:

---------------------------
#include <mpi.h>
#include <stdlib.h>

int delete_fn(MPI_Comm comm, int keyval, void *attr, void *extra) {
        MPI_Keyval_free(&keyval);
        return 0;
}

int main (int argc, char **argv)
{
        MPI_Comm duped;
        int keyval;
        MPI_Init(&argc, &argv);
        MPI_Comm_dup(MPI_COMM_SELF, &duped);

        MPI_Keyval_create(MPI_NULL_COPY_FN, delete_fn, &keyval, NULL);

        MPI_Attr_put(MPI_COMM_SELF, keyval, NULL);
        MPI_Attr_put(duped, keyval, NULL);

        MPI_Comm_free(&duped);
        MPI_Finalize();
        return 0;
}
---------------------------

My main question here: Am I doing something wrong, or have I managed
to confuse openmpi's reference counts somehow?

==rob

-- 
Rob Latham
Mathematics and Computer Science Division    A215 0178 EA2D B059 8CDF
Argonne National Lab, IL USA                 B29D F333 664A 4280 315B