Atom-beautify: Beautification with Executables sometimes causes freeze/crash

Created on 19 Jun 2017  路  20Comments  路  Source: Glavin001/atom-beautify

Description

In atom-beautify v0.30.1 beautification with autopep8 will regularly (but not always :confused:) 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:

  • [x] Tried uninstalling and reinstalling Atom Beautify to ensure it installed properly
  • [x] Reloaded (or restarted) Atom to ensure it is not a caching issue
  • [x] Searched through existing Atom Beautify Issues at https://github.com/Glavin001/atom-beautify/issues
    so I know this is not a duplicate issue
  • [x] 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

bug high priority published

Most helpful comment

Published to v0.30.3

All 20 comments

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.

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!

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

@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.

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!!

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

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

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

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 bc21afd424728591ea45eb8c1153df0a1b719a70 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! :crossed_fingers:

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!

Oh and looks like Atom itself had the same issue! https://github.com/atom/atom/issues/13084

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!

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!

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 Many thanks for quickly going after this!

Get ready for testing! Just waiting for CI builds to finish: https://github.com/Glavin001/atom-beautify/pull/1735

Published to v0.30.3

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

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.

@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. :+1: I'll report back if I find anything that breaks it, but I think for now beautifying python is working.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

jasonivers picture jasonivers  路  4Comments

opikhidayat picture opikhidayat  路  4Comments

philiplb picture philiplb  路  5Comments

mkermani144 picture mkermani144  路  4Comments

bartocc picture bartocc  路  5Comments