LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Slackware (http://www.linuxquestions.org/questions/slackware-14/)
-   -   Memory errors in Python? (http://www.linuxquestions.org/questions/slackware-14/memory-errors-in-python-4175433064/)

guanx 10-19-2012 09:47 AM

Memory errors in Python?
 
1 Attachment(s)
I just tried to run Python from Slackware 14 with valgrind and saw a huge amount of errors. Is this a fault in Python or in valgrind?
Code:

$ valgrind python -c ""
==13793== Memcheck, a memory error detector
==13793== Copyright (C) 2002-2012, and GNU GPL'd, by Julian Seward et al.
==13793== Using Valgrind-3.8.1 and LibVEX; rerun with -h for copyright info
==13793== Command: python -c
==13793==
==13793== Invalid read of size 4
==13793==    at 0x40AD1B1: PyObject_Free (in /usr/lib/libpython2.7.so.1.0)
==13793==    by 0x62696C2E: ???
==13793==  Address 0x44dd010 is 168 bytes inside a block of size 352 free'd
==13793==    at 0x4029C14: free (vg_replace_malloc.c:446)
==13793==    by 0x42E03AB: fclose@@GLIBC_2.1 (in /lib/libc-2.15.so)
==13793==    by 0x412BAF7: ??? (in /usr/lib/libpython2.7.so.1.0)
==13793==    by 0x62696C2E: ???
==13793==
==13793== Conditional jump or move depends on uninitialised value(s)
==13793==    at 0x40AD1BA: PyObject_Free (in /usr/lib/libpython2.7.so.1.0)
==13793==    by 0x415116D: PyObject_GC_Del (in /usr/lib/libpython2.7.so.1.0)
==13793==    by 0x4077161: ??? (in /usr/lib/libpython2.7.so.1.0)
==13793==    by 0x40C21EE: ??? (in /usr/lib/libpython2.7.so.1.0)
==13793==    by 0x407726B: ??? (in /usr/lib/libpython2.7.so.1.0)
==13793==    by 0x62696C2E: ???
==13793==
...
... and so on ...
... and so on ...
...
==13793==
==13793==
==13793== HEAP SUMMARY:
==13793==    in use at exit: 1,009,659 bytes in 229 blocks
==13793==  total heap usage: 9,076 allocs, 8,847 frees, 6,084,251 bytes allocated
==13793==
==13793== LEAK SUMMARY:
==13793==    definitely lost: 0 bytes in 0 blocks
==13793==    indirectly lost: 0 bytes in 0 blocks
==13793==      possibly lost: 5,684 bytes in 16 blocks
==13793==    still reachable: 1,003,975 bytes in 213 blocks
==13793==        suppressed: 0 bytes in 0 blocks
==13793== Rerun with --leak-check=full to see details of leaked memory
==13793==
==13793== For counts of detected and suppressed errors, rerun with: -v
==13793== Use --track-origins=yes to see where uninitialised values come from
==13793== ERROR SUMMARY: 722 errors from 35 contexts (suppressed: 0 from 0)


smallpond 10-19-2012 03:12 PM

Using the valgrind and python in RHEL 6.3 gives no errors:

Code:

# valgrind python -c ""
==28740== Memcheck, a memory error detector
==28740== Copyright (C) 2002-2010, and GNU GPL'd, by Julian Seward et al.
==28740== Using Valgrind-3.6.0 and LibVEX; rerun with -h for copyright info
==28740== Command: python -c
==28740==
==28740==
==28740== HEAP SUMMARY:
==28740==    in use at exit: 764,828 bytes in 4,444 blocks
==28740==  total heap usage: 16,926 allocs, 12,482 frees, 3,000,042 bytes allocated
==28740==
==28740== LEAK SUMMARY:
==28740==    definitely lost: 0 bytes in 0 blocks
==28740==    indirectly lost: 0 bytes in 0 blocks
==28740==      possibly lost: 6,152 bytes in 13 blocks
==28740==    still reachable: 758,676 bytes in 4,431 blocks
==28740==        suppressed: 0 bytes in 0 blocks
==28740== Rerun with --leak-check=full to see details of leaked memory
==28740==
==28740== For counts of detected and suppressed errors, rerun with: -v
==28740== ERROR SUMMARY: 0 errors from 0 contexts (suppressed: 6 from 6)
# python -V
Python 2.6.6


angryfirelord 10-19-2012 08:29 PM

According to this post, it may not be a problem: http://stackoverflow.com/questions/1...n-memory-leaks


All times are GMT -5. The time now is 05:36 AM.