[petsc-dev] clang --analyze messages on PETSc

Matthew Knepley knepley at gmail.com
Mon Apr 13 18:46:42 CDT 2015


On Mon, Apr 13, 2015 at 5:48 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:

>
> When I run clang --analyze on PETSc on getting warnings of the type below,
> any idea how to deal with them? Clearly these things are usually not null
> pointers or PETSc would crash everywhere.
>

Lisandro brought this up.

This is a problem with the analyzer. Anything that uses PetscMallocK() will
be wrong since it can
possibly be NULL. The limitations of static analysis are stark.

   Matt


>    Thanks
>
>   Barry
>
>
> 12 warnings generated.
>           CC arch-debug/obj/src/mat/impls/aij/seq/bas/basfactor.o
>           CC arch-debug/obj/src/mat/impls/aij/seq/bas/spbas.o
> /Users/barrysmith/Src/PETSc/src/mat/impls/aij/seq/bas/basfactor.c:33:11:
> warning: Array access (from variable 'ui') results in a null pointer
> dereference
>     ui[0] = 0;
>     ~~    ^
> /Users/barrysmith/Src/PETSc/src/mat/impls/aij/seq/bas/basfactor.c:43:39:
> warning: Dereference of null pointer
>       for (j=0; j<ncols; j++) *cols++ = *aj++;
>                               ~~~~~~~~^~~~~~~
> 2 warnings generated.
>           CC arch-debug/obj/src/mat/impls/aij/seq/csrperm/csrperm.o
> /Users/barrysmith/Src/PETSc/src/mat/impls/aij/seq/csrperm/csrperm.c:190:23:
> warning: Array access (from variable 'rows_in_bucket') results in a null
> pointer dereference
>     rows_in_bucket[i] = 0;
>     ~~~~~~~~~~~~~~    ^
> /Users/barrysmith/Src/PETSc/src/mat/impls/aij/seq/csrperm/csrperm.c:194:5:
> warning: Array access (from variable 'rows_in_bucket') results in a null
> pointer dereference
>     rows_in_bucket[nz]++;
>     ^~~~~~~~~~~~~~~~~~~~
> /Users/barrysmith/Src/PETSc/src/mat/impls/aij/seq/csrperm/csrperm.c:221:27:
> warning: Array access (via field 'xgroup') results in a null pointer
> dereference
>   aijperm->xgroup[ngroup] = istart;
>            ~~~~~~         ^
> 3 warnings generated.
>           CC arch-debug/obj/src/mat/impls/aij/seq/ftn-auto/aijf.o
>           CC arch-debug/obj/src/mat/impls/aij/seq/crl/crl.o
> /Users/barrysmith/Src/PETSc/src/mat/impls/aij/seq/crl/crl.c:62:20:
> warning: Array access (from variable 'acols') results in a null pointer
> dereference
>       acols[j*m+i] = *aa++;
>       ~~~~~        ^
> /Users/barrysmith/Src/PETSc/src/mat/impls/aij/seq/crl/crl.c:63:20:
> warning: Array access (from variable 'icols') results in a null pointer
> dereference
>       icols[j*m+i] = *aj++;
>       ~~~~~        ^
> /Users/barrysmith/Src/PETSc/src/mat/impls/aij/seq/crl/crl.c:66:20:
> warning: Array access (from variable 'acols') results in a null pointer
> dereference
>       acols[j*m+i] = 0.0;
>
>
>


-- 
What most experimenters take for granted before they begin their
experiments is infinitely more interesting than any results to which their
experiments lead.
-- Norbert Wiener
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.mcs.anl.gov/pipermail/petsc-dev/attachments/20150413/a97849f4/attachment.html>


More information about the petsc-dev mailing list