Package: python2.7
Version: 2.7.3~rc1-1
Severity: important

File descriptors opened by PyFile_FromString don't get closed when the
reference count is decreased.

Here's my test program, pythony.c:

#include <Python.h>

int main()
{
  int i = 0;
  PyObject *obj;

  Py_Initialize();
  while (i++ < 5) {
    obj = PyFile_FromString("hello.py", "r");
    assert(obj);
    Py_DECREF(obj);
  }
  Py_Finalize();
}

hello.py is 'print("hello world")'.

I'm compiling it with both Python 2.6 and 2.7.
$ gcc pythony.c -lpython2.6 -L/usr/lib/python2.6/config 
-I/usr/include/python2.6/ -o pythony-2.6
$ gcc pythony.c -lpython2.7 -L/usr/lib/python2.7/config 
-I/usr/include/python2.7/ -o pythony-2.7

$ strace ./pythony-2.6 2>&1 | tail -n 20
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fffb1d097b0) = -1 EINVAL (Invalid 
argument)
ioctl(2, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7fffb1d097b0) = -1 EINVAL (Invalid 
argument)
open("hello.py", O_RDONLY)              = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=21, ...}) = 0
close(3)                                = 0
open("hello.py", O_RDONLY)              = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=21, ...}) = 0
close(3)                                = 0
open("hello.py", O_RDONLY)              = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=21, ...}) = 0
close(3)                                = 0
open("hello.py", O_RDONLY)              = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=21, ...}) = 0
close(3)                                = 0
open("hello.py", O_RDONLY)              = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=21, ...}) = 0
close(3)                                = 0
rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7f1e1a0224f0}, 
{0x7f1e1a49a160, [], SA_RESTORER, 0x7f1e1a0224f0}, 8) = 0
exit_group(0)                           = ?


$ strace ./pythony-2.7 2>&1 | tail -n 20
fstat(4, {st_mode=S_IFREG|0644, st_size=1950, ...}) = 0
read(4, "", 4096)                       = 0
close(4)                                = 0
munmap(0x7fa41f10f000, 4096)            = 0
close(3)                                = 0
ioctl(0, SNDCTL_TMR_TIMEBASE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7ffff7bd33f0) = -1 EINVAL (Invalid 
argument)
ioctl(2, SNDCTL_TMR_TIMEBASE or TCGETS, 0x7ffff7bd33f0) = -1 EINVAL (Invalid 
argument)
open("hello.py", O_RDONLY)              = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=21, ...}) = 0
open("hello.py", O_RDONLY)              = 4
fstat(4, {st_mode=S_IFREG|0644, st_size=21, ...}) = 0
open("hello.py", O_RDONLY)              = 5
fstat(5, {st_mode=S_IFREG|0644, st_size=21, ...}) = 0
open("hello.py", O_RDONLY)              = 6
fstat(6, {st_mode=S_IFREG|0644, st_size=21, ...}) = 0
open("hello.py", O_RDONLY)              = 7
fstat(7, {st_mode=S_IFREG|0644, st_size=21, ...}) = 0
rt_sigaction(SIGINT, {SIG_DFL, [], SA_RESTORER, 0x7fa4206e24f0}, 
{0x7fa420b8dd50, [], SA_RESTORER, 0x7fa4206e24f0}, 8) = 0
exit_group(0)                           = ?


The Python 2.7 version never calls close, not even at Py_Finalize().

On #d-d, jwilk suspected that this change might be the cause:
http://hg.python.org/cpython/rev/0f5b64630fda/#l4.46

-- System Information:
Debian Release: wheezy/sid
  APT prefers unstable
  APT policy: (500, 'unstable')
Architecture: amd64 (x86_64)

Kernel: Linux 3.2.0-2-amd64 (SMP w/6 CPU cores)
Locale: LANG=C, LC_CTYPE=fi_FI.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages python2.7 depends on:
ii  libbz2-1.0         1.0.6-1
ii  libc6              2.13-27
ii  libdb4.8           4.8.30-11
ii  libexpat1          2.0.1-7.2
ii  libgcc1            1:4.6.3-1
ii  libncursesw5       5.9-4
ii  libreadline6       6.2-8
ii  libsqlite3-0       3.7.10-1
ii  libtinfo5          5.9-4
ii  mime-support       3.52-1
ii  python2.7-minimal  2.7.3~rc1-1

python2.7 recommends no packages.

Versions of packages python2.7 suggests:
pn  binutils       2.22-6
pn  python2.7-doc  <none>

-- no debconf information



-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to