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.

Title: segfault calling sys.excepthook with non-Exception argument
Type: crash Stage:
Components: Interpreter Core Versions: Python 3.0
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ajaksu2, benjamin.peterson, georg.brandl, pitrou, vstinner
Priority: release blocker Keywords: needs review, patch

Created on 2008-08-23 16:55 by ajaksu2, last changed 2022-04-11 14:56 by admin. This issue is now closed.

File name Uploaded Description Edit
print_exception.patch ajaksu2, 2008-08-23 16:55 Victor Stinner's patch for checking that value is an Exception (pythonrun.c)
use_unraiseable.patch benjamin.peterson, 2008-08-23 20:46
use_unraiseable_better.patch benjamin.peterson, 2008-08-24 14:35
Messages (7)
msg71807 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2008-08-23 16:55
Calling sys.excepthook(1,'1',1) crashes 3.0:

Python 3.0b3+ (py3k:65987, Aug 23 2008, 10:04:31)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import sys; sys.excepthook(1,'1',1)
Segmentation fault

gdb points at "PyException_GetTraceback  at Objects/exceptions.c:265
265         Py_XINCREF(base_self->traceback);"

This was found by Fusil and Victor Stinner (haypo) sent me a patch (see

Thanks bpeterson for triaging :)

PS: I also think that issue3643 should be targeted to 3.0, as the
underlying issue is the same, it would be an easy way to segfault
python3.0 and has a clean patch available.
msg71811 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-08-23 19:55
Patch looks good.
msg71812 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-08-23 20:08
Ok. Applied in r65998.
msg71815 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2008-08-23 20:36
The patch should probably used PyErr_Format() followed by
msg71816 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2008-08-23 20:46
Attaching new patch...
msg71833 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-08-24 08:37
PyErr_Format sets the new exception and returns NULL though.
msg72254 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-09-01 14:34
I think you need to clear the exception again before returning.
Date User Action Args
2022-04-11 14:56:38adminsetgithub: 47903
2008-09-01 14:34:48georg.brandlsetmessages: + msg72254
2008-08-24 14:35:17benjamin.petersonsetfiles: + use_unraiseable_better.patch
2008-08-24 09:14:45vstinnersetnosy: + vstinner
2008-08-24 08:37:48georg.brandlsetmessages: + msg71833
2008-08-23 20:46:11benjamin.petersonsetfiles: + use_unraiseable.patch
messages: + msg71816
2008-08-23 20:36:33pitrousetnosy: + pitrou
messages: + msg71815
2008-08-23 20:08:22benjamin.petersonsetstatus: open -> closed
nosy: + benjamin.peterson
resolution: fixed
messages: + msg71812
2008-08-23 19:55:08georg.brandlsetnosy: + georg.brandl
messages: + msg71811
2008-08-23 16:58:16benjamin.petersonsetpriority: release blocker
keywords: + needs review
2008-08-23 16:55:53ajaksu2create