[petsc-dev] another hypre memory corruption problem
Barry Smith
bsmith at mcs.anl.gov
Tue Sep 8 18:12:01 CDT 2015
petsc at crank:/sandbox/petsc/petsc.test/src/ksp/ksp/examples/tutorials$ /sandbox/petsc/petsc.test/bin/petscmpiexec -valgrind -n 3 ./ex10 -pc_type hypre -pc_hypre_type parasails -f0 ${DATAFILESPATH}/matrices/medium
==12918== Use of uninitialised value of size 8
==12918== at 0x5C2CDD1: DiagScaleCreate (DiagScale.c:129)
==12918== by 0x5BB8733: ParaSailsSetupPattern (ParaSails.c:1678)
==12918== by 0x5BB4D9E: hypre_ParaSailsSetup (hypre_ParaSails.c:227)
==12918== by 0x5AD9357: HYPRE_ParaSailsSetup (HYPRE_parcsr_ParaSails.c:372)
==12918== by 0x56A3ECC: PCSetUp_HYPRE (hypre.c:208)
==12918== by 0x559714A: PCSetUp (precon.c:984)
==12918== by 0x56AEEC7: KSPSetUp (itfunc.c:332)
==12918== by 0x40525E: main (ex10.c:312)
==12918== Uninitialised value was created by a heap allocation
==12918== at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==12918== by 0x5BB6D32: MemAlloc (Mem.c:108)
==12918== by 0x5C2CD69: DiagScaleCreate (DiagScale.c:120)
==12918== by 0x5BB8733: ParaSailsSetupPattern (ParaSails.c:1678)
==12918== by 0x5BB4D9E: hypre_ParaSailsSetup (hypre_ParaSails.c:227)
==12918== by 0x5AD9357: HYPRE_ParaSailsSetup (HYPRE_parcsr_ParaSails.c:372)
==12918== by 0x56A3ECC: PCSetUp_HYPRE (hypre.c:208)
==12918== by 0x559714A: PCSetUp (precon.c:984)
==12918== by 0x56AEEC7: KSPSetUp (itfunc.c:332)
==12918== by 0x40525E: main (ex10.c:312)
==12918==
==12924== Conditional jump or move depends on uninitialised value(s)
==12924== at 0x5BBB160: PrunedRowsCreate (PrunedRows.c:71)
==12924== by 0x5BB8791: ParaSailsSetupPattern (ParaSails.c:1683)
==12924== by 0x5BB4D9E: hypre_ParaSailsSetup (hypre_ParaSails.c:227)
==12924== by 0x5AD9357: HYPRE_ParaSailsSetup (HYPRE_parcsr_ParaSails.c:372)
==12924== by 0x56A3ECC: PCSetUp_HYPRE (hypre.c:208)
==12924== by 0x559714A: PCSetUp (precon.c:984)
==12924== by 0x56AEEC7: KSPSetUp (itfunc.c:332)
==12924== by 0x40525E: main (ex10.c:312)
==12924== Uninitialised value was created by a heap allocation
==12924== at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==12924== by 0x5C2CACD: DiagScaleCreate (DiagScale.c:190)
==12924== by 0x5BB8733: ParaSailsSetupPattern (ParaSails.c:1678)
==12924== by 0x5BB4D9E: hypre_ParaSailsSetup (hypre_ParaSails.c:227)
==12924== by 0x5AD9357: HYPRE_ParaSailsSetup (HYPRE_parcsr_ParaSails.c:372)
==12924== by 0x56A3ECC: PCSetUp_HYPRE (hypre.c:208)
==12924== by 0x559714A: PCSetUp (precon.c:984)
==12924== by 0x56AEEC7: KSPSetUp (itfunc.c:332)
==12924== by 0x40525E: main (ex10.c:312)
==12924==
==12924== Conditional jump or move depends on uninitialised value(s)
==12924== at 0x5BBB219: PrunedRowsCreate (PrunedRows.c:84)
==12924== by 0x5BB8791: ParaSailsSetupPattern (ParaSails.c:1683)
==12924== by 0x5BB4D9E: hypre_ParaSailsSetup (hypre_ParaSails.c:227)
==12924== by 0x5AD9357: HYPRE_ParaSailsSetup (HYPRE_parcsr_ParaSails.c:372)
==12924== by 0x56A3ECC: PCSetUp_HYPRE (hypre.c:208)
==12924== by 0x559714A: PCSetUp (precon.c:984)
==12924== by 0x56AEEC7: KSPSetUp (itfunc.c:332)
==12924== by 0x40525E: main (ex10.c:312)
==12924== Uninitialised value was created by a heap allocation
==12924== at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==12924== by 0x5C2CACD: DiagScaleCreate (DiagScale.c:190)
==12924== by 0x5BB8733: ParaSailsSetupPattern (ParaSails.c:1678)
==12924== by 0x5BB4D9E: hypre_ParaSailsSetup (hypre_ParaSails.c:227)
==12924== by 0x5AD9357: HYPRE_ParaSailsSetup (HYPRE_parcsr_ParaSails.c:372)
==12924== by 0x56A3ECC: PCSetUp_HYPRE (hypre.c:208)
==12924== by 0x559714A: PCSetUp (precon.c:984)
==12924== by 0x56AEEC7: KSPSetUp (itfunc.c:332)
==12924== by 0x40525E: main (ex10.c:312)
==12924==
==12917== Conditional jump or move depends on uninitialised value(s)
==12917== at 0x5BBB160: PrunedRowsCreate (PrunedRows.c:71)
==12917== by 0x5BB8791: ParaSailsSetupPattern (ParaSails.c:1683)
==12917== by 0x5BB4D9E: hypre_ParaSailsSetup (hypre_ParaSails.c:227)
==12917== by 0x5AD9357: HYPRE_ParaSailsSetup (HYPRE_parcsr_ParaSails.c:372)
==12917== by 0x56A3ECC: PCSetUp_HYPRE (hypre.c:208)
==12917== by 0x559714A: PCSetUp (precon.c:984)
==12917== by 0x56AEEC7: KSPSetUp (itfunc.c:332)
==12917== by 0x40525E: main (ex10.c:312)
==12917== Uninitialised value was created by a heap allocation
==12917== at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==12917== by 0x5C2CACD: DiagScaleCreate (DiagScale.c:190)
==12917== by 0x5BB8733: ParaSailsSetupPattern (ParaSails.c:1678)
==12917== by 0x5BB4D9E: hypre_ParaSailsSetup (hypre_ParaSails.c:227)
==12917== by 0x5AD9357: HYPRE_ParaSailsSetup (HYPRE_parcsr_ParaSails.c:372)
==12917== by 0x56A3ECC: PCSetUp_HYPRE (hypre.c:208)
==12917== by 0x559714A: PCSetUp (precon.c:984)
==12917== by 0x56AEEC7: KSPSetUp (itfunc.c:332)
==12917== by 0x40525E: main (ex10.c:312)
==12917==
==12917== Conditional jump or move depends on uninitialised value(s)
==12917== at 0x5BBB219: PrunedRowsCreate (PrunedRows.c:84)
==12917== by 0x5BB8791: ParaSailsSetupPattern (ParaSails.c:1683)
==12917== by 0x5BB4D9E: hypre_ParaSailsSetup (hypre_ParaSails.c:227)
==12917== by 0x5AD9357: HYPRE_ParaSailsSetup (HYPRE_parcsr_ParaSails.c:372)
==12917== by 0x56A3ECC: PCSetUp_HYPRE (hypre.c:208)
==12917== by 0x559714A: PCSetUp (precon.c:984)
==12917== by 0x56AEEC7: KSPSetUp (itfunc.c:332)
==12917== by 0x40525E: main (ex10.c:312)
==12917== Uninitialised value was created by a heap allocation
==12917== at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==12917== by 0x5C2CACD: DiagScaleCreate (DiagScale.c:190)
==12917== by 0x5BB8733: ParaSailsSetupPattern (ParaSails.c:1678)
==12917== by 0x5BB4D9E: hypre_ParaSailsSetup (hypre_ParaSails.c:227)
==12917== by 0x5AD9357: HYPRE_ParaSailsSetup (HYPRE_parcsr_ParaSails.c:372)
==12917== by 0x56A3ECC: PCSetUp_HYPRE (hypre.c:208)
==12917== by 0x559714A: PCSetUp (precon.c:984)
==12917== by 0x56AEEC7: KSPSetUp (itfunc.c:332)
==12917== by 0x40525E: main (ex10.c:312)
==12917==
==12917== Use of uninitialised value of size 8
==12917== at 0x5C2CDD1: DiagScaleCreate (DiagScale.c:129)
==12917== by 0x5BBA287: ParaSailsSetupValues (ParaSails.c:1844)
==12917== by 0x5BB4E1C: hypre_ParaSailsSetup (hypre_ParaSails.c:234)
==12917== by 0x5AD9357: HYPRE_ParaSailsSetup (HYPRE_parcsr_ParaSails.c:372)
==12917== by 0x56A3ECC: PCSetUp_HYPRE (hypre.c:208)
==12917== by 0x559714A: PCSetUp (precon.c:984)
==12917== by 0x56AEEC7: KSPSetUp (itfunc.c:332)
==12917== by 0x40525E: main (ex10.c:312)
==12917== Uninitialised value was created by a heap allocation
==12917== at 0x4C2B6CD: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
==12917== by 0x5BB6D32: MemAlloc (Mem.c:108)
==12917== by 0x5C2CD69: DiagScaleCreate (DiagScale.c:120)
==12917== by 0x5BBA287: ParaSailsSetupValues (ParaSails.c:1844)
==12917== by 0x5BB4E1C: hypre_ParaSailsSetup (hypre_ParaSails.c:234)
==12917== by 0x5AD9357: HYPRE_ParaSailsSetup (HYPRE_parcsr_ParaSails.c:372)
==12917== by 0x56A3ECC: PCSetUp_HYPRE (hypre.c:208)
==12917== by 0x559714A: PCSetUp (precon.c:984)
==12917== by 0x56AEEC7: KSPSetUp (itfunc.c:332)
==12917== by 0x40525E: main (ex10.c:312)
==12917==
==12917== Invalid read of size 8
==12917== at 0x5C2CDD1: DiagScaleCreate (DiagScale.c:129)
==12917== by 0x5BBA287: ParaSailsSetupValues (ParaSails.c:1844)
==12917== by 0x5BB4E1C: hypre_ParaSailsSetup (hypre_ParaSails.c:234)
==12917== by 0x5AD9357: HYPRE_ParaSailsSetup (HYPRE_parcsr_ParaSails.c:372)
==12917== by 0x56A3ECC: PCSetUp_HYPRE (hypre.c:208)
==12917== by 0x559714A: PCSetUp (precon.c:984)
==12917== by 0x56AEEC7: KSPSetUp (itfunc.c:332)
==12917== by 0x40525E: main (ex10.c:312)
==12917== Address 0x213b27498 is not stack'd, malloc'd or (recently) free'd
==12917==
[0]PETSC ERROR: ------------------------------------------------------------------------
[0]PETSC ERROR: Caught signal number 11 SEGV: Segmentation Violation, probably memory access out of range
[0]PETSC ERROR: Try option -start_in_debugger or -on_error_attach_debugger
[0]PETSC ERROR: or see http://www.mcs.anl.gov/petsc/documentation/faq.html#valgrind
[0]PETSC ERROR: or try http://valgrind.org on GNU/linux and Apple Mac OS X to find memory corruption errors
[0]PETSC ERROR: configure using --with-debugging=yes, recompile, link, and run
[0]PETSC ERROR: to get more information on the crash.
[0]PETSC ERROR: --------------------- Error Message ------------------------------------------
Looking at the code there appears to be a problem. The routine first does a probe which gives a source and a count, you then allocate the space, but then you do a
hypre_MPI_Recv(recvbuf, count, HYPRE_MPI_INT, hypre_MPI_ANY_SOURCE, ...
but use hypre_MPI_ANY_SOURCE instead of source as the source. Thus you might get a different message (with a different length) then the probe found. I think you need to pass source instead of hypre_MPI_ANY_SOURCE here. Note that other places in the same directory where you use Probe you always use the source to receive on. When I make this change in my copy of hypre the problem goes away.
Barry
static void ExchangeDiagEntriesServer(MPI_Comm comm, Matrix *mat,
HYPRE_Real *local_diags, HYPRE_Int num_requests, Mem *mem, hypre_MPI_Request *requests)
{
hypre_MPI_Status status;
HYPRE_Int *recvbuf;
HYPRE_Real *sendbuf;
HYPRE_Int i, j, source, count;
/* recvbuf contains requested indices */
/* sendbuf contains corresponding diagonal entries */
for (i=0; i<num_requests; i++)
{
hypre_MPI_Probe(hypre_MPI_ANY_SOURCE, DIAG_INDS_TAG, comm, &status);
source = status.hypre_MPI_SOURCE;
hypre_MPI_Get_count(&status, HYPRE_MPI_INT, &count);
recvbuf = (HYPRE_Int *) MemAlloc(mem, count*sizeof(HYPRE_Int));
sendbuf = (HYPRE_Real *) MemAlloc(mem, count*sizeof(HYPRE_Real));
hypre_MPI_Recv(recvbuf, count, HYPRE_MPI_INT, hypre_MPI_ANY_SOURCE,
DIAG_INDS_TAG, comm, &status);
source = status.hypre_MPI_SOURCE;
/* Construct reply message of diagonal entries in sendbuf */
for (j=0; j<count; j++)
sendbuf[j] = local_diags[recvbuf[j] - mat->beg_row];
/* Use ready-mode send, since receives already posted */
hypre_MPI_Irsend(sendbuf, count, hypre_MPI_DOUBLE, source,
DIAG_VALS_TAG, comm, &requests[i]);
}
}
More information about the petsc-dev
mailing list