question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Stack overflow is crashing kernel

See original GitHub issue

Environment data

  • VS Code version: 1.69.2 (user setup)
  • Jupyter Extension version: v2022.7.1001951036
  • Python Extension version: v2022.10.1
  • OS and version: Windows 11 Home 21H2
  • Python and/or Anaconda version: 3.9.13
  • Type of virtual environment used: N/A
  • Jupyter server running: Local

Behaviour

I can reproduce the following error but the context is complex and I haven’t been able to isolate it well.

Canceled future for execute_request message before replies were done

The Kernel crashed while executing code in the the current cell or a previous cell. Please review the code in the cell(s) to identify a possible cause of the failure. Click [here](https://aka.ms/vscodeJupyterKernelCrash) for more info. View Jupyter [log](command:jupyter.viewOutput) for further details.

I’m working with a local package. To generate the error, I import the local package in a jupyter cell and call a class method with the wrong name, like this

import pkg
obj = pkg.Obj()
obj.wrong_method_name()

This should generate AttributeError: 'Obj' object has no attribute 'wrong_method_name' but instead it throws the error above.

I can generate the same problem using every release of the Jupyter Extension from the last three months (back to 2022.3.x).

This could be related to how I’ve structured my package, because the following generates the correct AttributeError for me:

import pandas as pd
df = pd.DataFrame()
df.wrong_name()

Logs

Output for Jupyter in the Output panel (ViewOutput, change the drop-down the upper-right of the Output panel to Jupyter)

info 12:25:35.125: Restart requested C:\DIRECTORY\FILE.IPYNB
info 12:25:35.125: Restart kernel execution
info 12:25:35.125: Cancel pending cells
info 12:25:35.125: Restarting undefined
info 12:25:35.125: Starting raw kernel 'Python 3.9.13' for interpreter c:\Users\user\AppData\Local\Microsoft\WindowsApps\python3.9.exe
info 12:25:35.142: Kernel launching with ports 9005,9006,9007,9008,9009. Start port is 9000
info 12:25:35.156: Process Execution: > ~\AppData\Local\Microsoft\WindowsApps\python3.9.exe -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
> ~\AppData\Local\Microsoft\WindowsApps\python3.9.exe -c "import ipykernel; print(ipykernel.__version__); print("5dc3a68c-e34e-4080-9c3e-2a532b2ccb4d"); print(ipykernel.__file__)"
info 12:25:35.162: Creating daemon process for c:\Users\user\AppData\Local\Microsoft\WindowsApps\python3.9.exe with env variables count 49
info 12:25:35.174: Process Execution: > ~\AppData\Local\Microsoft\WindowsApps\python3.9.exe -m vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.kernel_interrupt_daemon -v --ppid 18644
> ~\AppData\Local\Microsoft\WindowsApps\python3.9.exe -m vscode_datascience_helpers.daemon --daemon-module=vscode_datascience_helpers.kernel_interrupt_daemon -v --ppid 18644
info 12:25:35.319: get interrupthandle daemon
info 12:25:35.333: Process Execution: > ~\AppData\Local\Microsoft\WindowsApps\python3.9.exe -m ipykernel_launcher --ip=127.0.0.1 --stdin=9008 --control=9006 --hb=9005 --Session.signature_scheme="hmac-sha256" --Session.key=b"6dffa17b-5651-46d5-8142-47f401c60b6b" --shell=9007 --transport="tcp" --iopub=9009 --f=c:\Users\user\AppData\Roaming\jupyter\runtime\kernel-v2-18644B7boFiWyTzHr.json
> ~\AppData\Local\Microsoft\WindowsApps\python3.9.exe -m ipykernel_launcher --ip=127.0.0.1 --stdin=9008 --control=9006 --hb=9005 --Session.signature_scheme="hmac-sha256" --Session.key=b"6dffa17b-5651-46d5-8142-47f401c60b6b" --shell=9007 --transport="tcp" --iopub=9009 --f=c:\Users\user\AppData\Roaming\jupyter\runtime\kernel-v2-18644B7boFiWyTzHr.json
info 12:25:35.333: Process Execution: cwd: C:\DIRECTORY
cwd: C:\DIRECTORY
info 12:25:35.405: ipykernel version 6.6.0 for c:\Users\user\AppData\Local\Microsoft\WindowsApps\python3.9.exe
info 12:25:35.405: ipykernel location ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\ipykernel\__init__.py for c:\Users\user\AppData\Local\Microsoft\WindowsApps\python3.9.exe
warn 12:25:35.950: StdErr from Kernel Process C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\traitlets\traitlets.py:2202: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use 'hmac-sha256' instead of '"hmac-sha256"' if you require traitlets >=5.
  warn(
C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\traitlets\traitlets.py:2157: FutureWarning: Supporting extra quotes around Bytes is deprecated in traitlets 5.0. Use '6dffa17b-5651-46d5-8142-47f401c60b6b' instead of 'b"6dffa17b-5651-46d5-8142-47f401c60b6b"'.
  warn(

info 12:25:35.988: Kernel Output: NOTE: When using the `ipython kernel` entry point, Ctrl-C will not work.

To exit, you will have to explicitly quit this process, by either sending
"quit" from a client, or using Ctrl-\ in UNIX-like environments.

To read more about this, see https://github.com/ipython/ipython/issues/2049


To connect another client to this kernel, use:
    --existing c:\Users\user\AppData\Roaming\jupyter\runtime\kernel-v2-18644B7boFiWyTzHr.json

info 12:25:36.193: Got new session b59c6fde-e746-4daf-84a8-a8d61fcc6ed4
info 12:25:36.193: Started new restart session
info 12:25:36.194: Executing silently Code (idle) = import sys\nprint(sys.executable)
info 12:25:36.197: Widget Message: Received IPyWidgetMessages.IPyWidgets_onRestartKernel
info 12:25:36.198: Widget Message: Received IPyWidgets_kernelOptions in ScriptManager
info 12:25:36.198: Widget Message: Received IPyWidgetMessages.IPyWidgets_kernelOptions
info 12:25:36.592: Executing silently Code (completed) = import sys\nprint(sys.executable) with 1 output(s)
info 12:25:36.607: Process Execution: > ~\AppData\Local\Microsoft\WindowsApps\python3.9.exe -c "import sys;print(sys.executable)"
> ~\AppData\Local\Microsoft\WindowsApps\python3.9.exe -c "import sys;print(sys.executable)"
info 12:25:36.608: UpdateWorkingDirectoryAndPath in Kernel
info 12:25:36.608: Executing silently Code (idle) = import os\nimport sys\n%cd "C:\DIRECTORY"\nif o
info 12:25:36.624: Executing silently Code (completed) = import os\nimport sys\n%cd "C:\DIRECTORYh"\nif o with 1 output(s)
info 12:25:36.625: Waiting for idle on (kernel): b59c6fde-e746-4daf-84a8-a8d61fcc6ed4 -> idle
info 12:25:36.625: Finished waiting for idle on (kernel): b59c6fde-e746-4daf-84a8-a8d61fcc6ed4 -> idle
info 12:25:39.371: Execute Cell 5 C:\DIRECTORY\FILE.IPYNB
error 12:25:39.714: Disposing session as kernel process died ExitCode: 3221225725, Reason: C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\traitlets\traitlets.py:2202: FutureWarning: Supporting extra quotes around strings is deprecated in traitlets 5.0. You can use 'hmac-sha256' instead of '"hmac-sha256"' if you require traitlets >=5.
  warn(
C:\Users\user\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\traitlets\traitlets.py:2157: FutureWarning: Supporting extra quotes around Bytes is deprecated in traitlets 5.0. Use '6dffa17b-5651-46d5-8142-47f401c60b6b' instead of 'b"6dffa17b-5651-46d5-8142-47f401c60b6b"'.
  warn(

info 12:25:39.714: kill daemon
error 12:25:39.714: Raw kernel process exited code: 3221225725
error 12:25:39.715: Error in waiting for cell to complete [Error: Canceled future for execute_request message before replies were done
	at t.KernelShellFutureHandler.dispose (c:\Users\user\.vscode\extensions\ms-toolsai.jupyter-2022.7.1001951036\out\extension.node.js:2:32353)
	at c:\Users\user\.vscode\extensions\ms-toolsai.jupyter-2022.7.1001951036\out\extension.node.js:2:51405
	at Map.forEach (<anonymous>)
	at y._clearKernelState (c:\Users\user\.vscode\extensions\ms-toolsai.jupyter-2022.7.1001951036\out\extension.node.js:2:51390)
	at y.dispose (c:\Users\user\.vscode\extensions\ms-toolsai.jupyter-2022.7.1001951036\out\extension.node.js:2:44872)
	at c:\Users\user\.vscode\extensions\ms-toolsai.jupyter-2022.7.1001951036\out\extension.node.js:2:2366282
	at t.swallowExceptions (c:\Users\user\.vscode\extensions\ms-toolsai.jupyter-2022.7.1001951036\out\extension.node.js:7:121082)
	at dispose (c:\Users\user\.vscode\extensions\ms-toolsai.jupyter-2022.7.1001951036\out\extension.node.js:2:2366260)
	at t.RawSession.dispose (c:\Users\user\.vscode\extensions\ms-toolsai.jupyter-2022.7.1001951036\out\extension.node.js:2:2371197)
	at processTicksAndRejections (node:internal/process/task_queues:96:5)]
warn 12:25:39.715: Cell completed with errors {
  message: 'Canceled future for execute_request message before replies were done'
}
info 12:25:39.716: Cancel all remaining cells true || Error || undefined
info 12:25:39.716: Cancel pending cells
info 12:25:39.716: Cell 5 executed with state Error

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
shortoriancommented, Jul 19, 2022

if it helps, this is a minimal version of my bad code

class Obj():

    def __init__(self):
        self.container = {}

    def __getattr__(self, attr):

        try:
            return getattr(self, attr)

        except AttributeError as error:
            
            try:
                return self.container['key']

            except KeyError:
                raise error
                
obj = Obj()
obj.wrong_name
1reaction
shortoriancommented, Jul 19, 2022

I just remembered I’d written a custom __getattr__ for Obj. That was the source of the problem, no issue with the extension.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Why does this kernel_write-call crash? - linux - Stack Overflow
I know that writing to a file inside the kernel is bad, but I need to persistently store information. Below is a simplified...
Read more >
using perf can crash kernel with a stack overflow
running sudo stress-ng --perf --cpu 1 -t 10 will cause the recent 5.4.0-25-generic kernel to lock up with no information on the console...
Read more >
Crashes unless I check for stack overflows? - Kernel
But when I perform a production build my application seems to be crashing on boot unless I enable stack overflow checking.
Read more >
The case of the stack overflow exception when the stack is ...
Another possibility is that the system ran out of memory. Even though a megabyte of memory is reserved for the stack, the memory...
Read more >
The kernel crashes in cpuacct_charge(). A possible stack ...
The kernel crashes in cpuacct_charge(). A possible stack overflow caused by the 3rd party module installed and loaded.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found