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: hotshot start / stop stats bug
Type: behavior Stage: test needed
Components: Library (Lib) Versions: Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: ajaksu2, alecf, aminusfu, barry, fdrake, georg.brandl, glchapman
Priority: low Keywords:

Created on 2004-08-31 18:06 by barry, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
hotshotbug.py barry, 2004-08-31 18:06
Messages (8)
msg22294 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2004-08-31 18:06
Hotshot has a bug that manifests when using start/stop
instead of run(), however it appears to only occur in
the interactive interpreter or in an embedded application.

If you run the attached program like "python
hotshotbug.py" it works just fine.  However, if you
start an interactive session and paste each line one by
one into the shell, you get the following exception:

Traceback (most recent call last):
  File "<stdin>", line 1, in ?
  File "/usr/local/lib/python2.3/hotshot/stats.py",
line 12, in load
    return StatsLoader(filename).load()
  File "/usr/local/lib/python2.3/hotshot/stats.py",
line 29, in load
    for event in log:
  File "/usr/local/lib/python2.3/hotshot/log.py", line
110, in next
    return what, self._pop(), tdelta
IndexError: pop from empty list

We discovered this when trying to profile an embedded
application which doesn't have a single entrypoint
suitable for run().  Unfortunately, I can't provide
that application, but it shouldn't matter, since the
interpreter crash is the same.
msg22295 - (view) Author: Barry A. Warsaw (barry) * (Python committer) Date: 2004-09-27 14:42
Logged In: YES 
user_id=12800

Could this be related to 900092?
msg22296 - (view) Author: Robert Brewer (aminusfu) Date: 2004-10-05 17:45
Logged In: YES 
user_id=967320

I get the same traceback even when not running
interactively. I can provide .prof files if needed.

fumanchu@amor.org
msg22297 - (view) Author: Greg Chapman (glchapman) Date: 2004-11-09 03:26
Logged In: YES 
user_id=86307

Not sure about the embedded application, but I believe the
problem with the interactive interpreter is that you're
executing a code snippet ("p.start()") which calls the
function to enable the profiler, and then does a return from
PyEval_EvalFrame.  This means the first event the profiler
sees will be the return, without having previosly seen a
call (since when PyEval_EvalFrame was entered, profiling was
not yet started).  The LogReader class assumes that a return
event must have been preceeded by a corresponding call event
so that it can pop the previously pushed information.  You
can get the same crash with a simple:

>>> p.start()
>>> p.stop()

and then try to load the stats.

By the way, with Python2.4b1, the example does not crash
when executed non-interactively from the command line (at
least on my Windows XP system).
msg22298 - (view) Author: Alec Flett (alecf) Date: 2005-01-11 23:05
Logged In: YES 
user_id=21804

So does this mean there is no decent way to use start() or
stop() if they are not called within the same stackframe? 

I've noticed this by trying to analyze prof files with
external python scripts - i.e. I generate the profile in one
program, and try to open it in another for analysis. Its the
2nd program that tries to open it that gets the crash.
msg86593 - (view) Author: Daniel Diniz (ajaksu2) * (Python triager) Date: 2009-04-26 02:26
Confirmed on trunk (interactive session only), might be considered a
historical limitation by now :)
msg112208 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-07-31 21:15
#1375 has a patch.
msg112210 - (view) Author: Georg Brandl (georg.brandl) * (Python committer) Date: 2010-07-31 21:22
Fixed in r83365 with patch from #1375.
History
Date User Action Args
2022-04-11 14:56:06adminsetgithub: 40849
2010-07-31 21:22:51georg.brandlsetstatus: open -> closed
resolution: fixed
messages: + msg112210

versions: + Python 2.7, - Python 2.6
2010-07-31 21:15:58georg.brandlsetnosy: + georg.brandl
messages: + msg112208
2010-07-31 21:15:27georg.brandllinkissue1375 superseder
2009-04-26 02:26:35ajaksu2setpriority: normal -> low

type: behavior
versions: + Python 2.6, - Python 2.3
nosy: + ajaksu2

messages: + msg86593
stage: test needed
2008-12-04 15:34:34fdrakesetassignee: fdrake ->
2004-08-31 18:06:40barrycreate