burke / zeus

Boot any rails app in under a second.
MIT License
3.33k stars 231 forks source link

Pager hangs in debugger console when displaying output via the pager (less) #627

Closed gltarsa closed 7 years ago

gltarsa commented 7 years ago

Zeus v0.15.13

Repeat by:

At the first pager prompt, :, nothing will advance to the next page, Ctrl-C does not abort. I have to use ^Z to suspend the process, then kill -9 %1 to REALLY kill the process.

Here is pstree output, that shows the relationships at the time of the hang:

|-+= 84190 tarsa /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal -psn_0_30776664
 | |-+= 84196 root login -pfl tarsa /bin/bash -c exec -la bash /bin/bash
 | | \-+= 84203 tarsa -bash
 | |   \--= 78756 tarsa /Users/tarsa/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/zeus-0.15.13/build/zeus-darwin-amd64 s
 | |-+= 84303 root login -pfl tarsa /bin/bash -c exec -la bash /bin/bash
 | | \-+= 84317 tarsa -bash
 | |   \-+= 35104 tarsa /Users/tarsa/.rbenv/versions/2.3.3/lib/ruby/gems/2.3.0/gems/zeus-0.15.13/build/zeus-darwin-amd64 start
 | |     \-+- 35118 tarsa zeus slave: boot   
 | |       \-+- 35120 tarsa zeus slave: default_bundle   
 | |         |-+- 80577 tarsa zeus slave: development_environment   
 | |         | |-+= 78770 tarsa zeus runner: server   
 | |         | | \-+- 78771 tarsa zeus command: server   
 | |         | |   \--- 79556 tarsa less -R -F -X .      # <---------- pager here
 | |         | \-+- 80597 tarsa zeus slave: prerake   
 | |         |   \--= 72432 tarsa (ruby)
 | |         \-+- 80578 tarsa zeus slave: test_environment   
 | |           \-+- 80598 tarsa zeus slave: test_helper   
 | |             \-+= 79389 tarsa zeus runner: test   
 | |               \-+- 79390 tarsa zeus command: test   
 | |                 \--= 79395 tarsa /usr/local/bin/phantomjs --proxy-type=none --load-images=no --ignore-ssl-errors=yes --ssl-protocol=any /User
sideshowcoder commented 7 years ago

Interesting I have not seen this so far so I wonder what makes your setup different from mine, as I have this quite often actually this way. normally the pry pager uses q to cancel. Can you reproduce this just in a big app or will a small script do it for you as well? Try for example https://github.com/sideshowcoder/zeus-without-rails for testing if it helps.

toshi1973814 commented 7 years ago

same for me

mipearson commented 7 years ago

This is hitting us as well, but in the rails console using pry-rails: no binding.pry required. Anything that triggers the pager causes it.

Process looks like this when it needs to be kill -9'd:

mp              43629   0.0  0.0 556624768   3996 s005  U+    1:44pm   0:00.08 /Users/mp/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/zeus-0.15.13/build/zeus-darwin-amd64 c```

(note the very very high mem allocation)

There is a delay between the kill -9 and the process actually exiting.

This issue does not appear in the versions of zeus 0.15.4 to 0.15.12 - only in .13.

sideshowcoder commented 7 years ago

interesting... does that happen on a new rails app as well? wonder if any gem causes this, or any pry setting... would you be able to create a demo app for me to reproduce?

maestromac commented 7 years ago

This is happening to me as well. Downgrading to 0.15.12 solved it.

rails (4.2.5.1) pry (0.10.4) pry-rails (0.3.6)

gltarsa commented 7 years ago

I can concur that the downgrade alleviates the immediate pain. Thanks, @maestromac!

rails (4.2.7.1) pry (0.10.4) pry-byebug (3.4.0)

OSX Sierra

sideshowcoder commented 7 years ago

Perfect thanks, lets see what is going on here 😢

sideshowcoder commented 7 years ago

so something in here broke it https://github.com/burke/zeus/compare/v0.15.12...v0.15.13 @Crunch09 as you wanted to take a look FYI, I assume it has something todo with how terminal is handled, or the input is directed ... The odd thing is it works in emacs using inf-ruby and inf-ruby-switch-from-compilation

bjeanes commented 7 years ago

I'm also experiencing this. Sometimes, I can ^C out of the pager and drop back into pry. However, I then cannot quit the main process. I too have had quite a few ^Z then kill %1 iterations in the last few weeks, though. This also usually corrupts the tty and I have to run stty sane to get a functioning shell again.

2017-04-07 at 2 10 pm
bjeanes commented 7 years ago

Confirmed downgrading from 0.15.13 to 0.15.12 also resolved the issue for me.

Crunch09 commented 7 years ago

With the help of git bisect and manually testing the commit i could determine that the culprit is https://github.com/burke/zeus/commit/0916d0f4746995913a91c50979ab0bace8e8137f . cc: @sideshowcoder

sideshowcoder commented 7 years ago

Thanks @Crunch09

sideshowcoder commented 7 years ago

Ok so I got a little further with that the issue seems to be related to how the terminal state is restored, it is stored in a defer of a go func, where it should be restored at the end of the main func.

sideshowcoder commented 7 years ago

One way to work around this is to disable the pager in pry Pry.config.pager = false this is obviously not ideal but at least means not needing to kill zeus everytime pry decides to page.

benjamin-thomas commented 7 years ago

Hello,

I'm encountering that same pager bug in v0.15.14

Version 0.15.12 does not have that behavior indeed

sideshowcoder commented 7 years ago

Interesting, could you share something to reproduce? Could you try reinstalling zeus at the latest version. @benjamin-thomas

benjamin-thomas commented 7 years ago

Sure, I'll see what I can do.

I'm developing in a (fairly complicated) docker environment so it should be reproducible.

Same problem with v0.15.15.pre

Do you have a docker environment setup ?

sideshowcoder commented 7 years ago

No actually I don't use docker but If you are able to provide a sample repro where the error occurs I can probably take a look @benjamin-thomas

benjamin-thomas commented 6 years ago

Hello @sideshowcoder

Could you have a look at this repo? https://github.com/benjamin-thomas/zeus-pager-bug

I manage to isolate this bug pretty minimally I think.

Based on sqlite so should be pretty trivial to setup.

I've based it on rails 4 since there seems to be a library loading issue with rails 5, so would make it more difficult to revert zeus versions.

Let me know if you need anything else.