Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MPI_Isend() may send wrong data if its request has been freed #62

Open
Piccions opened this issue Aug 7, 2022 · 0 comments
Open

MPI_Isend() may send wrong data if its request has been freed #62

Piccions opened this issue Aug 7, 2022 · 0 comments

Comments

@Piccions
Copy link

Piccions commented Aug 7, 2022

Freeing a request for an immediate send causes subsequent sends to reuse the same buffer even if the previous operation hasn't completed, leading to erroneous data being sent.
I include a reproducer program that induces the bug.

#include <assert.h>
#include <mpi.h>

#define TRIGGER_BUG

int main(void)
{
	int thread_lvl = MPI_THREAD_SINGLE;
	MPI_Init_thread(NULL, NULL, MPI_THREAD_MULTIPLE, &thread_lvl);
	assert(thread_lvl >= MPI_THREAD_MULTIPLE);

	static const int one = 1;
	MPI_Request req_one;
	MPI_Isend(&one, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &req_one);
#ifdef TRIGGER_BUG
	MPI_Request_free(&req_one);
#endif

	static const int six = 6;
	MPI_Request req_six;
	MPI_Isend(&six, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, &req_six);
#ifndef TRIGGER_BUG
	MPI_Request_free(&req_one);
#endif
	MPI_Request_free(&req_six);

	int recv_first = 0;
	MPI_Recv(&recv_first, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);

	int recv_second = 0;
	MPI_Recv(&recv_second, 1, MPI_INT, 0, 0, MPI_COMM_WORLD, MPI_STATUS_IGNORE);

	assert(recv_first + recv_second == 7);

	MPI_Finalize();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant