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

Randall Mackie rlmackie862 at gmail.com
Mon Aug 4 17:14:13 CDT 2014


Barry,

Yes, that fixes the problem.

Thanks, Randy


On Aug 4, 2014, at 1:49 PM, Barry Smith <bsmith at mcs.anl.gov> wrote:

> 
>   Randall,
> 
>    If you replace the PetscStrncpy(b,a,n+1);  with PetscStrncpy(b,a,n); 
> 
> #define FIXCHAR(a,n,b) \
> {\
>  if (a == PETSC_NULL_CHARACTER_Fortran) { \
>    b = a = 0; \
>  } else { \
>    while((n > 0) && (a[n-1] == ' ')) n--; \
>    *ierr = PetscMalloc((n+1)*sizeof(char),&b); \
>    if (*ierr) return; \
>    *ierr = PetscStrncpy(b,a,n+1); \
>    if (*ierr) return; \
>    b[n] = 0; \
>  } \
> }
> 
> in include/petsc-private/fortranimpl.h and recompile the PETSc libraries does the problem go away?  
> 
> Let me know and I’ll fix the code.
> 
>   Thanks
> 
>   Barry
> 
> 
> 
> On Aug 2, 2014, at 2:20 PM, Randall Mackie <rlmackie862 at gmail.com> wrote:
> 
>> 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
>> ==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.
>> 
>> 
>> <makefile><test.F90><valgrind_out.txt><cmd_configure><cmd_test>
> 



More information about the petsc-users mailing list