-
-
Notifications
You must be signed in to change notification settings - Fork 31.6k
IDLE - shell becomes unresponsive if debugger windows is closed while active. #59553
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
The IDLE shell does not respond to commands if the debugger window is closed by clicking "X". This is due to PyShell's "executing" flag not being reset. Steps to reproduce:
The shell is no longer responsive to new commands. Selecting "Restart Shell" does not fix the problem either. |
Attached is a patch against 3.4 to solve the issue. The debugger was originally written for running IDLE without a subprocess. As a result, calls to idb.run() from Debugger.py would block until completed. If .interacting == 1 then clicking "X" would not close the debugger window. Once the debugger finishes, the .interacting flag would reset to 0, which then allows for the Debugger.close() method to destroy the debugger window. Clicking "Quit" is one way to have the debugger finish. When running *with* a subprocess, the idb.run() returns immediately, since it is using the IdbProxy object instead. As a consequence, the .interacting flag is also reset to 0 immediately despite the debugger still being active. Thus, clicking "X" would allow the debugger to close without properly stopping the debugger via clicking "Quit". A useful side-effect of the interactive debugger being active is that the PyShell.executing flag is set to true. When the debugger stops, the call to PyShell.endexecuting() from poll_subprocess() resets the .executing flag. The patch checks if PyShell's executing is true in order to prevent the Debugger Window from being closed by clicking "X". This makes the behavior is consistent with running the IDLE debugger without a subprocess. When running IDLE without a subprocess is fully removed (see bpo-16123), then maintaining the Debugger code will become simpler. Until then, testing against both code paths is necessary. |
While trying to address bpo-15347, I discovered one too many corner cases where the debugger breaks IDLE. The stable_idle_debugger.diff against 3.4 contains necessary changes to make IDLE more reliable while debugging. Since the IDLE debugger is not documented these changes should not be controversial. Here are all the cases the patch fixes:
The patch creates the following behavior:
I tested these issues and solutions on Linux. Can someone review the patch for Windows and Mac? |
Is it possible to make the X button quit the debugger if enabled? |
Clicking "X" while the debugger is enabled, but not actively debugging a program, will close the debugger window. |
What's the intended behavior? stop debugging and quit the program? stop debugging and continue freerunning? I'm using 3.3, can you make the patch stop debugging the active running program when you click the X? |
If the debugger is active, then clicking "X" will flash the "Quit" button. You must click the quit button first before closing the debugger window. |
Then frigging change it! |
Closing the active debugger with "X" creates a problem with references and callbacks. I encountered too many corner cases where I could not implement that behavior simply. |
But of course, you are more than welcomed to try to submit a patch yourself. Just make sure that those corner cases I described earlier are handled reasonable when running IDLE with and without a subprocess. |
I have never used the debugger, but I verified the bug. While something was 'hung', the debugger would not restart because something was 'busy'. I also verified that clicking [quit] first and then [x] works. I will try to test the second patch sometime. Jimbo, the first priority is to fix crashes and hangs. We control the response to buttons we add, but the [x] close button involves the gui and operating system. So working with it can be trickier than it seems it ought to be. |
bpo-24455 is probably related. |
"not responsive to new commands" means that a statements can be typed but <Enter> is ignored and no execution takes place. |
The patch for bpo-24455 replaced root.mainloop,.quit with tcl vwait, set as the suspend/resume mechanism for Debugger.interation. After this, closing the shell as described in bpo-15347, or the debugger with [x] as described here, on my Windows 10 machine, resulted in File "F:\Python\dev\34\lib\idlelib\Debugger.py", line 20, in user_line instead of a hang. This is an improvement as the Exception can be caught and ignored. People testing of other systems did not report this. With TclError caught, closing the debugger with [x] then produced File "F:\Python\dev\34\lib\idlelib\Debugger.py", line 21, in user_line I applied the patch with Runtime also caught and ignored. The exceptions did not occur when [Quit] was pressed first. So I think [x] should do whatever Quit does before closing. |
(I was wrong about seeing the exception when closing the shell.) A major difference between [Quit] and [x] is that [Quit] stops the running program whereas [x] closes the visible gui but leaves the program to run through to the end, as though the [go] button were pressed. I added 'as e' and 'print(e)' to the try except and there are multiple RuntimeErrors, 1 per line traced by [step], including IDLE code for input() and print() calls, with [x], but none with [quit] first. The TclError only occurs in 3.4.3, not in 2.7.10. The string 'gui_adapter' comes from RemoteDebugger.py, line 28. Replacing self.abort_loop with self.quit (which calls abort_loop) eliminates the Runtime exceptions, as the backend debugger in the user process is stopped before the idle process frontend gui disappears. However, self.idb.set_quit (within self.quit) raises |
New changeset 427ad0ede016 by Terry Jan Reedy in branch '2.7': New changeset 4eae64a9cd26 by Terry Jan Reedy in branch '3.4': |
I don't like the idea of [x] flashing quit instead of closing. This patch, on top of the one for bpo-24455, may not be perfect, but the two are definite improvements. Unless I see something critically bad first, I want them in the upcoming releases. Mark claims that his second patch for bpo-15347 improves behavior for no subprocess. But that was without this patch. There is one situation not mentioned that I know is still glitchy. Debug a program with input(prompt). Run up to and including that line. While the program is waiting for input, close with [x]. The shell prints '[DEBUG OFF]' after the prompt and '>>> ' on the next line. But that is a fake prompt in that a statement entered will not be executed, but will be seen as the response to the pending input(). While there is a pending input (or any other blocked statement), the [Quit] button is disabled. The close method should detect this 'program executing' condition and ask whether to kill it, just as if one tries to close IDLE under the same condition. I am leaving this open, at least for now, at least for this. |
The input glitch mentioned above no longer exists, so closing. |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: