Closed 3921e517-b8ff-4a95-ba81-e08735eacad3 closed 11 years ago
I've found a very strange bug in python 3.3
It's taken me around an hour just to narrow it down to a small case where it happens.
I cannot for the life of me figure out the exact cause. It seems to have something to do with "yield from".
I've attached a case which reproduces this. Run python3.3 test.py, it should segfault on linux, "stopped responding" on windows.
Tested with OS: Linux Debian-60-squeeze-32-minimal 2.6.32-5-686-bigmem PY: Python 3.3.1rc1 (default, Mar 30 2013, 21:44:39)
OS: Windows 7 64 bit PY: Python 3.3.0 (v3.3.0:bd8afb90ebf2, Sep 29 2012, 10:55:48) [MSC v.1600 32 bit (Intel)] on win32
NOTES: If you get rid of "import logging" in generators.py, it only crashes if there's no __pycache__
The file contents so people dont have to download the zip:
generators.py: ---------------------------
def subgen():
yield
def other_gen(self):
move = yield from subgen()
game.py: ---------------------------
class Game(object):
def __init__(self):
self.gen = self.first_gen()
next(self.gen)
def first_gen(self):
while True:
from generators import \
other_gen
yield from other_gen(self)
test.py: ---------------------------
from game import Game
Game()
The crashing version has 'import logging' at the top of generators.py. I did not experience a crash when it was absent even if there was no __pycache__.
It also doesn't crash if the import is moved out of the body of first_gen.
FAULTHANDLER doesn't fair too well on this one, no real surprise :)
Fatal Python error: Segmentation fault
Current thread 0xb75856c0: zsh: segmentation fault PYTHONFAULTHANDLER=true ../python test.py
This is the patch. I'll have to think about whether there's a self-contained way to test this.
New changeset 35cb75b9d653 by Benjamin Peterson in branch '3.3': don't run frame if it has no stack (closes bpo-17669) http://hg.python.org/cpython/rev/35cb75b9d653
New changeset 0b2d4089180c by Benjamin Peterson in branch 'default': merge 3.3 (bpo-17669) http://hg.python.org/cpython/rev/0b2d4089180c
New changeset 516303f32bad by Benjamin Peterson in branch '3.3': add a test for issue bpo-17669 (closes bpo-18565) http://hg.python.org/cpython/rev/516303f32bad
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields: ```python assignee = 'https://github.com/benjaminp' closed_at =
created_at =
labels = ['interpreter-core', 'OS-windows', 'type-crash']
title = 'Segfault caused by weird combination of imports and yield from'
updated_at =
user = 'https://bugs.python.org/fhamand'
```
bugs.python.org fields:
```python
activity =
actor = 'pconnell'
assignee = 'benjamin.peterson'
closed = True
closed_date =
closer = 'python-dev'
components = ['Interpreter Core', 'Windows']
creation =
creator = 'fhamand'
dependencies = []
files = ['29744', '29748']
hgrepos = []
issue_num = 17669
keywords = ['patch']
message_count = 6.0
messages = ['186354', '186355', '186365', '186370', '186530', '193797']
nosy_count = 11.0
nosy_names = ['brett.cannon', 'vinay.sajip', 'ncoghlan', 'pitrou', 'benjamin.peterson', 'Arfrever', 'r.david.murray', 'python-dev', 'eric.snow', 'pconnell', 'fhamand']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = 'crash'
url = 'https://bugs.python.org/issue17669'
versions = ['Python 3.3', 'Python 3.4']
```