New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
frame.f_locals causes segfault on Python >=3.4.1 #66096
Comments
It seems that frame.f_locals causes segfault on Python >=3.4.1 $ uname -a
Linux ashrose 3.2.0-61-generic #93-Ubuntu SMP Fri May 2 21:31:50 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux
$ ls
test1.py
$ cat test1.py
import unittest class TestCallable(unittest.TestCase):
def test_callable(self):
try:
with self.assertRaises(IndexError):
def raise_error(): raise TypeError
(lambda: raise_error())()
except TypeError as exception:
exception.__traceback__.tb_next.tb_frame.f_locals
$ python3.4.1 -m unittest
Segmentation fault
$ python3.4.0 -m unittest
. Ran 1 test in 0.001s OK OK ... (gdb) run -m unittest Program received signal SIGSEGV, Segmentation fault. |
6ab3193e890e exposes the issue. |
Following patch seems to fix it, but I have to cook a proper test: diff --git a/Objects/frameobject.c b/Objects/frameobject.c
--- a/Objects/frameobject.c
+++ b/Objects/frameobject.c
@@ -786,7 +786,7 @@ map_to_dict(PyObject *map, Py_ssize_t nm
PyObject *key = PyTuple_GET_ITEM(map, j);
PyObject *value = values[j];
assert(PyUnicode_Check(key));
- if (deref) {
+ if (deref && value != NULL) {
assert(PyCell_Check(value));
value = PyCell_GET(value);
} |
Thanks, pitrou. Your patch seems ok to me. $ python3.4.1_with_patch -m unittest
. Ran 1 test in 0.001s It seems that this issue is same as https://bitbucket.org/hpk42/pytest/issue/528/test-causes-segfault . |
Here is a patch with tests. |
New changeset 758468cdf72c by Antoine Pitrou in branch '3.4': New changeset bd6515070f9c by Antoine Pitrou in branch 'default': |
Patch committed. Thank you for reporting this issue! |
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:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: