Skip to content
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

The code causes the kernel to die due to infinite recursion #6687

Open
CoolPlayLin opened this issue Jan 11, 2023 · 8 comments
Open

The code causes the kernel to die due to infinite recursion #6687

CoolPlayLin opened this issue Jan 11, 2023 · 8 comments
Labels

Comments

@CoolPlayLin
Copy link

Describe the bug
A bug in the code caused the kernel to die

To Reproduce
Steps to reproduce the behavior:

  • Using the following code can cause kernel death
class A:
    def __init__(self, data) -> None:
        self.data = data
    def __bool__(self) -> bool:
        return bool(a)
a = A("Test")
bool(a)

Expected behavior

  • Python reports errors due to infinite recursion
    image

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows 11 22H2
  • Browser: Edge
  • Version: 👇👇👇

image

@jupyterlab-probot jupyterlab-probot bot added the status:Needs Triage Applied to issues that need triage label Jan 11, 2023
@CoolPlayLin
Copy link
Author

image

@RRosio RRosio removed the status:Needs Triage Applied to issues that need triage label Jan 12, 2023
@RRosio RRosio changed the title [Bug] Infinite Recursion Leads to Kernel Death When Kernel dies error messages are not displayed Jan 12, 2023
@RRosio
Copy link
Collaborator

RRosio commented Jan 12, 2023

Thanks for reporting @CoolPlayLin. A similar issue has previously been reported as well #2648.

@CoolPlayLin CoolPlayLin changed the title When Kernel dies error messages are not displayed The code causes the kernel to die due to infinite recursion Jan 13, 2023
@CoolPlayLin
Copy link
Author

You probably didn't get what I mean
@RRosio I'm focusing on kernel bugs

@CoolPlayLin
Copy link
Author

After running the above code, Python will prompt an error, but Jupyter notebook is the kernel directly dead
@RRosio

@CoolPlayLin
Copy link
Author

@RRosio

@CoolPlayLin CoolPlayLin closed this as not planned Won't fix, can't repro, duplicate, stale Jan 21, 2023
@CoolPlayLin CoolPlayLin reopened this Jan 22, 2023
@CoolPlayLin CoolPlayLin reopened this Jan 24, 2023
@RRosio
Copy link
Collaborator

RRosio commented Jan 26, 2023

@CoolPlayLin Thank you for clarifying this issue. This issue has been accepted but no one is actively working on it at the moment. If you'd like to look into this issue, we'd welcome a pull request!

@CoolPlayLin CoolPlayLin closed this as not planned Won't fix, can't repro, duplicate, stale Jan 29, 2023
@CoolPlayLin CoolPlayLin reopened this Jun 18, 2023
@blairfrandeen
Copy link

I had this same issue. My code that caused it to crash:

class Bug:
    def __post_init__(self): # NOTE: Should be __init__
        self._config = {"bug": True}
    def __getattr__(self, name):
        return self._config[name]

b = Bug()
b.bug

Running this code in the Python interpreter gives the following:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "<stdin>", line 5, in __getattr__
  File "<stdin>", line 5, in __getattr__
  File "<stdin>", line 5, in __getattr__
  [Previous line repeated 996 more times]
RecursionError: maximum recursion depth exceeded

Note that the following code, when run in a Jupyter Notebook, generates a recursion error as expected, without killing the kernel.

def inf_rec():
    inf_rec()
inf_rec()

@CoolPlayLin
Copy link
Author

Any update?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants