[New-bugs-announce] [issue4367] Patch for segmentation fault in ast_for_atom

Giuseppe Ottaviano report at bugs.python.org
Thu Nov 20 18:36:07 CET 2008


New submission from Giuseppe Ottaviano <giuott at gmail.com>:

Hi all,
trying to compile Python 2.6 I got a segmentation fault while
byte-compiling the modules. 

The segmentation fault happened in ast_for_atom, parsing an Unicode
entity. I found out that another problem prevented unicodedata to be
imported, so unicode_decode raised an exception. I think the problem is
in the following lines:

            if (PyErr_ExceptionMatches(PyExc_UnicodeError)){
                PyObject *type, *value, *tback, *errstr;
                PyErr_Fetch(&type, &value, &tback);
                errstr = ((PyUnicodeErrorObject *)value)->reason;

I'm not an expert of CPython internals, but the exception is raised with
PyErr_SetString, so value is a PyStringObject, and that cast is invalid.
Changing the last line to 

                errstr = value;

everything works. 

The patch is attached.

----------
files: ast.patch
keywords: patch
messages: 76119
nosy: ot
severity: normal
status: open
title: Patch for segmentation fault in ast_for_atom
type: crash
versions: Python 2.6
Added file: http://bugs.python.org/file12075/ast.patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue4367>
_______________________________________


More information about the New-bugs-announce mailing list