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

Beautification with Executables sometimes causes freeze/crash #1728

Closed
4 of 5 tasks
matthewfeickert opened this issue Jun 19, 2017 · 20 comments
Closed
4 of 5 tasks

Beautification with Executables sometimes causes freeze/crash #1728

matthewfeickert opened this issue Jun 19, 2017 · 20 comments

Comments

@matthewfeickert
Copy link

matthewfeickert commented Jun 19, 2017

Description

In atom-beautify v0.30.1 beautification with autopep8 will regularly (but not always 😕) cause Atom to lockup (only for Beautification with autopep8, Beautification with uncrustify is fine for C++ files) and need me to manually kill it from the command line.
freezing

Steps to Reproduce

  1. Add Python code to Atom editor
  2. Run command Atom Beautify: Beautify Editor so that beautification with autopep8 occurs
  3. Atom freezes and has to be killed from the command line

Debug

The freeze happens when running in debug mode too, so no error logs output can be generated.

Checklist

I have:

  • Tried uninstalling and reinstalling Atom Beautify to ensure it installed properly
  • Reloaded (or restarted) Atom to ensure it is not a caching issue
  • Searched through existing Atom Beautify Issues at https://github.com/Glavin001/atom-beautify/issues
    so I know this is not a duplicate issue
  • Filled out the Input, Expected, and Actual sections above or have edited/removed them in a way that fully describes the issue.
  • Generated debugging information by executing Atom Beautify: Help Debug Editor command in Atom and added link for debug.md Gist to this issue
    • Unable to as debug mode fails too
@matthewfeickert matthewfeickert changed the title Beautification with autopep8 sometimes causes crash Beautification with autopep8 sometimes causes freeze/crash Jun 19, 2017
@tekvsakdan
Copy link

I have similar problem with javascript. If the code is more complexed, with a lot of functions, Atom freezes after pressing CTRL+ALT+B (Atom-beautify version 0.30.1). CPU is then 100%. I didn't have problems with 0.29.x version. The only solution is to kill Atom process.

@Glavin001 Glavin001 added this to the v0.31.0 milestone Jun 19, 2017
@Glavin001
Copy link
Owner

I do expect first load / beautification to take some time. I always find first load very slow -- a couple seconds -- and subsequent loads are fast, since the executable paths are cached.

I have no experienced this before. What version of Atom are you each using? I'll try again later to reproduce, however our CI builds are passing:

This is what is being tested for Python + autopep8: https://github.com/Glavin001/atom-beautify/blob/master/examples/nested-jsbeautifyrc/python/original/test.py
Could you try that Python file?


@Zajc : JavaScript is handled differently than autopep8. I would expect it to be relatively quick.
I did update the js-beautify dependency: https://github.com/Glavin001/atom-beautify/blame/master/package.json#L168
Could you try to generate a debug.md Gist so I can see what your configuration is and narrow down the issues?

Thanks!

@Glavin001 Glavin001 added the bug label Jun 19, 2017
@fidalgo
Copy link

fidalgo commented Jun 19, 2017

I have the same problem with Ruby, but I'm also unable to debug it, because the editor freezes...

@matthewfeickert
Copy link
Author

matthewfeickert commented Jun 19, 2017

@Glavin001 I am using Atom (Linux distro) version 1.17.2.

$ atom --version
Atom    : 1.17.2
Electron: 1.3.15
Chrome  : 52.0.2743.82
Node    : 6.5.0

also (though I don't think it is relevant):

$ uname -a
Linux ThinkPad-Edge-E540 4.4.0-79-generic #100-Ubuntu SMP Wed May 17 19:58:14 UTC 2017 x86_64 x86_64 x86_64 GNU/Linux

I have been able to successfully reproduce the error in the following way: opening the file from the command line. That is, if I do

$ atom test.py

and then beautify (either by the Packages drop down menu) or by executing ctrl-alt-b I get the same freezing behavior where my CPU goes up to 100% and Ubutnu 16.04 eventually will ask to kill the process (if I haven't already from the command line).
However, if I open Atom from the Unity Launcher icon, and then open the file from within Atom everything is fine. I can spam ctrl-alt-b and atom-beautify handles everything just fine and is able to beautify your test.py successfully.

@Glavin001
Copy link
Owner

However, if I open Atom from the Unity Launcher icon, and then open the file from within Atom everything is fine. I can spam ctrl-alt-b and atom-beautify handles everything just fine and is able to beautify your test.py successfully.

Oooh, that's interesting! I think this would be equivalent to how I personally run Atom on my Mac (via Finder). I will try using atom FILENAME instead and seeing if there are some interesting branches followed. Thank you for your research!!

@billiam13s
Copy link

I have the same problem with php-cs-fixer after today update.

@matthewfeickert
Copy link
Author

matthewfeickert commented Jun 19, 2017

I've just checked to make sure what I reported holds true (on my machine at least) with Atom 1.18.0 (which just appeared in apt update) and it does. That is, the freeze/crash still occurs when Atom is opened from the command line, and it does not occur (atom-beautify works correctly) when Atom is opened from the Launcher/Finder and the file is then opened from inside Atom.

$ atom --version
Atom    : 1.18.0
Electron: 1.3.15
Chrome  : 52.0.2743.82
Node    : 6.5.0

@tekvsakdan
Copy link

JavaScript. I cannot create debug.md beacuse Atom editor freezes after pressing CTRL+ALT+B.

$ atom --version
Atom    : 1.18.0
Electron: 1.3.15
Chrome  : 52.0.2743.82
Node    : 6.5.0
$ lsb_release -a
No LSB modules are available.
Distributor ID:	Ubuntu
Description:	Ubuntu 16.04.2 LTS
Release:	16.04
Codename:	xenial

@Glavin001 Glavin001 changed the title Beautification with autopep8 sometimes causes freeze/crash Beautification with Executables sometimes causes freeze/crash Jun 20, 2017
@Glavin001
Copy link
Owner

Ok thanks for trying @Zajc.


@foutrelis did some investigation and discovered an issue with bash -ilc env call:

Starting with v0.30.0, atom-beautify hangs while beautifying code (tried C and Go files). There is a bash -ilc env process that uses 100% of one core while other cores are tied up by Atom/Electron processes.

Doing a quick git bisect shows commit bc21afd as the first commit that displays this behavior.

I'm using Atom 1.18 (running on Electron 1.4.16) on Arch Linux x86_64.

This is interesting because the bash -ilc env call should be non-blocking and was also being used before Executables in the older code. I think we can move towards removing it. The problem is environment variables such as PATH are not correctly loaded by Atom/Electron. However, maybe this has changed since this feature was added to Atom-Beautify! 🤞

@Glavin001
Copy link
Owner

Great news! Looks like Atom already does the same thing Atom-Beautify does to load the environment variables correctly! See https://github.com/atom/atom/blob/7b1aadc9b361c4e6257f88d94fe9bf531341a407/src/update-process-env.js#L79

This means I can simply remove the code from Atom-Beautify and expect the process.env to work correctly! 🎆 😃 Fix coming later!

@Glavin001
Copy link
Owner

Oh and looks like Atom itself had the same issue! atom/atom#13084

@Glavin001
Copy link
Owner

Having problems with tests: https://discuss.atom.io/t/specs-do-not-load-shell-environment-variables-activationhooks-core-loaded-shell-environment/44199
Blocked by this. Once resolved, I can merge fix. Thanks everyone for your patience!

@icaromag
Copy link

Same issue here, 100% disk usage in my machine and atom freezes. The interesting is that when running within my Vagrant box there is no problem at all!

@Glavin001
Copy link
Owner

I have not heard of a great fix yet. I am going to patch the specs using the old method Atom-Beautify was using -- which works for me, Travis CI, and AppVeyor 👍 -- and remove it for the package itself such that you guys should no longer have issues! Working on this now. Wish me luck! 😄

@Glavin001 Glavin001 self-assigned this Jun 21, 2017
@matthewfeickert
Copy link
Author

@Glavin001 Many thanks for quickly going after this!

@Glavin001
Copy link
Owner

Get ready for testing! Just waiting for CI builds to finish: #1735

Glavin001 added a commit that referenced this issue Jun 22, 2017
Fixes #1728. Remove Shell-Env from Executable, use Atom's process.env instead
@Glavin001
Copy link
Owner

Published to v0.30.3

@Glavin001
Copy link
Owner

Please test and let me know if it works or does not work. Thanks!

@tekvsakdan
Copy link

tekvsakdan commented Jun 22, 2017

After the upgrade to v0.30.3 I'm experiencing the same (CPU 100%, freeze) behaviour when trying to beautify the JavaScript code.

Edit: If JavaScript code is not complex it can be beautified. When it has (a lot of) functions the Editor freezes when CTRL+ALT+B is pressed.

@matthewfeickert
Copy link
Author

matthewfeickert commented Jun 22, 2017

@Glavin001 Everything is working as expected now with atom-beautify v0.30.3 and

$ atom --version
Atom    : 1.18.0
Electron: 1.3.15
Chrome  : 52.0.2743.82
Node    : 6.5.0

Many thanks! I've tested with your test.py example (with opening from the command line, atom test.py) and also confirmed that it works on much larger things like xAODAnaHelpers's python scripts. 👍 I'll report back if I find anything that breaks it, but I think for now beautifying python is working.

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

6 participants