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: _lsprof.c:ptrace_enter_call assumes PyErr_* is clean
Type: Stage:
Components: Extension Modules Versions: Python 2.6
process
Status: closed Resolution: accepted
Dependencies: Superseder:
Assigned To: Nosy List: arigo, peaker
Priority: normal Keywords: patch

Created on 2007-06-09 08:04 by peaker, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
cProfile.patch peaker, 2007-06-09 08:04 A patch to the most recent svn
cProfile.patch peaker, 2007-06-09 08:30 Removed redundant PyErr_Clear (already done by PyErr_Fetch)
Messages (4)
msg52738 - (view) Author: Eyal Lotem (peaker) Date: 2007-06-09 08:04
_lsprof.c:ptrace_enter_call assumes PyErr_* has no errors.
It assumes this by feeling free to call functions that PyErr_Clear and overwrite PyErr.

This assumption is broken when throwing into a generator. In that case gen_send_ex(.., 1) calls the ptrace_enter_call with an exception already set.

This assumption causes two bugs:
A. The exception thrown into the generator is overwritten and lost. Later it was also cleared.
B. gen_send_ex(..) still returns error-indication, but since the exception was cleared, you get a SystemError (error indication returned but no exception was set).

To fix this, ptrace_enter_call now saves/restores the current PyErr.

The attached patch was applied on the newest trunk svn. I guess it should be applicable without problems on the 2.5 bugfix branch as well.
msg52739 - (view) Author: Eyal Lotem (peaker) Date: 2007-06-09 08:24
It seems that bug #1733757 encountered the same bug. See comments on that bug.
msg52740 - (view) Author: Eyal Lotem (peaker) Date: 2007-06-09 08:30
File Added: cProfile.patch
msg55681 - (view) Author: Armin Rigo (arigo) * (Python committer) Date: 2007-09-06 08:36
Thanks for the patch.  Checked in:

 * r58004  (trunk)
 * r58005  (release25-maint)
History
Date User Action Args
2022-04-11 14:56:24adminsetgithub: 45071
2007-09-06 08:36:01arigosetstatus: open -> closed
resolution: accepted
messages: + msg55681
nosy: + arigo
2007-06-09 08:04:30peakercreate