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
Title: Extra DECREF on syntax errors
Type: Stage:
Components: Versions: Python 3.0
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: pitrou Nosy List: amaury.forgeotdarc, barry, benjamin.peterson, georg.brandl, pitrou
Priority: release blocker Keywords: needs review, patch

Created on 2008-08-24 20:20 by amaury.forgeotdarc, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
missing-incref.patch amaury.forgeotdarc, 2008-08-25 09:35
Messages (6)
msg71859 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-08-24 20:20
The following output is very suspect: the total number of references
decreases!

Python 3.0b3+ (py3k, Aug 24 2008, 21:56:40) [MSC v.1500 32 bit (Intel)]
on win32
Type "help", "copyright", "credits" or "license" for more information.
>>> f(1=1)
  File "<stdin>", line 1
SyntaxError: keyword can't be an expression
[42055 refs]
>>> f(1=1)
  File "<stdin>", line 1
SyntaxError: keyword can't be an expression
[42054 refs]
>>> f(1=1)
  File "<stdin>", line 1
SyntaxError: keyword can't be an expression
[42053 refs]
>>> f(1=1)
  File "<stdin>", line 1
SyntaxError: keyword can't be an expression
[42052 refs]
>>> f(1=1)
  File "<stdin>", line 1
SyntaxError: keyword can't be an expression
[42051 refs]
>>> f(1=1)
  File "<stdin>", line 1
SyntaxError: keyword can't be an expression
[42050 refs]

After several hundred statements, I got:
Fatal Python error: deallocating None
msg71896 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-08-24 22:32
The culprit is Python/pythonrun.c:1245:

    tb = tb ? tb : Py_None;

Py_None needs to be INCREF'd in the else case.
msg71914 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-08-25 09:35
Agreed. PyErr_ExceptionMatches returns owned references, so the tb
variable has to remain an owned reference.
Patch attached, please review.
msg71920 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-08-25 13:30
The patch looks fine to me.
msg71973 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2008-08-26 09:11
Benjamin's reviewed it, so please commit it.  Is there a test for this
crasher?
msg72000 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-08-26 22:03
Committed in r66041. Thanks everyone.
History
Date User Action Args
2022-04-11 14:56:38adminsetgithub: 47913
2008-08-26 22:03:27pitrousetstatus: open -> closed
resolution: accepted -> fixed
messages: + msg72000
2008-08-26 09:11:43barrysetnosy: + barry
resolution: accepted
messages: + msg71973
2008-08-26 09:10:02barrysetpriority: deferred blocker -> release blocker
2008-08-25 13:30:56benjamin.petersonsetnosy: + benjamin.peterson
messages: + msg71920
2008-08-25 09:35:18amaury.forgeotdarcsetkeywords: + needs review, patch
files: + missing-incref.patch
messages: + msg71914
2008-08-24 22:32:28georg.brandlsetassignee: pitrou
messages: + msg71896
nosy: + georg.brandl
2008-08-24 20:23:11pitrousetnosy: + pitrou
2008-08-24 20:20:29amaury.forgeotdarccreate