Skip to content

Spyder continuously spawns bash processes, hanging the system #23455

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

Open
7 of 10 tasks
pvir opened this issue Jan 13, 2025 · 5 comments
Open
7 of 10 tasks

Spyder continuously spawns bash processes, hanging the system #23455

pvir opened this issue Jan 13, 2025 · 5 comments

Comments

@pvir
Copy link

pvir commented Jan 13, 2025

Issue Report Checklist

  • Searched the issues page for similar reports
  • Read the relevant sections of the Spyder Troubleshooting Guide and followed its advice
  • Reproduced the issue after updating with conda update spyder (or pip, if not using Anaconda)
  • Could not reproduce inside jupyter qtconsole (if console-related)
  • Tried basic troubleshooting (if a bug/error)
    • Restarted Spyder
    • Reset preferences with spyder --reset
    • Reinstalled the latest version of Anaconda
    • Tried the other applicable steps from the Troubleshooting Guide
  • Completed the Problem Description, Steps to Reproduce and Version sections below

Problem Description

Sometimes Spyder starts spawning an unlimited amount of processes like this, apparently in a busy loop:

bash -l -c python3.12 -c import os; print(dict(os.environ))

which almost completely hangs the system.

To resolve the situation, I have to pkill -9 spyder and pkill -9 -f python3.12, to kill hundreds of spawned bash processes and prevent more from spawning. The python3.12 is that from the same condaforge install as Spyder.

What steps reproduce the problem?

This is unclear, but it happens sporadically on one specific system:

Spyder from current condaforge, on RHEL 9.4.

When it occurred, I had started Spyder from gnome-shell, not from terminal. This has now happened not every time I use Spyder on this setup, but relatively often.

Now that I tried it again, Spyder did this after being idle for a few minutes.

What is the expected output? What do you see instead?

Spyder should not be able to get in a state where it spawns bash processes in a busy loop.

Versions

  • Spyder version: 6.0.3 (conda)
  • Python version: 3.12.6 64-bit
  • Qt version: 5.15.8
  • PyQt5 version: 5.15.9
  • Operating System: Linux-5.14.0-427.42.1.el9_4.x86_64-x86_64-with-glibc2.34

Dependencies

# Mandatory:
aiohttp >=3.9.3                  :  3.11.11 (OK)
asyncssh >=2.14.0,<3.0.0         :  2.19.0 (OK)
atomicwrites >=1.2.0             :  1.4.1 (OK)
chardet >=2.0.0                  :  5.2.0 (OK)
cloudpickle >=0.5.0              :  3.1.0 (OK)
cookiecutter >=1.6.0             :  2.6.0 (OK)
diff_match_patch >=20181111      :  20241021 (OK)
github >=2.3.0                   :  2.5.0 (OK)
importlib_metadata >=4.6.0       :  8.5.0 (OK)
intervaltree >=3.0.2             :  3.1.0 (OK)
IPython >=8.13.0,<9.0.0,!=8.17.1 :  8.31.0 (OK)
jedi >=0.17.2,<0.20.0            :  0.19.2 (OK)
jellyfish >=0.7                  :  1.1.3 (OK)
jsonschema >=3.2.0               :  4.23.0 (OK)
keyring >=17.0.0                 :  25.6.0 (OK)
nbconvert >=4.0                  :  7.16.5 (OK)
numpydoc >=0.6.0                 :  1.8.0 (OK)
parso >=0.7.0,<0.9.0             :  0.8.4 (OK)
pexpect >=4.4.0                  :  4.9.0 (OK)
pickleshare >=0.4                :  0.7.5 (OK)
psutil >=5.3                     :  6.1.1 (OK)
pygments >=2.0                   :  2.19.1 (OK)
pylint >=3.1,<4                  :  3.3.3 (OK)
pylint_venv >=3.0.2              :  3.0.4 (OK)
pyls_spyder >=0.4.0              :  0.4.0 (OK)
pylsp >=1.12.0,<1.13.0           :  1.12.0 (OK)
pylsp_black >=2.0.0,<3.0.0       :  2.0.0 (OK)
pyuca >=1.2                      :  1.2 (OK)
qdarkstyle >=3.2.0,<3.3.0        :  3.2.3 (OK)
qstylizer >=0.2.2                :  0.2.4 (OK)
qtawesome >=1.3.1,<1.4.0         :  1.3.1 (OK)
qtconsole >=5.6.1,<5.7.0         :  5.6.1 (OK)
qtpy >=2.4.0                     :  2.4.2 (OK)
rtree >=0.9.7                    :  1.3.0 (OK)
setuptools >=49.6.0              :  75.6.0 (OK)
sphinx >=0.6.6                   :  8.1.3 (OK)
spyder_kernels >=3.0.2,<3.1.0    :  3.0.2 (OK)
superqt >=0.6.2,<1.0.0           :  0.7.0 (OK)
textdistance >=4.2.0             :  4.6.2 (OK)
three_merge >=0.1.1              :  0.1.1 (OK)
watchdog >=0.10.3                :  6.0.0 (OK)
xdg >=0.26                       :  0.28 (OK)
yarl >=1.9.4                     :  1.18.3 (OK)
zmq >=24.0.0                     :  26.2.0 (OK)

# Optional:
cython >=0.21                    :  None (NOK)
matplotlib >=3.0.0               :  3.10.0 (OK)
numpy >=1.7                      :  2.2.1 (OK)
pandas >=1.1.1                   :  None (NOK)
scipy >=0.17.0                   :  1.14.1 (OK)
sympy >=0.7.3                    :  None (NOK)
@pvir pvir changed the title Spyder continuously spawns Spyder continuously spawns bash processes, hanging the system Jan 13, 2025
@ccordoba12
Copy link
Member

Hey @pvir, thanks for reporting. You said:

When it occurred, I had started Spyder from gnome-shell, not from terminal. This has now happened not every time I use Spyder on this setup, but relatively often.

I don't know why this is happening in your system. I also use Linux (Ubuntu 22.04) and I'm no seeing anything like that, so my guess is that it's related to something in your setup (plus, it hasn't been reported by other Linux users).

A workaround for this is to start Spyder from the command line. Let us know if that solves the problem for you.

@pvir
Copy link
Author

pvir commented Jan 14, 2025

The problem likely is coming from

elif os.name == 'posix':
which calls bash etc. to try to get environment variables of login shell. It's not clear to me what exactly is calling this function repeatedly. Unfortunately, I don't have time right now to debug this further.

I'm not really looking for workarounds here (I can just edit out that problematic code for this installation), this bug report is mainly for you to be aware of that on some cases this code seems to cause problems.

@casimir7
Copy link

casimir7 commented Jan 28, 2025

Thanks to the OP for reporting and thanks to all responders.
Just to confirm: I am having the same issue with the stock-installation of Spyder 6.03 (pip) with IPython 8.26.0 on fedora 41.
Python 3.13.1 64-bit | Qt 5.15.15 | PyQt5 5.15.10 Linux 6.12.10-200.fc41.x86_64 (x86_64)
The issue appeared with one of the last updates around Jan 1.

When I start Spyder or just (re-)start a kernel inside the spyder console, this results in hundreds of bash instances that seem to multiply themselves.
One can kill them using killall bash but one needs to do that fast and repeatedly for ~a minute. Otherwise the system freezes.
After the last bash instance is killed, everything is back to normal.
Starting Spyder from the console does not avoid this problem

I tried all steps from the troubleshooting guide apart from installing spyder in a virtual environment. Resetting the configuration or complete fresh install of spyder and the entire python toolchain did not help.
Please indicate if any further info is required.

@pvir
Copy link
Author

pvir commented Jan 28, 2025

As a workaround, I've made the following edit to the Spyder installation, and the problem seems to have disappeared:

--- spyder/utils/environ.py	2025-01-28 14:01:10.553385181 +0200
+++ spyder/utils/environ.py	2025-01-14 14:33:18.411784314 +0200
@@ -103,7 +110,10 @@
         env_var = dict(
             [winreg.EnumValue(key, k)[:2] for k in range(num_values)]
         )
-    elif os.name == 'posix':
+    elif os.name == 'posix' and False:

Haven't yet managed to find out what exactly is calling this in a loop on this machine.

I've also been using Spyder on another machine with current Fedora 41 without any edits to the installation, but on that machine I do not see the issue for some reason.

@casimir7
Copy link

I tried the proposed patch by @pvir and it works on my machine.
Further, I did a bit of debugging on environ.py.
The bash instances are triggered by this code:

stdout, stderr = proc.communicate(
                    timeout=3 if running_in_ci() else 0.5
                )

However, I do not understand why.

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

No branches or pull requests

3 participants