Open Piccions opened 2 years ago
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(); }
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.