[petsc-dev] [petsc-checkbuilds] PETSc blame digest (next) 2016-04-08

Satish Balay balay at mcs.anl.gov
Tue Apr 12 22:42:26 CDT 2016


Ok - I see the bug in this code.

static PetscErrorCode DMPlexReferenceTreeRestoreChildrenMatrices_Injection(DM refTree, Mat inj, PetscScalar ****childrenMats)

Since this funciton is defined as 'static' the compiler is doing
'inter procedure analysis' across the calling function with -O [this
warning comes up only with -O build]

1. plextree.c:3506 has the following variable declared [uninitialized]
  PetscScalar    ***childrenMats;

2. the next usage of this variable is: plextree.c:3846
  ierr = DMPlexReferenceTreeGetChildrenMatrices_Injection(refTree,injRef,&childrenMats);CHKERRQ(ierr);

3. Within this function - the first usage of this variable is plextree.c:L3453
  refPointFieldMats = *childrenMats;

i.e access/use of uninitialized variable.

The following supresses the warning - but there is clearly some lurking bug..

diff --git a/src/dm/impls/plex/plextree.c b/src/dm/impls/plex/plextree.c
index 2ee02d0..e51f704 100644
--- a/src/dm/impls/plex/plextree.c
+++ b/src/dm/impls/plex/plextree.c
@@ -3503,7 +3503,7 @@ PetscErrorCode DMPlexComputeInjectorTree(DM coarse, DM fine, PetscSF coarseToFin
   PetscLayout    rowMap, colMap;
   PetscInt       rowStart, rowEnd, colStart, colEnd, *nnzD, *nnzO;
   PetscObject    injRefObj;
-  PetscScalar    ***childrenMats;
+  PetscScalar    ***childrenMats=0;
   PetscErrorCode ierr;
 
   PetscFunctionBegin;

And this was introduced by http://bitbucket.org/petsc/petsc/commits/f30e825d

Satish

On Fri, 8 Apr 2016, Barry Smith wrote:

> 
>   Toby,
> 
>    We'll be filtering out these false positives. It is just taking us a couple of days to determine that needs to be filtered.
> 
>   Barry
> 
> > On Apr 8, 2016, at 2:36 PM, Tobin Isaac <tisaac at uchicago.edu> wrote:
> > 
> > 
> > I spent a couple minutes verifying that there is no code path where
> > that variable is not initialized on line 3437.
> > 
> > -Wmaybe-uninitialized seems to generate a lot of false positives.
> > Coupled with the blame digest's poor ability to assign blame, this
> > proactive approach seems to waste more time than a reactive
> > SEGV->valgrind->fix approach.
> > 
> > Cheers,
> >  Toby
> > 
> > On Fri, Apr 08, 2016 at 02:12:22PM -0500, Satish Balay wrote:
> >> This should have been sent to Toby.
> >> 
> >> I don't really understand the issue here. Its triggered by --with-debugging=0. I'm
> >> not sure why these compilers are pointing to petscsys.h. I get slightly different message
> >> on my laptop.
> >> 
> >> mpicc -c -fPIC  -Wall -Wwrite-strings -Wno-strict-aliasing -Wno-unknown-pragmas -fvisibility=hidden -g -O   -I/home/balay/petsc/include -I/home/balay/petsc/arch-linux2-c-opt/include -I/home/balay/soft/mpich-3.1.4/include    -MMD -MP /home/balay/petsc/src/dm/impls/plex/plextree.c -o arch-linux2-c-opt/obj/src/dm/impls/plex/plextree.o
> >> /home/balay/petsc/src/dm/impls/plex/plextree.c: In function ‘DMPlexComputeInjectorTree’:
> >> /home/balay/petsc/src/dm/impls/plex/plextree.c:3484:11: warning: ‘childrenMats’ may be used uninitialized in this function [-Wmaybe-uninitialized]
> >>   ierr = PetscFree(refPointFieldMats);CHKERRQ(ierr);
> >>           ^
> >> /home/balay/petsc/src/dm/impls/plex/plextree.c:3507:18: note: ‘childrenMats’ was declared here
> >>   PetscScalar    ***childrenMats;
> >>                  ^
> >> 
> >> Satish
> >> 
> >> On Fri, 8 Apr 2016, PETSc checkBuilds wrote:
> >> 
> >>> 
> >>> 
> >>> Dear PETSc developer,
> >>> 
> >>> This email contains listings of contributions attributed to you by
> >>> `git blame` that caused compiler errors or warnings in PETSc automated
> >>> testing.  Follow the links to see the full log files. Please attempt to fix
> >>> the issues promptly or let us know at petsc-dev at mcs.anl.gov if you are unable
> >>> to resolve the issues.
> >>> 
> >>> Thanks,
> >>>  The PETSc development team
> >>> 
> >>> ----
> >>> 
> >>> warnings attributed to commit https://bitbucket.org/petsc/petsc/commits/49d7da5
> >>> PetscMalloc: allow ptr=malloc(0) and free(ptr)
> >>> 
> >>>  include/petscsys.h:1157
> >>>    [http://ftp.mcs.anl.gov/pub/petsc/nightlylogs/archive/2016/04/08/build_next_arch-freebsd-cxx-pkgs-opt_wii.log]
> >>>      /usr/home/balay/petsc.clone-2/include/petscsys.h:1157:88: warning: 'childrenMats' may be used uninitialized in this function [-Wmaybe-uninitialized]
> >>>    [http://ftp.mcs.anl.gov/pub/petsc/nightlylogs/archive/2016/04/08/build_next_arch-linux-opt-cxx-quad_grind.log]
> >>>      /sandbox/petsc/petsc.clone-3/include/petscsys.h:1157:88: warning: 'childrenMats' may be used uninitialized in this function [-Wmaybe-uninitialized]
> >>>    [http://ftp.mcs.anl.gov/pub/petsc/nightlylogs/archive/2016/04/08/build_next_arch-freebsd-pkgs-opt_wii.log]
> >>>      /usr/home/balay/petsc.clone/include/petscsys.h:1157:39: warning: 'childrenMats' may be used uninitialized in this function [-Wmaybe-uninitialized]
> >>>    [http://ftp.mcs.anl.gov/pub/petsc/nightlylogs/archive/2016/04/08/build_next_arch-linux-pkgs-latest_cg.log]
> >>>      /sandbox/petsc/petsc.clone-4/include/petscsys.h:1157:25: warning: 'childrenMats' may be used uninitialized in this function [-Wmaybe-uninitialized]
> >>>    [http://ftp.mcs.anl.gov/pub/petsc/nightlylogs/archive/2016/04/08/build_next_arch-linux-pkgs-opt_crank.log]
> >>>      /sandbox/petsc/petsc.clone/include/petscsys.h:1157:25: warning: 'childrenMats' may be used uninitialized in this function [-Wmaybe-uninitialized]
> >>> 
> >>> ----
> >>> To opt-out from receiving these messages - send a request to petsc-dev at mcs.anl.gov.
> >>> 
> > 
> 
> 


More information about the petsc-dev mailing list