[Python-bugs-list] [ python-Bugs-521854 ] Different extension modules share space

noreply@sourceforge.net noreply@sourceforge.net
Sat, 23 Feb 2002 11:20:28 -0800


Bugs item #521854, was opened at 2002-02-23 11:20
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=521854&group_id=5470

Category: Extension Modules
Group: Python 2.1.2
Status: Open
Resolution: None
Priority: 5
Submitted By: Pearu Peterson (pearu)
Assigned to: Nobody/Anonymous (nobody)
Summary: Different extension modules share space

Initial Comment:
Hi!
I have found that if two extension modules use the same
third party
library that defines a static variable, then this
static variable is shared 
in both extension modules. In real applications, this
can cause curious segmentation faults if both extension
modules are used in the same
Python script or session. Using these extension modules
in separate
session generates no problems whatsoever.
This is observed only with Python version 2.1.1 and
2.1.2.
Python 2.0 and 2.2 are free from the described
symptoms. Therefore,
it makes me argue that there are still bugs in 2.1.2
that are related to importing extension modules. I have
prepared a small example to demonstrate all this. The
example consists of 4 files: runme.py, foo.c, bar.c,
and fun.c that are attached to this report. You only
need to run runme.py.
Here are the outputs of runme.py when used with
different Python 
versions:
$ python2.0 runme.py
>From foo: set_var: var=0; Doing var++
>From bar: set_var: var=0; Doing var++
$ python2.1 runme.py
>From foo: set_var: var=0; Doing var++
>From bar: set_var: var=1; Doing var++    <- note that
var=1 was set in foo
$ python2.2 runme.py
>From foo: set_var: var=0; Doing var++
>From bar: set_var: var=0; Doing var++
These tests are performed on Debian Woody with
gcc-2.95.4.

I appreciate if you could suggest a fix or workaround
to extension modules that are build under Python 2.1.2,
of course only if possible.
Thanks,
	Pearu

----------------------------------------------------------------------

You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=521854&group_id=5470