classification
Title: _hotshot: invalid error control in logreader()
Type: crash Stage:
Components: Library (Lib) Versions: Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: amaury.forgeotdarc Nosy List: amaury.forgeotdarc, georg.brandl, vstinner
Priority: normal Keywords: patch

Created on 2008-09-24 10:02 by vstinner, last changed 2008-12-15 22:17 by amaury.forgeotdarc. This issue is now closed.

Files
File name Uploaded Description Edit
_hotshot_logreader2.patch vstinner, 2008-09-24 10:10 Fixed patch + unit test for this issue
Messages (8)
msg73700 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2008-09-24 10:02
Using Fusil the fuzzer, I found a "minor" bug in _hotshot module: it 
doesn't check correctly the errors in hotshot_logreader(). On error, 
an exception is raised (eg. by eof_error()) but the result is a 
pointer to a new allocated object instead of NULL.

Here is a patch to delete the new created object (using Py_DECREF) and 
return NULL. It uses an ugly goto, but goto is sometimes useful to 
avoid code duplication on error handling (eg. see Linux source code).

Example to reproduce the bug:
---
import _hotshot, gc
_hotshot.logreader(".")
gc.collect()
---
msg73701 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2008-09-24 10:10
Oops, my previous patch always raise an error even on valid file :-p

Here is a new patch with *an unit test* (yeah!).
msg73704 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-09-24 11:13
The patch is good to me. 
gotos are perfectly allowed for this purpose.

(to python committers: Should this kind of "minor" issues be fixed after
2.6rc2? This could as well wait until 2.6.1)
msg73726 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-09-24 16:25
Looks fine. Since it is minor, why not commit it now?
msg73727 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2008-09-24 16:26
@georg: give me a svn access and i will commit it ;-)
msg73729 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2008-09-24 16:30
Regardless of the smiley, I certainly wouldn't object if you requested
permissions on python-dev...
msg77641 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2008-12-11 23:16
> Regardless of the smiley, I certainly wouldn't object if you
> requested permissions on python-dev...

I still don't have an account and the issue is still open. 2.6(.1) and 
3.0 are released. The patch has been reviewed by amaury.forgeotdarc, 
so can the patch be applied?

The issue is still valid with python trunk:

$ ./python
Python 2.7a0 (trunk:67710M, Dec 11 2008, 23:57:18)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
>>> import _hotshot, gc
>>> _hotshot.logreader(".")
<_hotshot.LogReaderType object at 0xb7d936e0>
>>> gc.collect()
Exception EOFError: 'end of file with incomplete profile record' 
in 'garbage collection' ignored
Fatal Python error: unexpected exception during garbage collection
Abandon (core dumped)
msg77882 - (view) Author: Amaury Forgeot d'Arc (amaury.forgeotdarc) * (Python committer) Date: 2008-12-15 22:17
Fixed in r67797 (trunk) and r67801 (2.6)
hotshot was removed from py3k.
History
Date User Action Args
2008-12-15 22:17:04amaury.forgeotdarcsetstatus: open -> closed
resolution: accepted -> fixed
messages: + msg77882
2008-12-15 21:42:20amaury.forgeotdarcsetassignee: amaury.forgeotdarc
2008-12-11 23:16:05vstinnersetmessages: + msg77641
2008-09-24 16:30:09georg.brandlsetmessages: + msg73729
2008-09-24 16:26:46vstinnersetmessages: + msg73727
2008-09-24 16:25:51georg.brandlsetnosy: + georg.brandl
messages: + msg73726
2008-09-24 11:13:18amaury.forgeotdarcsetresolution: accepted
messages: + msg73704
nosy: + amaury.forgeotdarc
2008-09-24 10:10:13vstinnersetfiles: - _hotshot_logreader.patch
2008-09-24 10:10:07vstinnersetfiles: + _hotshot_logreader2.patch
messages: + msg73701
2008-09-24 10:02:27vstinnercreate