Cycle debugging results in a runaway process that crashes the system
See original GitHub issue- VS Code version: 1.21.1
- Extension version (available under the Extensions sidebar): XXX
- OS and version: Antergos (Arch Linux based) kernel 4.14.32-1-lts
- Python version (& distribution if applicable, e.g. Anaconda): python3.6
- Type of virtual environment used (N/A | venv | virtualenv | conda | …): virtualenv
Actual behavior
itertools.cycle() returns an infinite sequence of items. When debugging, hovering the mouse over the cycle() object displays details about its items. VSCode will allocate memory ad infinitum and crash the entire system when it runs out of memory (in less than 2 second on my machine with 16GB or RAM).
Expected behavior
No crash occurs, maybe only some items in the iterator should be displayed? With a hardcoded limit of only a few items perhaps? Or just not expanded at all just to be safe.
Steps to reproduce:
import itertools
- Create an itertools.cycle() like so
mycycle = itertools.cycle((1,2,3))
- Start debugging
- After the cycle class has been instantiated and populated (e.g. from a list), hover the mouse cursor above its symbol
mycycle
- Click “items” to expand the list in the popup details view.
Logs
No logs, system hard locks, no way to recover but to cold reboot the system.
I don’t know TypeScript, but it looks like the problem is located around here maybe: https://github.com/DonJayamanne/pythonVSCode/blob/master/src/client/debugger/Main.ts#L637
Maybe cycles should be marked as not expandable?
Issue Analytics
- State:
- Created 5 years ago
- Comments:7 (3 by maintainers)
Hovering over a cycle object in debug mode doesn’t show any detail about it anymore (except its memory address), so I suppose it will prevent any potential crash that way from now on. Thanks.
@glubsy I believe we have fixed this issue. Please could you validate the fix in the latest development version of the extension. Instructions for installing the dev version can be found here https://github.com/Microsoft/vscode-python/blob/master/CONTRIBUTING.md#development-build
Please feel free to re-open the issue if it hasn’t been resolved.