Re: Large memory usage by gdb

Simon Marchi <[email protected]>
Newsgroups gmane.comp.gdb.devel
Message-ID <[email protected]>
On 2017-08-07 23:04, Alex Lindsay wrote:
> Yes, I've also seen all those errors. I wrote them off to errors in
> the python library but maybe I should have looked more closely
> 
> On 08/07/2017 02:53 PM, Philippe Waroquiers wrote:
>> On Mon, 2017-08-07 at 10:14 +0100, Yao Qi wrote:
>> 
>>> leaks are bugs, and we should fix them.  I can find these leaks in
>>> valgrind too,
>> When running valgrind + gdb on a small program, I also get
>> many errors like the below (GDB 8.0, Debian 8).
>> 
>> Do you also see that ?
>> 
>> 
>> Philippe
>> 
>> ==9360== Invalid read of size 4
>> ==9360==    at 0x58AD9F3: PyObject_Free (in 
>> /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0)
>> ==9360==    by 0x4C5E7F: gdb_Py_DECREF (python-internal.h:194)
>> ==9360==    by 0x4C5E7F: decref (py-ref.h:36)
>> ==9360==    by 0x4C5E7F: ~ref_ptr (gdb_ref_ptr.h:91)
>> ==9360==    by 0x4C5E7F: unicode_to_encoded_string(_object*, char 
>> const*) (py-utils.c:74)
>> ==9360==    by 0x4C5F9C: python_string_to_host_string(_object*) 
>> (py-utils.c:158)
>> ==9360==    by 0x4BBDDD: get_doc_string(_object*, _object*) 
>> (py-param.c:314)
>> ==9360==    by 0x4BC11D: parmpy_init(_object*, _object*, _object*) 
>> (py-param.c:707)
>> ==9360==    by 0x580AD5B: ??? (in 
>> /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0)
>> ==9360==    by 0x5899BE2: PyObject_Call (in 
>> /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0)
>> ==9360==    by 0x58CD441: PyEval_EvalFrameEx (in 
>> /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0)
>> ==9360==    by 0x594218F: PyEval_EvalCodeEx (in 
>> /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0)
>> ==9360==    by 0x589132B: ??? (in 
>> /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0)
>> ==9360==    by 0x5899BE2: PyObject_Call (in 
>> /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0)
>> ==9360==    by 0x58DC0E4: ??? (in 
>> /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0)
>> ==9360==  Address 0x6f0c020 is 1,280 bytes inside a block of size 
>> 3,133 free'd
>> ==9360==    at 0x4C29B8A: realloc (vg_replace_malloc.c:785)
>> ==9360==    by 0x5862625: _PyString_Resize (in 
>> /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0)
>> ==9360==    by 0x57E40AC: PyUnicodeUCS4_EncodeUTF8 (in 
>> /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0)
>> ==9360==    by 0x5848A98: ??? (in 
>> /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0)
>> ==9360==    by 0x5899BE2: PyObject_Call (in 
>> /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0)
>> ==9360==    by 0x59416E6: PyEval_CallObjectWithKeywords (in 
>> /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0)
>> ==9360==    by 0x5906C4D: PyCodec_Encode (in 
>> /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0)
>> ==9360==    by 0x57E4AB4: PyUnicodeUCS4_AsEncodedString (in 
>> /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0)
>> ==9360==    by 0x4C5E44: unicode_to_encoded_string(_object*, char 
>> const*) (py-utils.c:74)
>> ==9360==    by 0x4C5F9C: python_string_to_host_string(_object*) 
>> (py-utils.c:158)
>> ==9360==    by 0x4BBDDD: get_doc_string(_object*, _object*) 
>> (py-param.c:314)
>> ==9360==    by 0x4BC11D: parmpy_init(_object*, _object*, _object*) 
>> (py-param.c:707)
>> ==9360==  Block was alloc'd at
>> ==9360==    at 0x4C27BF5: malloc (vg_replace_malloc.c:299)
>> ==9360==    by 0x5864249: PyString_FromStringAndSize (in 
>> /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0)
>> ==9360==    by 0x57E41C6: PyUnicodeUCS4_EncodeUTF8 (in 
>> /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0)
>> ==9360==    by 0x5848A98: ??? (in 
>> /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0)
>> ==9360==    by 0x5899BE2: PyObject_Call (in 
>> /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0)
>> ==9360==    by 0x59416E6: PyEval_CallObjectWithKeywords (in 
>> /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0)
>> ==9360==    by 0x5906C4D: PyCodec_Encode (in 
>> /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0)
>> ==9360==    by 0x57E4AB4: PyUnicodeUCS4_AsEncodedString (in 
>> /usr/lib/x86_64-linux-gnu/libpython2.7.so.1.0)
>> ==9360==    by 0x4C5E44: unicode_to_encoded_string(_object*, char 
>> const*) (py-utils.c:74)
>> ==9360==    by 0x4C5F9C: python_string_to_host_string(_object*) 
>> (py-utils.c:158)
>> ==9360==    by 0x4BBDDD: get_doc_string(_object*, _object*) 
>> (py-param.c:314)
>> ==9360==    by 0x4BC11D: parmpy_init(_object*, _object*, _object*) 
>> (py-param.c:707)
>> 
>> 

This is expected with Python:

https://svn.python.org/projects/python/trunk/Misc/README.valgrind

Simon
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.