More about memory check: error message from valgrind

Barry Smith bsmith at mcs.anl.gov
Tue May 5 17:07:54 CDT 2009


    These are all errors at the OS level and can be ignored.

    The other error in the DA you got in your code I cannot understand.

    Barry

On May 5, 2009, at 5:04 PM, (Rebecca) Xuefei YUAN wrote:

> Hi,
>
> I ran the exe5 (/petsc-3.0.0-p1/src/snes/examples/tutorials/ex5.c)  
> and it turned out the errors for PetscInitialize() also exists.  
> Anything wrong?
>
> valgrind --leak-check=full --show-reachable=yes --tool=memcheck ./test
> ==27852== Memcheck, a memory error detector.
> ==27852== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward  
> et al.
> ==27852== Using LibVEX rev 1804, a library for dynamic binary  
> translation.
> ==27852== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
> ==27852== Using valgrind-3.3.0-Debian, a dynamic binary  
> instrumentation framework.
> ==27852== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward  
> et al.
> ==27852== For more details, rerun with: -v
> ==27852==
> ==27852== Invalid read of size 4
> ==27852==    at 0x40151F9: (within /lib/ld-2.7.so)
> ==27852==    by 0x4005C59: (within /lib/ld-2.7.so)
> ==27852==    by 0x4007A87: (within /lib/ld-2.7.so)
> ==27852==    by 0x4011533: (within /lib/ld-2.7.so)
> ==27852==    by 0x400D5C5: (within /lib/ld-2.7.so)
> ==27852==    by 0x4010F4D: (within /lib/ld-2.7.so)
> ==27852==    by 0x42C0291: (within /lib/tls/i686/cmov/libc-2.7.so)
> ==27852==    by 0x400D5C5: (within /lib/ld-2.7.so)
> ==27852==    by 0x42C0454: __libc_dlopen_mode (in /lib/tls/i686/cmov/ 
> libc-2.7.so)
> ==27852==    by 0x429A186: __nss_lookup_function (in /lib/tls/i686/ 
> cmov/libc-2.7.so)
> ==27852==    by 0x429A29F: (within /lib/tls/i686/cmov/libc-2.7.so)
> ==27852==    by 0x429BEC5: __nss_hosts_lookup (in /lib/tls/i686/cmov/ 
> libc-2.7.so)
> ==27852==  Address 0x432af8c is 36 bytes inside a block of size 37  
> alloc'd
> ==27852==    at 0x4022AB8: malloc (vg_replace_malloc.c:207)
> ==27852==    by 0x4008021: (within /lib/ld-2.7.so)
> ==27852==    by 0x4011533: (within /lib/ld-2.7.so)
> ==27852==    by 0x400D5C5: (within /lib/ld-2.7.so)
> ==27852==    by 0x4010F4D: (within /lib/ld-2.7.so)
> ==27852==    by 0x42C0291: (within /lib/tls/i686/cmov/libc-2.7.so)
> ==27852==    by 0x400D5C5: (within /lib/ld-2.7.so)
> ==27852==    by 0x42C0454: __libc_dlopen_mode (in /lib/tls/i686/cmov/ 
> libc-2.7.so)
> ==27852==    by 0x429A186: __nss_lookup_function (in /lib/tls/i686/ 
> cmov/libc-2.7.so)
> ==27852==    by 0x429A29F: (within /lib/tls/i686/cmov/libc-2.7.so)
> ==27852==    by 0x429BEC5: __nss_hosts_lookup (in /lib/tls/i686/cmov/ 
> libc-2.7.so)
> ==27852==    by 0x42A0782: gethostbyname_r (in /lib/tls/i686/cmov/ 
> libc-2.7.so)
> ==27852==
> ==27852== Invalid read of size 4
> ==27852==    at 0x40151E3: (within /lib/ld-2.7.so)
> ==27852==    by 0x4005C59: (within /lib/ld-2.7.so)
> ==27852==    by 0x4007A87: (within /lib/ld-2.7.so)
> ==27852==    by 0x4011533: (within /lib/ld-2.7.so)
> ==27852==    by 0x400D5C5: (within /lib/ld-2.7.so)
> ==27852==    by 0x4010F4D: (within /lib/ld-2.7.so)
> ==27852==    by 0x42C0291: (within /lib/tls/i686/cmov/libc-2.7.so)
> ==27852==    by 0x400D5C5: (within /lib/ld-2.7.so)
> ==27852==    by 0x42C0454: __libc_dlopen_mode (in /lib/tls/i686/cmov/ 
> libc-2.7.so)
> ==27852==    by 0x429A186: __nss_lookup_function (in /lib/tls/i686/ 
> cmov/libc-2.7.so)
> ==27852==    by 0x4731FFB: (within /lib/tls/i686/cmov/ 
> libnss_compat-2.7.so)
> ==27852==    by 0x473313C: _nss_compat_getpwuid_r (in /lib/tls/i686/ 
> cmov/libnss_compat-2.7.so)
> ==27852==  Address 0x432c1f8 is 32 bytes inside a block of size 35  
> alloc'd
> ==27852==    at 0x4022AB8: malloc (vg_replace_malloc.c:207)
> ==27852==    by 0x4008021: (within /lib/ld-2.7.so)
> ==27852==    by 0x4011533: (within /lib/ld-2.7.so)
> ==27852==    by 0x400D5C5: (within /lib/ld-2.7.so)
> ==27852==    by 0x4010F4D: (within /lib/ld-2.7.so)
> ==27852==    by 0x42C0291: (within /lib/tls/i686/cmov/libc-2.7.so)
> ==27852==    by 0x400D5C5: (within /lib/ld-2.7.so)
> ==27852==    by 0x42C0454: __libc_dlopen_mode (in /lib/tls/i686/cmov/ 
> libc-2.7.so)
> ==27852==    by 0x429A186: __nss_lookup_function (in /lib/tls/i686/ 
> cmov/libc-2.7.so)
> ==27852==    by 0x4731FFB: (within /lib/tls/i686/cmov/ 
> libnss_compat-2.7.so)
> ==27852==    by 0x473313C: _nss_compat_getpwuid_r (in /lib/tls/i686/ 
> cmov/libnss_compat-2.7.so)
> ==27852==    by 0x4246D15: getpwuid_r (in /lib/tls/i686/cmov/ 
> libc-2.7.so)
> Number of Newton iterations = 4
> ==27852==
> ==27852== ERROR SUMMARY: 3 errors from 2 contexts (suppressed: 41  
> from 1)
> ==27852== malloc/free: in use at exit: 156 bytes in 11 blocks.
> ==27852== malloc/free: 1,345 allocs, 1,334 frees, 714,197 bytes  
> allocated.
> ==27852== For counts of detected errors, rerun with: -v
> ==27852== searching for pointers to 11 not-freed blocks.
> ==27852== checked 1,072,220 bytes.
> ==27852==
> ==27852==
> ==27852== 156 (36 direct, 120 indirect) bytes in 1 blocks are  
> definitely lost in loss record 1 of 3
> ==27852==    at 0x4022AB8: malloc (vg_replace_malloc.c:207)
> ==27852==    by 0x429A3E2: (within /lib/tls/i686/cmov/libc-2.7.so)
> ==27852==    by 0x429AC2D: __nss_database_lookup (in /lib/tls/i686/ 
> cmov/libc-2.7.so)
> ==27852==    by 0x4731FDB: ???
> ==27852==    by 0x473313C: ???
> ==27852==    by 0x4246D15: getpwuid_r (in /lib/tls/i686/cmov/ 
> libc-2.7.so)
> ==27852==    by 0x424665D: getpwuid (in /lib/tls/i686/cmov/ 
> libc-2.7.so)
> ==27852==    by 0x861D299: PetscGetUserName (fuser.c:68)
> ==27852==    by 0x85DAA80: PetscErrorPrintfInitialize (errtrace.c:68)
> ==27852==    by 0x860DBB3: PetscInitialize (pinit.c:518)
> ==27852==    by 0x804B62E: main (test.c:90)
> ==27852==
> ==27852==
> ==27852== 40 bytes in 5 blocks are indirectly lost in loss record 2  
> of 3
> ==27852==    at 0x4022AB8: malloc (vg_replace_malloc.c:207)
> ==27852==    by 0x4299FBB: __nss_lookup_function (in /lib/tls/i686/ 
> cmov/libc-2.7.so)
> ==27852==    by 0x4731FFB: ???
> ==27852==    by 0x473313C: ???
> ==27852==    by 0x4246D15: getpwuid_r (in /lib/tls/i686/cmov/ 
> libc-2.7.so)
> ==27852==    by 0x424665D: getpwuid (in /lib/tls/i686/cmov/ 
> libc-2.7.so)
> ==27852==    by 0x861D299: PetscGetUserName (fuser.c:68)
> ==27852==    by 0x85DAA80: PetscErrorPrintfInitialize (errtrace.c:68)
> ==27852==    by 0x860DBB3: PetscInitialize (pinit.c:518)
> ==27852==    by 0x804B62E: main (test.c:90)
> ==27852==
> ==27852==
> ==27852== 80 bytes in 5 blocks are indirectly lost in loss record 3  
> of 3
> ==27852==    at 0x4022AB8: malloc (vg_replace_malloc.c:207)
> ==27852==    by 0x428739B: tsearch (in /lib/tls/i686/cmov/libc-2.7.so)
> ==27852==    by 0x4299F7D: __nss_lookup_function (in /lib/tls/i686/ 
> cmov/libc-2.7.so)
> ==27852==    by 0x4731FFB: ???
> ==27852==    by 0x473313C: ???
> ==27852==    by 0x4246D15: getpwuid_r (in /lib/tls/i686/cmov/ 
> libc-2.7.so)
> ==27852==    by 0x424665D: getpwuid (in /lib/tls/i686/cmov/ 
> libc-2.7.so)
> ==27852==    by 0x861D299: PetscGetUserName (fuser.c:68)
> ==27852==    by 0x85DAA80: PetscErrorPrintfInitialize (errtrace.c:68)
> ==27852==    by 0x860DBB3: PetscInitialize (pinit.c:518)
> ==27852==    by 0x804B62E: main (test.c:90)
> ==27852==
> ==27852== LEAK SUMMARY:
> ==27852==    definitely lost: 36 bytes in 1 blocks.
> ==27852==    indirectly lost: 120 bytes in 10 blocks.
> ==27852==      possibly lost: 0 bytes in 0 blocks.
> ==27852==    still reachable: 0 bytes in 0 blocks.
> ==27852==         suppressed: 0 bytes in 0 blocks.
>
>
>
> Quoting "(Rebecca) Xuefei YUAN" <xy2102 at columbia.edu>:
>
>> Hi,
>>
>> I am using valgrind to check the memory leaking and it turned out  
>> that
>> I got 3 errors and they were happening at the the PetscInitialize(),
>> and DACreate2d()
>>
>> line 79: PetscInitialize(&argc, &argv, (char*)0, help);
>> line 84: ierr = DACreate2d(comm,DA_XPERIODIC,DA_STENCIL_BOX, -5, -5,
>> PETSC_DECIDE, PETSC_DECIDE, 4, 2, 0, 0, &da);CHKERRQ(ierr);
>>
>>
>> What could be wrong here? Thanks!
>>
>> The following is the message from valgrind
>>
>> -----------------------------------------------------------------
>> valgrind --leak-check=full --show-reachable=yes --tool=memcheck
>> ./vdthpffxmhd -options_file option_ffxmhd>output
>> ==26665== Memcheck, a memory error detector.
>> ==26665== Copyright (C) 2002-2007, and GNU GPL'd, by Julian Seward  
>> et al.
>> ==26665== Using LibVEX rev 1804, a library for dynamic binary  
>> translation.
>> ==26665== Copyright (C) 2004-2007, and GNU GPL'd, by OpenWorks LLP.
>> ==26665== Using valgrind-3.3.0-Debian, a dynamic binary  
>> instrumentation
>> framework.
>> ==26665== Copyright (C) 2000-2007, and GNU GPL'd, by Julian Seward  
>> et al.
>> ==26665== For more details, rerun with: -v
>> ==26665==
>> ==26665== Invalid read of size 4
>> ==26665==    at 0x40151F9: (within /lib/ld-2.7.so)
>> ==26665==    by 0x4005C59: (within /lib/ld-2.7.so)
>> ==26665==    by 0x4007A87: (within /lib/ld-2.7.so)
>> ==26665==    by 0x4011533: (within /lib/ld-2.7.so)
>> ==26665==    by 0x400D5C5: (within /lib/ld-2.7.so)
>> ==26665==    by 0x4010F4D: (within /lib/ld-2.7.so)
>> ==26665==    by 0x42C0291: (within /lib/tls/i686/cmov/libc-2.7.so)
>> ==26665==    by 0x400D5C5: (within /lib/ld-2.7.so)
>> ==26665==    by 0x42C0454: __libc_dlopen_mode (in
>> /lib/tls/i686/cmov/libc-2.7.so)
>> ==26665==    by 0x429A186: __nss_lookup_function (in
>> /lib/tls/i686/cmov/libc-2.7.so)
>> ==26665==    by 0x429A29F: (within /lib/tls/i686/cmov/libc-2.7.so)
>> ==26665==    by 0x429BEC5: __nss_hosts_lookup (in
>> /lib/tls/i686/cmov/libc-2.7.so)
>> ==26665==  Address 0x432af8c is 36 bytes inside a block of size 37  
>> alloc'd
>> ==26665==    at 0x4022AB8: malloc (vg_replace_malloc.c:207)
>> ==26665==    by 0x4008021: (within /lib/ld-2.7.so)
>> ==26665==    by 0x4011533: (within /lib/ld-2.7.so)
>> ==26665==    by 0x400D5C5: (within /lib/ld-2.7.so)
>> ==26665==    by 0x4010F4D: (within /lib/ld-2.7.so)
>> ==26665==    by 0x42C0291: (within /lib/tls/i686/cmov/libc-2.7.so)
>> ==26665==    by 0x400D5C5: (within /lib/ld-2.7.so)
>> ==26665==    by 0x42C0454: __libc_dlopen_mode (in
>> /lib/tls/i686/cmov/libc-2.7.so)
>> ==26665==    by 0x429A186: __nss_lookup_function (in
>> /lib/tls/i686/cmov/libc-2.7.so)
>> ==26665==    by 0x429A29F: (within /lib/tls/i686/cmov/libc-2.7.so)
>> ==26665==    by 0x429BEC5: __nss_hosts_lookup (in
>> /lib/tls/i686/cmov/libc-2.7.so)
>> ==26665==    by 0x42A0782: gethostbyname_r (in  /lib/tls/i686/cmov/ 
>> libc-2.7.so)
>> ==26665==
>> ==26665== Invalid read of size 4
>> ==26665==    at 0x40151E3: (within /lib/ld-2.7.so)
>> ==26665==    by 0x4005C59: (within /lib/ld-2.7.so)
>> ==26665==    by 0x4007A87: (within /lib/ld-2.7.so)
>> ==26665==    by 0x4011533: (within /lib/ld-2.7.so)
>> ==26665==    by 0x400D5C5: (within /lib/ld-2.7.so)
>> ==26665==    by 0x4010F4D: (within /lib/ld-2.7.so)
>> ==26665==    by 0x42C0291: (within /lib/tls/i686/cmov/libc-2.7.so)
>> ==26665==    by 0x400D5C5: (within /lib/ld-2.7.so)
>> ==26665==    by 0x42C0454: __libc_dlopen_mode (in
>> /lib/tls/i686/cmov/libc-2.7.so)
>> ==26665==    by 0x429A186: __nss_lookup_function (in
>> /lib/tls/i686/cmov/libc-2.7.so)
>> ==26665==    by 0x4731FFB: (within /lib/tls/i686/cmov/ 
>> libnss_compat-2.7.so)
>> ==26665==    by 0x473313C: _nss_compat_getpwuid_r (in
>> /lib/tls/i686/cmov/libnss_compat-2.7.so)
>> ==26665==  Address 0x432c1f8 is 32 bytes inside a block of size 35  
>> alloc'd
>> ==26665==    at 0x4022AB8: malloc (vg_replace_malloc.c:207)
>> ==26665==    by 0x4008021: (within /lib/ld-2.7.so)
>> ==26665==    by 0x4011533: (within /lib/ld-2.7.so)
>> ==26665==    by 0x400D5C5: (within /lib/ld-2.7.so)
>> ==26665==    by 0x4010F4D: (within /lib/ld-2.7.so)
>> ==26665==    by 0x42C0291: (within /lib/tls/i686/cmov/libc-2.7.so)
>> ==26665==    by 0x400D5C5: (within /lib/ld-2.7.so)
>> ==26665==    by 0x42C0454: __libc_dlopen_mode (in
>> /lib/tls/i686/cmov/libc-2.7.so)
>> ==26665==    by 0x429A186: __nss_lookup_function (in
>> /lib/tls/i686/cmov/libc-2.7.so)
>> ==26665==    by 0x4731FFB: (within /lib/tls/i686/cmov/ 
>> libnss_compat-2.7.so)
>> ==26665==    by 0x473313C: _nss_compat_getpwuid_r (in
>> /lib/tls/i686/cmov/libnss_compat-2.7.so)
>> ==26665==    by 0x4246D15: getpwuid_r (in /lib/tls/i686/cmov/ 
>> libc-2.7.so)
>> ==26665==
>> ==26665== ERROR SUMMARY: 3 errors from 2 contexts (suppressed: 41  
>> from 1)
>> ==26665== malloc/free: in use at exit: 64,352 bytes in 87 blocks.
>> ==26665== malloc/free: 2,472 allocs, 2,385 frees, 3,015,115 bytes  
>> allocated.
>> ==26665== For counts of detected errors, rerun with: -v
>> ==26665== searching for pointers to 87 not-freed blocks.
>> ==26665== checked 1,120,136 bytes.
>> ==26665==
>> ==26665==
>> ==26665== 32 bytes in 2 blocks are still reachable in loss record 1  
>> of 5
>> ==26665==    at 0x4022AB8: malloc (vg_replace_malloc.c:207)
>> ==26665==    by 0x871B2A8: MPID_VCRT_Create (mpid_vc.c:62)
>> ==26665==    by 0x8718C6A: MPID_Init (mpid_init.c:116)
>> ==26665==    by 0x86F1C3B: MPIR_Init_thread (initthread.c:288)
>> ==26665==    by 0x86F175D: PMPI_Init (init.c:106)
>> ==26665==    by 0x86355A1: PetscInitialize (pinit.c:503)
>> ==26665==    by 0x804B627: main (vdthpffxmhd.c:79)
>> ==26665==
>> ==26665==
>> ==26665== 156 (36 direct, 120 indirect) bytes in 1 blocks are
>> definitely lost in loss record 2 of 5
>> ==26665==    at 0x4022AB8: malloc (vg_replace_malloc.c:207)
>> ==26665==    by 0x429A3E2: (within /lib/tls/i686/cmov/libc-2.7.so)
>> ==26665==    by 0x429AC2D: __nss_database_lookup (in
>> /lib/tls/i686/cmov/libc-2.7.so)
>> ==26665==    by 0x4731FDB: ???
>> ==26665==    by 0x473313C: ???
>> ==26665==    by 0x4246D15: getpwuid_r (in /lib/tls/i686/cmov/ 
>> libc-2.7.so)
>> ==26665==    by 0x424665D: getpwuid (in /lib/tls/i686/cmov/ 
>> libc-2.7.so)
>> ==26665==    by 0x8644D41: PetscGetUserName (fuser.c:68)
>> ==26665==    by 0x8602528: PetscErrorPrintfInitialize (errtrace.c:68)
>> ==26665==    by 0x863565B: PetscInitialize (pinit.c:518)
>> ==26665==    by 0x804B627: main (vdthpffxmhd.c:79)
>> ==26665==
>> ==26665==
>> ==26665== 40 bytes in 5 blocks are indirectly lost in loss record 3  
>> of 5
>> ==26665==    at 0x4022AB8: malloc (vg_replace_malloc.c:207)
>> ==26665==    by 0x4299FBB: __nss_lookup_function (in
>> /lib/tls/i686/cmov/libc-2.7.so)
>> ==26665==    by 0x4731FFB: ???
>> ==26665==    by 0x473313C: ???
>> ==26665==    by 0x4246D15: getpwuid_r (in /lib/tls/i686/cmov/ 
>> libc-2.7.so)
>> ==26665==    by 0x424665D: getpwuid (in /lib/tls/i686/cmov/ 
>> libc-2.7.so)
>> ==26665==    by 0x8644D41: PetscGetUserName (fuser.c:68)
>> ==26665==    by 0x8602528: PetscErrorPrintfInitialize (errtrace.c:68)
>> ==26665==    by 0x863565B: PetscInitialize (pinit.c:518)
>> ==26665==    by 0x804B627: main (vdthpffxmhd.c:79)
>> ==26665==
>> ==26665==
>> ==26665== 80 bytes in 5 blocks are indirectly lost in loss record 4  
>> of 5
>> ==26665==    at 0x4022AB8: malloc (vg_replace_malloc.c:207)
>> ==26665==    by 0x428739B: tsearch (in /lib/tls/i686/cmov/ 
>> libc-2.7.so)
>> ==26665==    by 0x4299F7D: __nss_lookup_function (in
>> /lib/tls/i686/cmov/libc-2.7.so)
>> ==26665==    by 0x4731FFB: ???
>> ==26665==    by 0x473313C: ???
>> ==26665==    by 0x4246D15: getpwuid_r (in /lib/tls/i686/cmov/ 
>> libc-2.7.so)
>> ==26665==    by 0x424665D: getpwuid (in /lib/tls/i686/cmov/ 
>> libc-2.7.so)
>> ==26665==    by 0x8644D41: PetscGetUserName (fuser.c:68)
>> ==26665==    by 0x8602528: PetscErrorPrintfInitialize (errtrace.c:68)
>> ==26665==    by 0x863565B: PetscInitialize (pinit.c:518)
>> ==26665==    by 0x804B627: main (vdthpffxmhd.c:79)
>> ==26665==
>> ==26665==
>> ==26665== 64,164 bytes in 74 blocks are still reachable in loss  
>> record 5 of 5
>> ==26665==    at 0x4022AB8: malloc (vg_replace_malloc.c:207)
>> ==26665==    by 0x8610BE4: PetscMallocAlign (mal.c:40)
>> ==26665==    by 0x8611CD3: PetscTrMallocDefault (mtr.c:194)
>> ==26665==    by 0x81DE577: DACreate2d (da2.c:364)
>> ==26665==    by 0x804B701: main (vdthpffxmhd.c:84)
>> ==26665==
>> ==26665== LEAK SUMMARY:
>> ==26665==    definitely lost: 36 bytes in 1 blocks.
>> ==26665==    indirectly lost: 120 bytes in 10 blocks.
>> ==26665==      possibly lost: 0 bytes in 0 blocks.
>> ==26665==    still reachable: 64,196 bytes in 76 blocks.
>> ==26665==         suppressed: 0 bytes in 0 blocks.
>>
>>
>> ------------------------------------------------------------------
>> -- 
>> (Rebecca) Xuefei YUAN
>> Department of Applied Physics and Applied Mathematics
>> Columbia University
>> Tel:917-399-8032
>> www.columbia.edu/~xy2102
>
>
>
> -- 
> (Rebecca) Xuefei YUAN
> Department of Applied Physics and Applied Mathematics
> Columbia University
> Tel:917-399-8032
> www.columbia.edu/~xy2102
>



More information about the petsc-users mailing list