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: IDLE hangs when selecting Stack View with debug active
Type: crash Stage: resolved
Components: IDLE Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Andrew.Harrington, ZackerySpytz, miss-islington, taleinat, terry.reedy
Priority: normal Keywords: patch

Created on 2015-02-27 21:25 by Andrew.Harrington, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
goodScope.py Andrew.Harrington, 2015-02-27 21:25 simple demo file from my tutorial
Pull Requests
URL Status Linked Edit
PR 17163 merged ZackerySpytz, 2019-11-15 06:42
PR 24365 merged miss-islington, 2021-01-28 23:14
PR 24366 merged miss-islington, 2021-01-28 23:14
Messages (12)
msg236842 - (view) Author: Andrew Harrington (Andrew.Harrington) * Date: 2015-02-27 21:25
1. In idle 3.4.3, OSX 10.10, active state Tk 8.5.17, starting data:

Python 3.4.3 (v3.4.3:9b73f1c3e601, Feb 23 2015, 02:52:03) 
[GCC 4.2.1 (Apple Inc. build 5666) (dot 3)] on darwin

2. start debugger, open very simple demo file, attached:


3. run, so debugger starts, step into main()

4. In debug menu, select Stack Viewer

5. hangs (apple swirling color wheel forever). Same error is repeatable.
msg236848 - (view) Author: Ned Deily (ned.deily) * (Python committer) Date: 2015-02-27 21:55
Thanks for the detailed report.  The problem is more general as it is reproducible on Linux X11-based IDLEs as well.
msg236853 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2015-02-27 22:49
Verified on Windows whenever the debugger is active, meaning that a program is running.  (Debug On just means that it will become active when code is run.) No stepping is needed; debugger can be pointing to the inital docstring line.  For me also, Idle stops and has to be externally closed, as opposed to totally disappearing by itself.

The doc for Stack Viewer says "Show the stack traceback of the last exception".   Example:

>>> 1/0
Traceback (most recent call last):
  File "<pyshell#0>", line 1, in <module>
    1/0
ZeroDivisionError: division by zero
>>> 

Selecting Stack Viewer pops up a viewer box.  This still works after 
[DEBUG ON]
>>>
turns the debugger on but inactive.  Entering anything at the prompt disables viewing the 'last' exception, contrary to my understanding of the short doc.  So I might add '(if no other code has been run)' to the doc.

Selecting Stack Viewer while a program is running (sleeping in this next example)

>>> import time; time.sleep(10); 1/0

brings up a box after the exception is printed.  So 'last exception' can actually be 'next exception'.  But in this case, the user process is left 'running' and no '>>> ' prompt appears, and one must Shell -> Restart to do anything further.  This is not good behavior.

When one selects Debug -> Debugger while user code is running, Idle brings up a message box "Don't debug now: You can only toggle the debugger when idle".  I think Debug -> Stack Viewer should be similarly disabled, though perhaps graying out the menu entry might be better. It could also be grayed out when there the 'last exception' cannot be viewed because other code has been run.  Stack Viewer should definitely be ignored when the debugger is active, and I see no need to let people select it *before* an exception occurs and the prompt is displayed.  The next menu entry, Auto-open Stack Viewer, takes care of opening upon future exceptions.
msg236864 - (view) Author: Andrew Harrington (Andrew.Harrington) * Date: 2015-02-28 01:39
I was using this without looking at documentation, as a newbies would.
Graying and disabling until after an exception makes sense, but even the
menu item name is misleading:  any time the program is running there is a
stack that you might want to view.   Better labels in the menu than "Stack
Viewer"  would be "stack trace" or "stack after exception" (maybe too long)
or "stack after crash".

On Fri, Feb 27, 2015 at 4:49 PM, Terry J. Reedy <report@bugs.python.org>
wrote:

>
> Terry J. Reedy added the comment:
>
> Verified on Windows whenever the debugger is active, meaning that a
> program is running.  (Debug On just means that it will become active when
> code is run.) No stepping is needed; debugger can be pointing to the inital
> docstring line.  For me also, Idle stops and has to be externally closed,
> as opposed to totally disappearing by itself.
>
> The doc for Stack Viewer says "Show the stack traceback of the last
> exception".   Example:
>
> >>> 1/0
> Traceback (most recent call last):
>   File "<pyshell#0>", line 1, in <module>
>     1/0
> ZeroDivisionError: division by zero
> >>>
>
> Selecting Stack Viewer pops up a viewer box.  This still works after
> [DEBUG ON]
> >>>
> turns the debugger on but inactive.  Entering anything at the prompt
> disables viewing the 'last' exception, contrary to my understanding of the
> short doc.  So I might add '(if no other code has been run)' to the doc.
>
> Selecting Stack Viewer while a program is running (sleeping in this next
> example)
>
> >>> import time; time.sleep(10); 1/0
>
> brings up a box after the exception is printed.  So 'last exception' can
> actually be 'next exception'.  But in this case, the user process is left
> 'running' and no '>>> ' prompt appears, and one must Shell -> Restart to do
> anything further.  This is not good behavior.
>
> When one selects Debug -> Debugger while user code is running, Idle brings
> up a message box "Don't debug now: You can only toggle the debugger when
> idle".  I think Debug -> Stack Viewer should be similarly disabled, though
> perhaps graying out the menu entry might be better. It could also be grayed
> out when there the 'last exception' cannot be viewed because other code has
> been run.  Stack Viewer should definitely be ignored when the debugger is
> active, and I see no need to let people select it *before* an exception
> occurs and the prompt is displayed.  The next menu entry, Auto-open Stack
> Viewer, takes care of opening upon future exceptions.
>
> ----------
> stage:  -> needs patch
> title: IDLE hangs with debug on and stack viewer -> IDLE hangs when
> selecting Stack View with debug active
>
> _______________________________________
> Python tracker <report@bugs.python.org>
> <http://bugs.python.org/issue23544>
> _______________________________________
>

-- 
Dr. Andrew N. Harrington
  Computer Science Department
  Graduate Program Director gpd@cs.luc.edu
  Loyola University Chicago
  529 Lewis Tower, 111 E. Pearson St. (Downtown)
  104 Loyola Hall, 1032 W. Sheridan Road (Rogers Park)
http://www.cs.luc.edu/~anh
Phone: 312-915-7982
Fax:    312-915-7998
aharrin@luc.edu (as professor, not gpd role)
msg236905 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2015-02-28 19:44
I agree that 'Stack Viewer' does not explain what this does, which is to gives a more detail view of the stack and name bindings after an exception.  The doc entry does not either.  I will consider 'Stack Trace' or maybe 'Exception Review'.  I think a popup message is needed too.

PS. When replying to email, please snip the messages you are responding to (except possible for a line or two).  That message sits above yours when viewed on the web page.
msg320686 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2018-06-28 21:09
This crashes or hangs the user execution process, but not the IDLE process.  So Shell => 'Restart Shell   cntl-F6' still works.
msg356652 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2019-11-15 08:30
Taking this in a different direction, perhaps we can make the stack viewer always work, regardless of whether it is immediately after an exception? Visually inspecting the stack can be useful not just for understanding error cases.
msg356653 - (view) Author: Tal Einat (taleinat) * (Python committer) Date: 2019-11-15 08:32
> perhaps we can make the stack viewer always work

Well, perhaps not "always", e.g. probably not while user code is running.
msg385889 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-01-28 23:13
New changeset 23a567c11ca36eedde0e119443c85cc16075deaf by Zackery Spytz in branch 'master':
bpo-23544: Disable IDLE Stack Viewer when running user code (GH-17163)
https://github.com/python/cpython/commit/23a567c11ca36eedde0e119443c85cc16075deaf
msg385890 - (view) Author: miss-islington (miss-islington) Date: 2021-01-28 23:38
New changeset 6d87dec5818667168cc7e4ad972dde8aeec6d900 by Miss Islington (bot) in branch '3.9':
bpo-23544: Disable IDLE Stack Viewer when running user code (GH-17163)
https://github.com/python/cpython/commit/6d87dec5818667168cc7e4ad972dde8aeec6d900
msg385892 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-01-29 01:48
New changeset 901a9834420e516c07d6cad356d2be481db6d8d1 by Miss Islington (bot) in branch '3.8':
bpo-23544: Disable IDLE Stack Viewer when running user code (GH-17163) (#24366)
https://github.com/python/cpython/commit/901a9834420e516c07d6cad356d2be481db6d8d1
msg385893 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2021-01-29 01:49
Tal, I agree with you.

The debugger is an execution controller with an optional current-frame viewer updated whenever execution is paused.  It displays both name and value.  I believe a current PR addresses the issue of value representations being indefinitely long and possibly overflowing the space allotted.

The stack viewer can view any frame on the stack, but only after an exception.  At least currently, on Windows, it omits value names. And there are other issues (#24790).  The debugger viewer and stack viewer should be combined with the best features of each (new issues).

In the meanwhile, I finished PR and merged.
History
Date User Action Args
2022-04-11 14:58:13adminsetgithub: 67732
2021-01-29 01:50:04terry.reedysetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2021-01-29 01:49:46terry.reedysetmessages: + msg385893
2021-01-29 01:48:12terry.reedysetmessages: + msg385892
2021-01-28 23:38:54miss-islingtonsetmessages: + msg385890
2021-01-28 23:14:10miss-islingtonsetpull_requests: + pull_request23189
2021-01-28 23:14:02miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request23188
2021-01-28 23:13:54terry.reedysetmessages: + msg385889
2019-11-15 08:32:13taleinatsetmessages: + msg356653
2019-11-15 08:30:33taleinatsetnosy: + taleinat
messages: + msg356652
2019-11-15 06:52:34ZackerySpytzsetnosy: + ZackerySpytz
2019-11-15 06:42:51ZackerySpytzsetkeywords: + patch
stage: needs patch -> patch review
pull_requests: + pull_request16673
2019-09-19 18:46:17terry.reedysetnosy: - kbk, roger.serwy

versions: + Python 3.9, - Python 2.7, Python 3.6, Python 3.7, Python 3.8
2018-06-28 21:09:47terry.reedysetmessages: + msg320686
versions: + Python 3.6, Python 3.7, Python 3.8, - Python 3.4, Python 3.5
2015-02-28 19:44:52terry.reedysetmessages: + msg236905
2015-02-28 01:39:20Andrew.Harringtonsetmessages: + msg236864
2015-02-27 22:49:04terry.reedysettitle: IDLE hangs with debug on and stack viewer -> IDLE hangs when selecting Stack View with debug active
messages: + msg236853
stage: needs patch
2015-02-27 21:56:09ned.deilysetnosy: - ned.deily
2015-02-27 21:55:25ned.deilysettitle: Idle stacker viewer crash OSX -> IDLE hangs with debug on and stack viewer
nosy: - ronaldoussoren

messages: + msg236848

versions: + Python 2.7, Python 3.5
components: - macOS
2015-02-27 21:31:07SilentGhostsetnosy: + roger.serwy, ned.deily, terry.reedy, kbk, ronaldoussoren
components: + macOS
2015-02-27 21:25:35Andrew.Harringtoncreate