You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Mar 3, 2023. It is now read-only.
Shelling out to collect environment variables is creating runaway 100% CPU processes on Linux #13084
I'm fairly sure this will end up being an Electron issue, but here goes ...
When I start atom-beta (1.12.0b4, though was present with b3 at least), it spawns a shell ('env') subprocess which burns 100% CPU, attempting to read stdin forever:
Sometimes this process blocks Atom startup, and you have to kill the shell for Atom's window to show. Sometimes Atom works just fine despite this, and you only realise later when you wonder why your system is slow, and kill the extraneous process. Sometimes closing Atom takes the rogue shell process with it, and sometimes it outlives Atom. Sometimes everything works fine and I can't reproduce it at all.
Either way, safe mode or not has no effect on it, and nothing bright turns up with --enable-logging. Timecop shows 'window load time' taking an ungodly amount of time, but with no insight into why.
Happy to supply more details or attempt debugging as needed, with the caveat that I have no idea what I'm doing in JavaScript.
Steps to Reproduce
Have my system
Run Atom beta
Expected behavior: 'What a nice normal text-editing experience this is'
Actual behavior: WOOOOOOOOSSHHHH goes the laptop fan
Versions
Atom 1.12.0b4 (also occurred with b3)
Fedora 25 (kernel 4.8-rc8+, glibc 2.24, etc)
Reacted by Drew Noel, Frode Egeland, Victor Gonzalez, Ronan Jouchet, Santos Gallegos, Andrew, Vianney Carel, Sergey Gnuskov, Flemming Andersen, Raphael Syed and 1 more
Ah, following the quoting for "command env" rather than as separate arguments, it dumps my entire environment and then exits immediately. I can share a redacted version with you, if the actual content is of interest, but it does simply print and exit.
Edit: Of particular interest is that it works as expected in foreground mode. Watching ps confirms that it requests information from the shell and continues just fine. @fooishbar is this problem absent in foreground mode (atom -f)?
When I launch atom-beta from a terminal instance, it runs without issues, regardless of whether it's launched in foreground mode or not, and whether I run the shell script in /usr/bin or the actual binary in /usr/share/atom-beta.
When I launch it through a provided desktop file, then the issue described in the bug report manifests. Running the exact same command used in the desktop file (minus the %F of course) does not reproduce this issue, and editing the desktop file to launch Atom using a simple /usr/bin/atom-beta does not fix it. Atom is the only application I have that causes this issue, including other Electron-based programs.
Same issue here: "/bin/bash -ilc command env" keeps CPU in full load, and atom never starts. Only killing this will successfully load atom.
Run on ubuntu 16.04
Atom version 1.12.0+1-1webupd80
I invoke $ atom project/folder/, but Atom only starts once I kill the /bin/zsh -ilc command env process. Otherwise Atom doesn't start and said process burns the CPU at 100% in all the cores.
Once the command is killed, Atom starts normally. For example:
$ atom project/folder/
# atom doesn't open
$ kill 12341
# burning process is killed and Atom opens its window
This is my installation, thorugh the webupd8 channel.
The "command env" commands (for both /bin/bash and /bin/zsh) both print a long list of environment variables without significant delay and exit normally. If there are any particular environment variables you wish to know the contents of, please let me know.
% which -a env
/usr/bin/env
% echo $SHELL
/bin/zsh
% getent passwd $LOGNAME | cut -d: -f7
/bin/zsh
@joefitzgerald the aur package atom-editor-bin downloads the official distribution, makes minimal tweaks for arch, and then installs it globally, just as if it were installed on ubuntu or fedora.
If someone else has the time to try out my reproduction case on ubuntu, that would be great.
@forivall I appreciate your effort in trying to identify root cause. It does seem like something very specific to arch linux at this point, and it seems like you are on the right track to look at the method of invocation for non-terminal launched atom on arch.
Very interested to hear the outcome of your investigation!
I started up an ubuntu 16.10 vm: with the minimal reproduction, the same issue occurs, and the same fix works. 🎉
Edit: also, by launching atom with the xdg-launch.py script (python xdg-launch.py /usr/share/applications/atom.desktop), the CPU will be pegged at 100% by a runaway bash process. (I installed lxde on the vm, and launching from its menu doesn't trigger the issue. But lxde uses qt)
This may be a different issue. Do y'all think I should open a new bug for it, or keep working in here?
Hello, I'm having the same issue with the zsh process taking 100% of the CPU. I tested it in Arch Linux, using the official community repo package, downloading the tar.gz from atom release page for the stable and the beta versions.
All of these versions share the same problem, and weirdly enough it only happens when launching atom from a .desktop file (via gnome shell in my case) and doesn't when I launch atom from the command line.
After reading @arcticicestudio comment in #13279 I came up with a sort of workaround, I simply made a .desktop file with the following line: Exec=sh -c "ATOM_DISABLE_SHELLING_OUT_FOR_ENVIRONMENT=true atom" and it seems to work fine.
I hope this can be of help to find a long term solution to this problem, which is getting really annoying and prevents many people from using such a great editor as atom.
@joefitzgerald should we reopen this issue? Seems like we're still getting reports but it's really hard to tell what's real with all these different custom packaging solutions.
@nathansobo We should at least attempt to reproduce the reported problems using only official distributions of Atom.
This means we'll need to check Arch Linux at least, possibly with both GNOME and KDE. On the Ubuntu side of things, it might be enough to check Ubuntu GNOME 16.04. The only reported problems I've seen on Ubuntu 16.04 is in relation to webupd8.
@maxbrunsfeld guess we want to add detached back in.
@phw thank you for the detailed analysis. We do actually want the -i flag as the intent of this behavior is to ensure the shell initializatoon scripts that get run for an interactive shell are run. This ensures that atom has the same environment that it would have when invoked from a terminal.
This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!
Activity
thomasjo commentedon Oct 27, 2016
This originates in our process environment patching. I'm guessing something is preventing
zshfrom exiting.Would you mind running the follow in a terminal, and reporting back what the output is?
fooishbar commentedon Oct 27, 2016
Oddly enough, just a screen-clear character, then exits immediately:
Thanks for the prompt response!
fooishbar commentedon Oct 27, 2016
Ah, following the quoting for "command env" rather than as separate arguments, it dumps my entire environment and then exits immediately. I can share a redacted version with you, if the actual content is of interest, but it does simply print and exit.
drewmnoel commentedon Oct 30, 2016
I have this problem as well. Confirmed on
zsh 5.2as well asGNU bash 4.3.46(1)Versions:
Attempted to make a minimal working example, but the extracted function actually works just fine for me on
node v6.9.1https://gist.github.com/drewmnoel/7da14895c20b0fa8b376c18354318caf
Edit: Of particular interest is that it works as expected in foreground mode. Watching
psconfirms that it requests information from the shell and continues just fine. @fooishbar is this problem absent in foreground mode (atom -f)?TheDaemoness commentedon Nov 10, 2016
I appear to have this issue as well.
When I launch atom-beta from a terminal instance, it runs without issues, regardless of whether it's launched in foreground mode or not, and whether I run the shell script in /usr/bin or the actual binary in /usr/share/atom-beta.
When I launch it through a provided desktop file, then the issue described in the bug report manifests. Running the exact same command used in the desktop file (minus the %F of course) does not reproduce this issue, and editing the desktop file to launch Atom using a simple
/usr/bin/atom-betadoes not fix it. Atom is the only application I have that causes this issue, including other Electron-based programs.winstliu commentedon Nov 10, 2016
@joefitzgerald
bsandu commentedon Nov 10, 2016
Same issue here: "/bin/bash -ilc command env" keeps CPU in full load, and atom never starts. Only killing this will successfully load atom.
Run on ubuntu 16.04
Atom version 1.12.0+1-1
webupd80dweldon commentedon Nov 10, 2016
I'm experiencing the same symptoms with atom
1.12.0and bash4.3.42under linux mint. If I kill the terminal, atom seems to start up fine.XzAeRo commentedon Nov 10, 2016
I'm experiencing the same.
I invoke
$ atom project/folder/, but Atom only starts once I kill the/bin/zsh -ilc command envprocess. Otherwise Atom doesn't start and said process burns the CPU at 100% in all the cores.Once the command is killed, Atom starts normally. For example:
This is my installation, thorugh the webupd8 channel.
joefitzgerald commentedon Nov 10, 2016
For anyone reporting they are experiencing this issue, please run the relevant command and paste the output:
/bin/bash -ilc "command env"/bin/zsh -ilc "command env"<path-to-your-shell-here> -ilc "command env"You can find out what shell is being used by determining what the
SHELLenv variable is set to.Additionally, please post the output from
which -a env; e.g.:It sounds like we should at a minimum establish a timeout for the invocation of this command so that it will be killed if it takes too long.
Timeout when invoking the shell, log information to the console
TheDaemoness commentedon Nov 11, 2016
The "command env" commands (for both /bin/bash and /bin/zsh) both print a long list of environment variables without significant delay and exit normally. If there are any particular environment variables you wish to know the contents of, please let me know.
69 remaining items
forivall commentedon Nov 19, 2016
Minimal reproduction case: https://gist.github.com/forivall/99bd9b913ab774ced025be2483a59879
Usage:
python xdg-launch.py ./spawn-ilc.desktop. You'll need to modify the path in the .desktop fileNow to figure out if this is a gnome or node issue. Changing it from zsh to bash causes the same issue.
Removing the
-i(interactive) option (so that it's just'-lc') stops it from hanging, though it may not be correct.joefitzgerald commentedon Nov 19, 2016
Just to confirm, @forivall, you're not using an official distribution of atom from https://atom.io?
https://github.com/atom/design-decisions/blob/master/unofficial-atom-distributions.md
forivall commentedon Nov 19, 2016
@joefitzgerald the aur package
atom-editor-bindownloads the official distribution, makes minimal tweaks for arch, and then installs it globally, just as if it were installed on ubuntu or fedora.If someone else has the time to try out my reproduction case on ubuntu, that would be great.
the following gist makes it work, by using a pty for stdin:
https://gist.github.com/forivall/825f4a94eaf30b96dec522d40bb47887
joefitzgerald commentedon Nov 19, 2016
@forivall I appreciate your effort in trying to identify root cause. It does seem like something very specific to arch linux at this point, and it seems like you are on the right track to look at the method of invocation for non-terminal launched atom on arch.
Very interested to hear the outcome of your investigation!
forivall commentedon Nov 19, 2016
I started up an ubuntu 16.10 vm: with the minimal reproduction, the same issue occurs, and the same fix works. 🎉
Edit: also, by launching atom with the xdg-launch.py script (
python xdg-launch.py /usr/share/applications/atom.desktop), the CPU will be pegged at 100% by a runawaybashprocess. (I installed lxde on the vm, and launching from its menu doesn't trigger the issue. But lxde uses qt)This may be a different issue. Do y'all think I should open a new bug for it, or keep working in here?
GabMus commentedon Nov 21, 2016
Hello, I'm having the same issue with the zsh process taking 100% of the CPU. I tested it in Arch Linux, using the official community repo package, downloading the tar.gz from atom release page for the stable and the beta versions.
All of these versions share the same problem, and weirdly enough it only happens when launching atom from a .desktop file (via gnome shell in my case) and doesn't when I launch atom from the command line.
After reading @arcticicestudio comment in #13279 I came up with a sort of workaround, I simply made a .desktop file with the following line:
Exec=sh -c "ATOM_DISABLE_SHELLING_OUT_FOR_ENVIRONMENT=true atom"and it seems to work fine.I hope this can be of help to find a long term solution to this problem, which is getting really annoying and prevents many people from using such a great editor as atom.
Workaround for atom#13084
nathansobo commentedon Nov 21, 2016
@joefitzgerald should we reopen this issue? Seems like we're still getting reports but it's really hard to tell what's real with all these different custom packaging solutions.
thomasjo commentedon Nov 21, 2016
@nathansobo We should at least attempt to reproduce the reported problems using only official distributions of Atom.
This means we'll need to check Arch Linux at least, possibly with both GNOME and KDE. On the Ubuntu side of things, it might be enough to check Ubuntu GNOME 16.04. The only reported problems I've seen on Ubuntu 16.04 is in relation to webupd8.
phw commentedon Nov 23, 2016
I debugged this a bit and can reproduce it with the following test script (extracted from src/update-process-env.js):
Launching this directly from a shell works, even if I set an empty environment like so:
Launching the same from a desktop file in Gnome 3.22 leads to the shell task endlessly consuming 100% of CPU. I used the following desktop file:
Two things help to solve this issue:
a) Enable
detached: truewhen spawning the child processb) Remove the
-iflag from the shell callI think b) would actually be correct anyway, since this is in no way an interactive shell.
EDIT: Just to be clear: I still don't know exactly why this is happening, I just know the issue can be circumvented removing the
-iflag.joefitzgerald commentedon Nov 23, 2016
@maxbrunsfeld guess we want to add detached back in.
@phw thank you for the detailed analysis. We do actually want the -i flag as the intent of this behavior is to ensure the shell initializatoon scripts that get run for an interactive shell are run. This ensures that atom has the same environment that it would have when invoked from a terminal.
phw commentedon Nov 23, 2016
Can this issue be reopened then until a fix is merged? I think this was accidentally closed by #13283
joefitzgerald commentedon Nov 23, 2016
No, it wasn't closed by that. We should open a new issue with your findings @phw. I will commit to getting this in today.
lock commentedon Apr 4, 2018
This issue has been automatically locked since there has not been any recent activity after it was closed. If you can still reproduce this issue in Safe Mode then please open a new issue and fill out the entire issue template to ensure that we have enough information to address your issue. Thanks!