Jed Brown wrote: > On Sun, 07 Feb 2010 22:40:55 -0500, Prentice Bisbal <prent...@ias.edu> wrote: >> Hello, everyone. I'm having trouble packing/unpacking this structure: >> >> typedef struct{ >> int index; >> int* coords; >> }point; >> >> The size of the coords array is not known a priori, so it needs to be a >> dynamic array. I'm trying to send it from one node to another using >> MPI_Pack/MPI_Unpack as shown below. When I unpack it, I get this error >> when unpacking the coords array: >> >> [fatboy:07360] *** Process received signal *** >> [fatboy:07360] Signal: Segmentation fault (11) >> [fatboy:07360] Signal code: Address not mapped (1) >> [fatboy:07360] Failing at address: (nil) > > Looks like b_point.coords = NULL. Has this been allocated on rank=1?
Yep, that was the problem. I left that out. I can't believe I overlooked something so obvious. Thanks for the code review. Thanks to Brian Austin, too, who also found that mistake. > > You might need to use MPI_Get_count to decide how much to allocate. > Also, if you don't have a convenient upper bound on the size of the > receive buffer, you can use MPI_Probe followed by MPI_Get_count to > determine this before calling MPI_Recv. Thanks for the tip. I'll take a look at those functions. -- Prentice