[petsc-dev] Invalid read in PetscSubcommSetTypeGeneral

Hong Zhang hzhang at mcs.anl.gov
Thu Oct 3 11:05:52 CDT 2013


Stefano,
The bug is fixed and merged to the next branch for regression tests
https://bitbucket.org/petsc/petsc/commits/9972d2cea69f576862c8d7ac556aa3a0a50ab130
Once it passes all the tests tomorrow, I'll merge it to master.

Thanks for your contribution!

Hong


On Wed, Oct 2, 2013 at 10:40 AM, Stefano Zampini <s.zampini at cineca.it>wrote:

> Is it the right solution?
>
> diff --git a/src/sys/objects/subcomm.c b/src/sys/objects/subcomm.c
> index 752550d..17ef49b 100644
> --- a/src/sys/objects/subcomm.c
> +++ b/src/sys/objects/subcomm.c
> @@ -186,7 +186,7 @@ PetscErrorCode PetscSubcommSetTypeGeneral(PetscSubcomm
> psubcomm,PetscMPIInt colo
>    ierr =
> MPI_Allgather(sendbuf,2,MPI_INT,recvbuf,2,MPI_INT,comm);CHKERRQ(ierr);
>
>    ierr = PetscMalloc(nsubcomm*sizeof(PetscMPIInt),&subsize);CHKERRQ(ierr);
> -  for (i=0; i<2*size; i++) {
> +  for (i=0; i<2*size; i+=2) {
>
>      subsize[recvbuf[i]] = recvbuf[i+1];
>    }
>    ierr = PetscFree(recvbuf);CHKERRQ(ierr);
>
>
>
> 2013/10/2 Stefano Zampini <s.zampini at cineca.it>
>
>> Hong,
>>
>> currently in master there's an error in PetscSubcommSetTypeGeneral,
>> namely in the loop starting at line 188
>>
>> for (i=0; i<2*size; i++) {    subsize[recvbuf[i]] = recvbuf[i+1];}
>>
>> recvbuf is allocated at line 178 as 2*size*sizeof(PetscMPIInt), and the
>> loop tries to read at location 2*size
>>
>> Could you please fix it?
>>
>>
>>
>> --
>>
>> Ph. D. Stefano Zampini
>> CINECA
>> SuperComputing Applications and Innovations Department - SCAI
>> Via dei Tizii, 6 00185 Roma - ITALY
>> ------------------------------------------------------------------------------------------------------------------------
>> Email: s.zampini at cineca.it
>> SkypeID: stefano.zampini
>> GoogleTalk: stefano.zampini at gmail.com
>> Tel: +39 06.44486.707
>> ------------------------------------------------------------------------------------------------------------------------
>>
>>
>
>
> --
>
> Ph. D. Stefano Zampini
> CINECA
> SuperComputing Applications and Innovations Department - SCAI
> Via dei Tizii, 6 00185 Roma - ITALY
> ------------------------------------------------------------------------------------------------------------------------
> Email: s.zampini at cineca.it
> SkypeID: stefano.zampini
> GoogleTalk: stefano.zampini at gmail.com
> Tel: +39 06.44486.707
> ------------------------------------------------------------------------------------------------------------------------
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20131003/82b220d1/attachment.html>


More information about the petsc-dev mailing list