Title: Python 3.2 segfault
Type: crash Stage: resolved
Components: Versions: Python 3.2
Status: closed Resolution: works for me
Dependencies: Superseder:
Assigned To: Nosy List: atagar, doko, jcea, skrah
Priority: normal Keywords:

Created on 2013-02-02 18:03 by atagar, last changed 2013-02-03 03:10 by jcea. This issue is now closed.

Messages (5)
msg181190 - (view) Author: Damian (atagar) Date: 2013-02-02 18:03
Hi. While porting a library of mine ( to python 3 I've been reliably encountering a python segmentation fault while running its integration tests. After many hours of head scratching I've narrowed the repro to the following script...


import queue
import socket

class Demo(object):
  def __init__(self, control_socket_file):
    demo_queue = queue.Queue()

      raise ValueError()
    except ValueError as exc:

for i in range(20):
  control_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
  control_socket.connect(("", 80))
  control_socket_file = control_socket.makefile(mode = "rw", newline = "") 



atagar@morrigan:~$ python3 --version
Python 3.2
atagar@morrigan:~$ python3 
Segmentation fault


Yes, I realise that the script is stupidly convoluted but it was the minimal amount of code I could get to in order to reproduce the problem. Some things to note...

* You must have an object that gets a reference to an open socket based file.

* You need to have a try/catch block and enqueue that exception. If you get rid of the try/catch or enqueue something else then no segfault for you.

* The segfault isn't entirely reliable (seems so happen half the time or so), hence the loop.

While this repro script is pointless, it's the last issue preventing me from moving to python 3. At this point I'm out of idea so help would be greatly appreciated.

Thanks! -Damian

Python: Python 3.2 (r32:88445, Oct 20 2012, 14:09:50)
Platform: Ubuntu 11.04

PS. If the advice is 'upgrade python, 3.2 had some segfault bugs' then a pointer to those bugs would be appreciated. I've sunk quite a few hours into this issue so it would be nice to finally figure out what's up.
msg181195 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2013-02-02 18:43
Thanks for the report. I cannot reproduce it with the latest 3.2 version.
Perhaps the version shipped with Ubuntu 11.04 has this problem.
msg181199 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2013-02-02 18:55
IOW, my advice is to get Python 3.3 from and see if
you can reproduce the issue.
msg181202 - (view) Author: Damian (atagar) Date: 2013-02-02 19:08
Thanks. I snagged the 3.3 tarball from '' after your first comment. Compilation just finished and it works there...

atagar@morrigan:~$ ~/Desktop/Python-3.3.0/python --version
Python 3.3.0
atagar@morrigan:~$ ~/Desktop/Python-3.3.0/python 


Feel free to resolve this ticket.
msg181203 - (view) Author: Stefan Krah (skrah) * (Python committer) Date: 2013-02-02 19:18
Thanks for testing. The problem with the Ubuntu Python

  "Python 3.2 (r32:88445, Oct 20 2012, 14:09:50)"

is that it seems to be a patched 3.2.0, while we're already at 3.2.3.

So it might be worth reporting this issue to Ubuntu.
Date User Action Args
2013-02-03 03:10:56jceasetnosy: + jcea
2013-02-02 19:18:04skrahsetstatus: open -> closed
resolution: works for me
messages: + msg181203

stage: resolved
2013-02-02 19:08:24atagarsetmessages: + msg181202
2013-02-02 18:55:57skrahsetmessages: + msg181199
2013-02-02 18:43:21skrahsetnosy: + skrah, doko
messages: + msg181195
2013-02-02 18:03:34atagarcreate