➜

This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
标题: PyNode_Compile() crashes in Python 3.8.
类型: crash Stage: resolved
Components: Versions: Python 3.8
process
状态: closed Resolution: fixed
Dependencies: 后续:
分配给: gvanrossum 抄送列表: grahamd, gvanrossum, lukasz.langa, petr.viktorin, vstinner
优先级: release blocker 关键字: patch

Created on 2019-05-28 01:52 by grahamd, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 13634 merged gvanrossum, 2019-05-28 18:17
Messages (6)
msg343727 - (view) Author: Graham Dumpleton (grahamd) 日期: 2019-05-28 01:52
The code:

#include <Python.h>

int
main(int argc, char *argv[])
{
    FILE *fp = NULL;
    PyObject *co = NULL;
    struct _node *n = NULL;
    const char * filename = "/dev/null";

    Py_Initialize();

    fprintf(stderr, "START\n");

    fp = fopen(filename, "r");

    fprintf(stderr, "CALL PyParser_SimpleParseFile()\n");

    n = PyParser_SimpleParseFile(fp, filename, Py_file_input);

    fprintf(stderr, "CALL PyNode_Compile()\n");

    co = (PyObject *)PyNode_Compile(n, filename);

    fprintf(stderr, "DONE\n");

    Py_Finalize();

    return 0;
}

has worked fine since Python 2.3 (and maybe earlier) through Python 3.7, but now crashes in Python 3.8.

It crashes in PyNode_Compile().

START
CALL PyParser_SimpleParseFile()
CALL PyNode_Compile()
Segmentation fault: 11

Although it is part of the public interface of compile.h, the PyNode_Compile() seems never to actually be called anywhere in Python itself, and perhaps isn't even covered by tests. So if Python 3.8 internal changes mean this function implementation needs to be changed, that fact may have been missed.
msg343728 - (view) Author: Graham Dumpleton (grahamd) 日期: 2019-05-28 02:10
FWIW, this was occurring on macOS. Not been able to test on other platforms.
msg343750 - (view) Author: Petr Viktorin (petr.viktorin) * (Python committer) 日期: 2019-05-28 08:42
Looks like this is caused by: https://github.com/python/cpython/pull/12086/files#diff-4d35cf8992b795c5e97e9c8b6167cb34R787

PyAST_FromNodeObject doesn't ignore flags any more, so when PyNode_Compile passes NULL flags, it crashes.

(This is unfamiliar code for me; I won't have time to fix & test properly this week.)
msg343761 - (view) Author: STINNER Victor (vstinner) * (Python committer) 日期: 2019-05-28 10:33
I mark this issue as a release blocker.
msg343811 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) 日期: 2019-05-28 18:03
OK, I'll look into this.
msg343834 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) 日期: 2019-05-28 23:45
New changeset 77f0ed7a42606d03ebfe48ab152caf0d796d6540 by Guido van Rossum in branch 'master':
bpo-37072: Fix crash in PyAST_FromNodeObject() when flags is NULL (#13634)
https://github.com/python/cpython/commit/77f0ed7a42606d03ebfe48ab152caf0d796d6540
历史
日期 用户 动作 参数
2022-04-11 14:59:15admin修改github: 81253
2019-05-28 23:45:50gvanrossum修改状态: open -> closed
resolution: fixed
stage: patch review -> resolved
2019-05-28 23:45:01gvanrossum修改消息: + msg343834
2019-05-28 18:17:10gvanrossum修改keywords: + patch
stage: patch review
pull_requests: + pull_request13534
2019-05-28 18:03:33gvanrossum修改assignee: gvanrossum

消息: + msg343811
抄送: + gvanrossum
2019-05-28 10:33:11vstinner修改优先级: normal -> release blocker
抄送: + vstinner, lukasz.langa
消息: + msg343761

2019-05-28 08:42:07petr.viktorin修改抄送: + petr.viktorin
消息: + msg343750
2019-05-28 02:10:44grahamd修改type: crash
消息: + msg343728
2019-05-28 01:52:54grahamd创建