LMPX.COM |
Home | Linux | Mysql | PHP | XML | ||
|
|
|||
From: Stefan Seifert Date: Sun Aug 31 15:00:15 2008 Subject: Inline::Python fixes for segfaults and memory leaks.
Hi!
Sending this mail to the inline-mailing list, since NEILW@cpan.org doesn't
seem to be a valid address anymore.
I'm trying to use Inline::Python in a web application for compatibility with
huge amounts of legacy Python code. I've gotten pretty far and it works well,
but it's leaking memory like pretty much all objects one moves from perl to
Python space.
I've fixed a bug where a perl object is freed when it's still in use, three
memory leaks and a segfault that surfaced when some destructors finally got
called, but there are still more segfaults seemingly unrelated to the code I
changed and I'm not even sure if I cought all memory leaks.
What I've found so far:
PerlObj_dealloc should use sv_2mortal instead of SvREFCNT_dec, because the
perl object could be a return value and thus still be in use.
py_call_function and py_call_method both do not free the return value if
called in void context and they only free the constructed argument tuple if
a Python error occured, but not if everything worked.
After fixing that PerlSub_dealloc segfaulted because of uninitialized member
variables (sub, pkg and full).
Py2Pl should sv_2mortal the newly created Inline::Python::Object. Otherwise
it's refcnt would be 2 for a call like:
my $obj = Inline::Python::Object->new('__main__', 'MyClass');
Unfortunately this creates a segfault in py_call_method in my application.
Haven't tracked this down yet.
This is my first real encounter with either Perl's or Python's internals, so
it could be, that I'm completely mistaken about all this. But I think, I'm on
the right track. Nonetheless I would be very, very glad to find someone still
interested in maintaining this module and in my fixes and
maybe give a little support on my mission. To be frank I'm not sure anymore
if I can fix this alone. It seems like a bottomless pit of wrong refcnts and
trying to keep them all right is clearly expanding my mind...
With kind regards,
Stefan Seifert
Attachment: [text/x-diff] Inline-Python-segfaults-memleaks.diff
| Navigate in group perl.inline at sever nntp.perl.org | |
| Previous | Next |
| © No Copyright You are free to use Anything |
Site Maintained by PHP Developer
Powered By PHP Consultants |