pcp
[Top] [All Lists]

Re: [pcp] Patch for Python's pmExtractValue Function

To: Stan Cox <scox@xxxxxxxxxx>, Nathan Scott <nathans@xxxxxxxxxx>
Subject: Re: [pcp] Patch for Python's pmExtractValue Function
From: Tom Yearke <tyearke@xxxxxxxxxxx>
Date: Mon, 14 Apr 2014 12:19:05 -0400
Cc: pcp@xxxxxxxxxxx
Delivered-to: pcp@xxxxxxxxxxx
In-reply-to: <534BF23B.80009@xxxxxxxxxx>
References: <53342449.7070602@xxxxxxxxxxx> <53446B81.4020602@xxxxxxxxxx> <235383721.4734118.1397439752269.JavaMail.zimbra@xxxxxxxxxx> <534B6428.1090709@xxxxxxxxxxx> <379826388.5021539.1397463731656.JavaMail.zimbra@xxxxxxxxxx> <534BF23B.80009@xxxxxxxxxx>
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:24.0) Gecko/20100101 Thunderbird/24.4.0
Ow! Glad you're doing better!

I've created a patch for the new solution that obtains the C string address in a hopefully-safe, Python 2.5-friendly manner. It will take a bit longer to test for the seg fault problem, but it's passed the small scale tests I've done, so I wanted to get it out ASAP for feedback.

I did notice some unusual valgrind messages for both the patched and unpatched new solution, which did not occur for any of the other solutions I've attempted. A series of errors like the following are printed:

==14442== Invalid read of size 8
==14442==    at 0x4A08BE8: memcpy (mc_replace_strmem.c:882)
==14442==    by 0x458D26: PyString_FromString (stringobject.c:144)
==14442==    by 0x44CFEA: PyObject_GenericGetAttr (object.c:1424)
==14442==    by 0x49D216: PyEval_EvalFrameEx (ceval.c:2082)
==14442==    by 0x4A00B7: PyEval_EvalFrameEx (ceval.c:3836)
==14442==    by 0x4A00B7: PyEval_EvalFrameEx (ceval.c:3836)
==14442==    by 0x4A119F: PyEval_EvalCodeEx (ceval.c:3000)
==14442==    by 0x49F372: PyEval_EvalFrameEx (ceval.c:3846)
==14442==    by 0x4A119F: PyEval_EvalCodeEx (ceval.c:3000)
==14442==    by 0x4A1271: PyEval_EvalCode (ceval.c:541)
==14442==    by 0x4C0D5D: PyRun_FileExFlags (pythonrun.c:1351)
==14442==    by 0x4C0F73: PyRun_SimpleFileExFlags (pythonrun.c:941)
==14442==  Address 0x10ff1ca8 is 40 bytes inside a block of size 67 free'd
==14442==    at 0x4A063F0: free (vg_replace_malloc.c:446)
==14442==    by 0x4F6A21: frame_dealloc (frameobject.c:420)
==14442==    by 0x4A00DD: PyEval_EvalFrameEx (ceval.c:3838)
==14442==    by 0x4A119F: PyEval_EvalCodeEx (ceval.c:3000)
==14442==    by 0x49F372: PyEval_EvalFrameEx (ceval.c:3846)
==14442==    by 0x4A119F: PyEval_EvalCodeEx (ceval.c:3000)
==14442==    by 0x4A1271: PyEval_EvalCode (ceval.c:541)
==14442==    by 0x4C0D5D: PyRun_FileExFlags (pythonrun.c:1351)
==14442==    by 0x4C0F73: PyRun_SimpleFileExFlags (pythonrun.c:941)
==14442==    by 0x413EB7: Py_Main (main.c:577)
==14442==    by 0x3F7821ED1C: (below main) (in /lib64/libc-2.12.so)

It doesn't seem to occur for every string fetch, and the new code doesn't appear to impact the contents of the returned strings, but I thought it might be important to share.

On 4/14/14, 10:35 AM, Stan Cox wrote:
 I believe Stan has strained his back

Torn oblique; but I am running on all cylinders now (finally!). I will poke at this today, which is EDT for me.


Attachment: patch.diff
Description: Text document

<Prev in Thread] Current Thread [Next in Thread>