Skip to content

4.1.x ERROR field of MPI_Status uninitialized after MPI_Recv call #12049

@blattms

Description

@blattms

Background information

What version of Open MPI are you using?

The issue is there in versions 4.1.6 (Debian sid) and 4.1.4 (Debian bookworm), but not on 4.1.0 (Debian oldstable/bullseye).

Describe how Open MPI was installed (e.g., from a source/distribution tarball, from a git clone, from an operating system distribution package, etc.)

openmpi is installed from packages either on Debian sid or Debian 12.2

Please describe the system on which you are running

  • Operating system/version: Debian GNU/Linux 12.2 and sid
  • Computer hardware: amd64
  • Network type: only one node without network

Details of the problem

If I compile the following test file with debugging

#include <stdio.h>
#include <stdlib.h>
#include <mpi.h>
 
/**
 * @brief Display information contained in the MPI_Status.
 **/
int main(int argc, char* argv[])
{
    MPI_Init(&argc, &argv);
 
    int my_rank;
    MPI_Comm_rank(MPI_COMM_WORLD, &my_rank);
 
    if(my_rank == 0)
    {
        // The "master" MPI process issues the MPI_Bsend.
        int buffer_sent = 12345;
        int tag = 67890;
        printf("MPI process %d sends value %d with tag %d.\n", my_rank, buffer_sent, tag);
        MPI_Ssend(&buffer_sent, 1, MPI_INT, 1, tag, MPI_COMM_WORLD);
    }
    else
    {
        // The "slave" MPI process receives the message.
        int buffer_received;
        MPI_Status status;
        MPI_Recv(&buffer_received, 1, MPI_INT, MPI_ANY_SOURCE, MPI_ANY_TAG, MPI_COMM_WORLD, &status);
	if(status.MPI_ERROR)
          printf("MPI process %d received value %d from rank %d, with tag %d and error code %d.\n", 
               my_rank,
               buffer_received,
               status.MPI_SOURCE,
               status.MPI_TAG,
               status.MPI_ERROR);
    }
 
    MPI_Finalize();
 
    return EXIT_SUCCESS;
}

using

shell$ mpicc -o tester -g -O0 mpi_test.c

and run under valgrind using:

shell$ mpirun -np 2 valgrind --suppressions=/usr/share/openmpi/openmpi-valgrind.supp ./tester

Then valgrind shows that the ERROR field is not initialized during the if(status.MPI_ERROR):

MPI process 0 sends value 12345 with tag 67890.
==38889== Thread 1:
==38889== Conditional jump or move depends on uninitialised value(s)
==38889==    at 0x10925D: main (mpi_test.c:29)
==38889== 

Shouldn't MPI_Recv initialize the MPI_Status field completely? We have asserts like assert(!status.MPI_ERROR); that are failing because of this. The workaround is to always default initialize the status field

MPI_Status status = {};

Is this intended or are we doing something wrong?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions