[petsc-users] valgrind error messages with PETSc V3.5.1

Barry Smith bsmith at mcs.anl.gov
Mon Aug 4 22:28:30 CDT 2014


On Aug 4, 2014, at 12:35 AM, Jed Brown <jed at jedbrown.org> wrote:

> Randall Mackie <rlmackie862 at gmail.com> writes:
> 
>> The attached small program, basically a call to PetscPrintf, gives the following valgrind errors:
>> 
>> [rmackie ~/tst_petsc_problem] ./cmd_test
>> ==24812== Invalid read of size 1
>> ==24812==    at 0x4C2E500: __GI_strncpy (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
>> ==24812==    by 0x4EF5B4D: PetscStrncpy (str.c:335)
>> ==24812==    by 0x4F334E0: petscprintf_ (zmprintf.c:54)
>> ==24812==    by 0x400F28: MAIN__ (test.F90:11)
>> ==24812==    by 0x400F9A: main (test.F90:16)
>> ==24812==  Address 0x8cef9bb is 0 bytes after a block of size 11 alloc'd
> 
> Barry, this looks like you making PetscStrncpy behave unlike strncpy.
> 
>  https://bitbucket.org/petsc/petsc/commits/ff32304b6c2c50401fe7ef46e45693a4318e17f0
> 
> I'll note that I dislike having functions named after standard C
> functions, but with different behavior (e.g., PetscStrcmp and
> PetscStrncpy).  If you really want these different semantics, I'd rather
> have different names.

   They do have different names. standard C functions do not begin with Petsc. The PETSc ones “fix” the standard ones for our needs and we document in the manual page (or should document) the differences from the standard ones. 

   Barry

> 
>> ==24812==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
>> ==24812==    by 0x6828BB4: ??? (in /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0)
>> ==24812==    by 0x68FBC97: _gfortran_string_trim (in /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0)
>> ==24812==    by 0x400EFD: MAIN__ (test.F90:11)
>> ==24812==    by 0x400F9A: main (test.F90:16)
>> ==24812== 
>> 
>> 
>> The program was compiled with PETSc V3.5.1 and --download-mpich.
>> 
>> The same program compiled with V3.4.4 and --download-mpich does not give these errors.
>> 
>> It seems like an innocuous error, and I can certainly create a suppression file for it, but I thought I'd report it anyway.
>> I get the same error on 2 different systems and I've tried 3 different gfortran versions, all with the same result.
>> 
>> Program, configure commands, etc, attached.
>> 
>> Randy M.
>> 
>> 
>> [rmackie ~/tst_petsc_problem] ./cmd_test
>> ==24812== Invalid read of size 1
>> ==24812==    at 0x4C2E500: __GI_strncpy (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
>> ==24812==    by 0x4EF5B4D: PetscStrncpy (str.c:335)
>> ==24812==    by 0x4F334E0: petscprintf_ (zmprintf.c:54)
>> ==24812==    by 0x400F28: MAIN__ (test.F90:11)
>> ==24812==    by 0x400F9A: main (test.F90:16)
>> ==24812==  Address 0x8cef9bb is 0 bytes after a block of size 11 alloc'd
>> ==24812==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
>> ==24812==    by 0x6828BB4: ??? (in /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0)
>> ==24812==    by 0x68FBC97: _gfortran_string_trim (in /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0)
>> ==24812==    by 0x400EFD: MAIN__ (test.F90:11)
>> ==24812==    by 0x400F9A: main (test.F90:16)
>> ==24812== 
>> ==24814== Invalid read of size 1
>> ==24814==    at 0x4C2E500: __GI_strncpy (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
>> ==24814==    by 0x4EF5B4D: PetscStrncpy (str.c:335)
>> ==24814==    by 0x4F334E0: petscprintf_ (zmprintf.c:54)
>> ==24814==    by 0x400F28: MAIN__ (test.F90:11)
>> ==24814==    by 0x400F9A: main (test.F90:16)
>> ==24814==  Address 0x8cef5ab is 0 bytes after a block of size 11 alloc'd
>> ==24814==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
>> ==24814==    by 0x6828BB4: ??? (in /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0)
>> ==24814==    by 0x68FBC97: _gfortran_string_trim (in /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0)
>> ==24814==    by 0x400EFD: MAIN__ (test.F90:11)
>> ==24814==    by 0x400F9A: main (test.F90:16)
>> ==24814== 
>> ==24815== Invalid read of size 1
>> ==24815==    at 0x4C2E500: __GI_strncpy (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
>> ==24815==    by 0x4EF5B4D: PetscStrncpy (str.c:335)
>> ==24815==    by 0x4F334E0: petscprintf_ (zmprintf.c:54)
>> ==24815==    by 0x400F28: MAIN__ (test.F90:11)
>> ==24815==    by 0x400F9A: main (test.F90:16)
>> ==24815==  Address 0x8cef51b is 0 bytes after a block of size 11 alloc'd
>> ==24815==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
>> ==24815==    by 0x6828BB4: ??? (in /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0)
>> ==24815==    by 0x68FBC97: _gfortran_string_trim (in /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0)
>> ==24815==    by 0x400EFD: MAIN__ (test.F90:11)
>> ==24815==    by 0x400F9A: main (test.F90:16)
>> ==24815== 
>> ==24813== Invalid read of size 1
>> ==24813==    at 0x4C2E500: __GI_strncpy (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
>> ==24813==    by 0x4EF5B4D: PetscStrncpy (str.c:335)
>> ==24813==    by 0x4F334E0: petscprintf_ (zmprintf.c:54)
>> ==24813==    by 0x400F28: MAIN__ (test.F90:11)
>> ==24813==    by 0x400F9A: main (test.F90:16)
>> ==24813==  Address 0x8cef51b is 0 bytes after a block of size 11 alloc'd
>> ==24813==    at 0x4C2AB80: malloc (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so)
>> ==24813==    by 0x6828BB4: ??? (in /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0)
>> ==24813==    by 0x68FBC97: _gfortran_string_trim (in /usr/lib/x86_64-linux-gnu/libgfortran.so.3.0.0)
>> ==24813==    by 0x400EFD: MAIN__ (test.F90:11)
>> ==24813==    by 0x400F9A: main (test.F90:16)
>> ==24813== 



More information about the petsc-users mailing list