Movatterモバイル変換


[0]ホーム

URL:


homepage

Issue3274

This issue trackerhas been migrated toGitHub, and is currentlyread-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title:Py_CLEAR(tmp) seg faults
Type:crashStage:
Components:Interpreter CoreVersions:Python 3.0, Python 2.5
process
Status:closedResolution:fixed
Dependencies:Superseder:
Assigned To:Nosy List: alexandre.vassalotti, ncoghlan, stutzbach
Priority:normalKeywords:

Created on2008-07-03 17:54 bystutzbach, last changed2022-04-11 14:56 byadmin. This issue is nowclosed.

Messages (4)
msg69213 -(view)Author: Daniel Stutzbach (stutzbach)(Python committer)Date: 2008-07-03 17:54
I'm writing a C extension module and discovered that Py_CLEAR() causes acrash if the programmer happened to name their variable "tmp".  ThePy_CLEAR() macro internally uses the name "tmp" in a new scope, hidingthe callers "tmp", and calling Py_DECREF() on an essentially random bitof memory.I suggest changing Py_CLEAR() to use something a little less common than"tmp".  Perhaps "_py_tmp".For easy reference, here's how Py_CLEAR() is defined now:#define Py_CLEAR(op)\        do {                            \                if (op) {\                        PyObject *tmp = (PyObject *)(op);\                        (op) = NULL;\                        Py_DECREF(tmp);\                }\        } while (0)
msg69498 -(view)Author: Alyssa Coghlan (ncoghlan)*(Python committer)Date: 2008-07-10 10:11
A better option may be to append _tmp to the passed in token:#define Py_CLEAR(op)\        do {                            \                if (op) {\                        PyObject *op##_tmp = (PyObject *)(op);\                        (op) = NULL;\                        Py_DECREF(op##_tmp);\                }\        } while (0)
msg69500 -(view)Author: Daniel Stutzbach (stutzbach)(Python committer)Date: 2008-07-10 12:24
Appending _tmp is a good idea, but it won't work when the parameterisn't a simple symbol.  For example, there's a line in cPickle.c likethis: Py_CLEAR(*p).
msg69621 -(view)Author: Alexandre Vassalotti (alexandre.vassalotti)*(Python committer)Date: 2008-07-13 20:43
Committed the fixr64927. Thanks.
History
DateUserActionArgs
2022-04-11 14:56:36adminsetgithub: 47524
2008-07-13 20:43:46alexandre.vassalottisetstatus: open -> closed
resolution: fixed
messages: +msg69621
nosy: +alexandre.vassalotti
2008-07-10 12:24:55stutzbachsetmessages: +msg69500
2008-07-10 10:11:07ncoghlansetnosy: +ncoghlan
messages: +msg69498
2008-07-03 17:54:08stutzbachcreate
Supported byThe Python Software Foundation,
Powered byRoundup
Copyright © 1990-2022,Python Software Foundation
Legal Statements

[8]ページ先頭

©2009-2026 Movatter.jp