X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/5b709bba3e8d25836dd1808aab2b3ef414f8329e..839ca861fcbfe4230637ffc30766445cc7b4918f:/teshsuite/smpi/mpich3-test/attr/keyval_double_free_type.c diff --git a/teshsuite/smpi/mpich3-test/attr/keyval_double_free_type.c b/teshsuite/smpi/mpich3-test/attr/keyval_double_free_type.c new file mode 100644 index 0000000000..406d7e82a1 --- /dev/null +++ b/teshsuite/smpi/mpich3-test/attr/keyval_double_free_type.c @@ -0,0 +1,45 @@ +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */ +/* + * + * (C) 2015 by Argonne National Laboratory. + * See COPYRIGHT in top-level directory. + */ +#include +#include +#include +#include "mpitest.h" + +/* tests multiple invocations of MPI_Type_free_keyval on the same keyval */ + +int delete_fn(MPI_Comm comm, int keyval, void *attr, void *extra); +int delete_fn(MPI_Comm comm, int keyval, void *attr, void *extra) +{ + MPI_Type_free_keyval(&keyval); + return MPI_SUCCESS; +} + +int main(int argc, char **argv) +{ + MPI_Datatype type; + MPI_Datatype type_dup; + int keyval = MPI_KEYVAL_INVALID; + int keyval_copy = MPI_KEYVAL_INVALID; + int errs = 0; + + MTest_Init(&argc, &argv); + MPI_Type_dup(MPI_INT, &type); + MPI_Type_dup(MPI_INT, &type_dup); + + MPI_Type_create_keyval(MPI_NULL_COPY_FN, delete_fn, &keyval, NULL); + keyval_copy = keyval; + MPI_Type_set_attr(type, keyval, NULL); + MPI_Type_set_attr(type_dup, keyval, NULL); + + MPI_Type_free(&type); /* first MPI_Type_free_keyval */ + MPI_Type_free_keyval(&keyval); /* second MPI_Type_free_keyval */ + MPI_Type_free_keyval(&keyval_copy); /* third MPI_Type_free_keyval */ + MPI_Type_free(&type_dup); /* fourth MPI_Type_free_keyval */ + MTest_Finalize(errs); + MPI_Finalize(); + return 0; +}