[capi-sig] c extension corrupting the python interpreter ?

Stefan Behnel python_capi at behnel.de
Fri Jun 22 08:08:32 CEST 2012


[changed the citation order to fix the top-post]

Ian Miers, 22.06.2012 04:37:
> On Thu, Jun 21, 2012 at 8:46 AM, Andrei Paraschivescu wrote:
> 
>> Ian, do you have other Python interpreters running? I don't know if that
>> can cause the behavior you describe, but as some information is shared
>> across interpreters (e.g. you can unpickle a class you have not imported if
>> another interpreter has), it could potentially be relevant.
>>
>> I have not been able to find where the documentation describes what is
>> shared across interpreters, but perhaps someone who understands that issue
>> can chime in.
>
> I have python2.7, 3.2 and 3.2 debug installed. Python 2.7 was likely
> running as part of some deamons in ubuntu( at least they are running
> now) . Funnily, I have these environments all inside virtualenv ( which
> appears to just  sym lin  the system  python(in this case 3.2) interpreter
> and  I believe changes the paths for site packages and such) and yet the
> errors don't seem to propagate back to the system interpreter or across
> virtualenv environments.

I'm sure that's not what Andrei meant. He likely referred to starting up
multiple interpreters within the *same* process. Separate processes don't
interfere with each other. From your answer, I take it that you're not
using this feature (which is not commonly used anyway).

In any case, you might have more luck asking on the general Python mailing
list (aka. comp.lang.python). It has a lot more listeners (aka. eyeballs).

As a general remark: yes, it's very possible that a C extension crashes
Python. In almost all cases, it's due to a bug in the C extension, of which
the vast majority are reference counting bugs. That's why I keep
encouraging users to write their extensions in Cython instead of C, because
it makes these things just so much easier - most of it happens
automatically. And it's a lot more pleasant for Python programmers to write
Cython code than to step down into C all on your own.

Stefan


More information about the capi-sig mailing list