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

Sorin theme causes shell to hang. #888

Closed
HelloGrayson opened this issue May 28, 2015 · 131 comments
Closed

Sorin theme causes shell to hang. #888

HelloGrayson opened this issue May 28, 2015 · 131 comments

Comments

@HelloGrayson
Copy link

My shell gets into a state where I can't do anything, I have to close the window and open a new shell. If I just hold ^C, this is my output:

~ ❯❯❯
~ ❯❯❯                                                                         ⏎
~ ❯❯❯                                                                         ⏎
~ ❯❯❯                                                                         ⏎
~ ❯❯❯                                                                         ⏎
~ ❯❯❯                                                                         ⏎
~ ❯❯❯                                                                         ⏎
~ ❯❯❯                                                                         ⏎
~ ❯❯❯                                                                         ⏎
~ ❯❯❯                                                                         ⏎
~ ❯❯❯                                                                         ⏎
~ ❯❯❯                                                                         ⏎
~ ❯❯❯                                                                         ⏎
~ ❯❯❯                                                                         ⏎
~ ❯❯❯                                                                         ⏎
~ ❯❯❯                                                                         ⏎
~ ❯❯❯                                                                         ⏎
~ ❯❯❯                                                                         ⏎
~ ❯❯❯                                                                         ⏎
~ ❯❯❯                                                                         ⏎
~ ❯❯❯                                                                         ⏎
~ ❯❯❯                                                                         ⏎
~ ❯❯❯                                                                         ⏎
~ ❯❯❯                                                                         ⏎
~ ❯❯❯                                                                         ⏎
~ ❯❯❯                                                                         ⏎
^C^C^C^C^C^C^C^C^C^C^C^C^C

At the end, you can see that the shell is busted, there is no way to get out.

Any help debugging/fixing would be much appreciated.

@HelloGrayson
Copy link
Author

Some other notes:

  • able to recreate by sending a bunch of ENTER keys, after like 4 seconds it hangs
  • switching to bash, I'm unable to reproduce in any way
  • disabling prezto by removing the initialization from zshrc, I'm unable to reproduce in any way

@HelloGrayson HelloGrayson changed the title Hangs after X commands Hangs after X consecutive commands May 28, 2015
@HelloGrayson
Copy link
Author

I think I found it, it's the sorin theme. I can reproduce with this config:

zstyle ':prezto:load' pmodule \
   'environment' \
   'terminal' \
   'editor' \
   'prompt'`

zstyle ':prezto:module:prompt' theme 'sorin'

But if I change the theme to minimal, it's fixed.

@HelloGrayson HelloGrayson changed the title Hangs after X consecutive commands Sorin theme causes shell to hang. May 28, 2015
@sorin-ionescu
Copy link
Owner

I cannot reproduce this.

@andrewpong
Copy link

I have the same problem, no idea if I can provide anything to help debug it though.

@ibeex
Copy link

ibeex commented May 28, 2015

same thing as @breerly

@tuxayo
Copy link

tuxayo commented May 28, 2015

Same problem, can reproduce by keeping "enter" pressed

@tuxayo
Copy link

tuxayo commented May 28, 2015

With a fresh install and an empty .zshrc, zsh 5.0.7, linux 4.0.4 on Arch Linux

@mafredri
Copy link

I encountered this issue a lot while working on improving the async functionality of prompt pure. There is definitely a problem with ZSH and sending kill-signals. For example, USR1, INT, etc, all can result in a deadlock of ZSH. I've tried debugging the issue with different debugging tools but to no avail.

The only safe kill-signal to send, I have found, is WINCH (window resize).

@sorin-ionescu
Copy link
Owner

Again, I cannot reproduce this.

@stefanosc
Copy link

Just to report, I can't reproduce this either.
I tried keeping enter pressed for a few seconds (probably about 100 returns) it did slow down and took a few second to catch up after I released enter but it didn't hang.

@sorin-ionescu
Copy link
Owner

https://github.com/mafredri/zsh-async, used by https://github.com/sindresorhus/pure, uses WINCH as well. Does it not get notified by terminal resizes?

@mafredri
Copy link

@stefanosc I recommend you try it inside a git repository. And I know it can be a bit tedious, but keep enter pressed for minimum of 1 minute. This happens very sporadically. Sometimes it can happen on the first try, sometimes it can take 5 minutes of pressing enter.

@sorin-ionescu it does get notified by window resizes, but it's not really an issue, since no async task has completed, no callback function will be called.

@stefanosc
Copy link

@mafredri I did try it inside a git repo.
I just tried again and held enter for about 1 minute. No hanging. It did take longer to become responsive again though (probably about 1 minute or longer)

@mafredri
Copy link

@stefanosc You can also try holding Ctrl+C instead of return. This is interesting, because I can reproduce it with a clean prezto configuration instantly (both with OS X 10.10.3 ZSH and Homebrew ZSH, did not even need to enter a git directory):

@stefanosc
Copy link

stefanosc commented May 29, 2015 via email

@mafredri
Copy link

Do you have any custom hooks? chpwd, precmd etc that might prevent the hang? I'm pretty sure it's some kind of race condition which happens when Zsh receives a kill signal while executing other commands. Do you use the OSX Terminal app or a custom one? I use Terminal (also TotalTerminal, which I've tried disabling and can still reproduce).

@stefanosc
Copy link

@mafredri no custom hooks. I use iTerm2 I don't want to test Terminal because I had set it up specifically not to use zsh / prezto (I needed to work with a team and have certain bash config...)

@mafredri
Copy link

@stefanosc roger that, then this might be a Terminal + zsh specific issue.

EDIT: Can reproduce in iTerm2, so no, not just Terminal.

@stefanosc
Copy link

stefanosc commented May 29, 2015 via email

@sorin-ionescu
Copy link
Owner

I am also using iTerm2. I will try Terminal.

@sorin-ionescu
Copy link
Owner

I have not been able to replicate it in Terminal.

@jediofthecode
Copy link

I am running arch on latest prezto pulled from git today and am able to consistently replicate this issue, running termite and zsh-5.0.7-2 from extra, switching to skwp theme fixed the issue.

@mafredri
Copy link

@sorin-ionescu @stefanosc might it be that you have enabled some options / settings that prevents this issue from surfacing? I have tested with completely clean setups (e.g. only prezto default modifications) and it happens in both iTerm2 and Terminal, I can't really think of any other environment settings that could affect this. Just out of curiosity, is your $TERM set to xterm-256color (mine is, per default)?

@sorin-ionescu
Copy link
Owner

The Prezto I use is the Prezto that is uploaded to GitHub sans a few runcom modifications seen bellow.

zpreztorc

--- /Users/sorin/.zprezto/runcoms/zprofile  2015-02-23 12:12:37.000000000 -0500
+++ /Users/sorin/.zprofile  2015-05-24 14:17:59.000000000 -0400
@@ -37,12 +37,15 @@
 typeset -gU cdpath fpath mailpath path

 # Set the the list of directories that cd searches.
-# cdpath=(
-#   $cdpath
-# )
+cdpath=(
+  $HOME/Developer
+  $cdpath
+)

 # Set the list of directories that Zsh searches for programs.
 path=(
+  $HOME/.tilde/{bin,sbin}
+  /opt/homebrew/{bin,sbin}
   /usr/local/{bin,sbin}
   $path
 )
@@ -60,8 +63,19 @@
 # Try both `lesspipe` and `lesspipe.sh` as either might exist on a system.
 if (( $#commands[(i)lesspipe(|.sh)] )); then
   export LESSOPEN="| /usr/bin/env $commands[(i)lesspipe(|.sh)] %s 2>&-"
+  # export LESSOPEN="| /Users/sorin/Downloads/less-458/debian/lesspipe %s";
+  # export LESSCLOSE="/Users/sorin/Downloads/less-458/debian/lesspipe %s %s";
+
+  # if (( $+commands[pygmentize] )); then
+    export LESSCOLORIZER='pygmentize -f terminal256 -O bg=dark,style=native -g'
+    export LESSCOLORIZER='source-highlight --outlang-def=esc256.outlang --style-file=esc256.style -i'
+  # fi
 fi

+# if (( $+commands[source-highlight-esc.sh] )); then
+#   export LESSOPEN="| /usr/bin/env source-highlight-esc.sh --infer-lang %s 2>&-"
+# fi
+
 #
 # Temporary Files
 #
@@ -72,3 +86,28 @@
 fi

 TMPPREFIX="${TMPDIR%/}/zsh"
+
+#
+# Go
+#
+
+godir="$HOME/Developer/go"
+if [[ -d "$godir" ]]; then
+  typeset -gxUT GOPATH gopath
+  gopath=($godir $gopath)
+  path=("$godir/bin" $path)
+fi
+unset godir
+
+#
+# Git
+#
+
+export GIT_EDITOR="$commands[$EDITOR]"
+
+#
+# Homebrew
+#
+export HOMEBREW_PREFIX="$HOME/.homebrew"
+export HOMEBREW_CACHE="$HOME/.cache/Homebrew"
+export REPOSITORY="https://github.com/Homebrew/homebrew"

zprofile

--- /Users/sorin/.zprezto/runcoms/zprofile  2015-02-23 12:12:37.000000000 -0500
+++ /Users/sorin/.zprofile  2015-05-24 14:17:59.000000000 -0400
@@ -37,12 +37,15 @@
 typeset -gU cdpath fpath mailpath path

 # Set the the list of directories that cd searches.
-# cdpath=(
-#   $cdpath
-# )
+cdpath=(
+  $HOME/Developer
+  $cdpath
+)

 # Set the list of directories that Zsh searches for programs.
 path=(
+  $HOME/.tilde/{bin,sbin}
+  /opt/homebrew/{bin,sbin}
   /usr/local/{bin,sbin}
   $path
 )
@@ -60,8 +63,19 @@
 # Try both `lesspipe` and `lesspipe.sh` as either might exist on a system.
 if (( $#commands[(i)lesspipe(|.sh)] )); then
   export LESSOPEN="| /usr/bin/env $commands[(i)lesspipe(|.sh)] %s 2>&-"
+  # export LESSOPEN="| /Users/sorin/Downloads/less-458/debian/lesspipe %s";
+  # export LESSCLOSE="/Users/sorin/Downloads/less-458/debian/lesspipe %s %s";
+
+  # if (( $+commands[pygmentize] )); then
+    export LESSCOLORIZER='pygmentize -f terminal256 -O bg=dark,style=native -g'
+    export LESSCOLORIZER='source-highlight --outlang-def=esc256.outlang --style-file=esc256.style -i'
+  # fi
 fi

+# if (( $+commands[source-highlight-esc.sh] )); then
+#   export LESSOPEN="| /usr/bin/env source-highlight-esc.sh --infer-lang %s 2>&-"
+# fi
+
 #
 # Temporary Files
 #
@@ -72,3 +86,28 @@
 fi

 TMPPREFIX="${TMPDIR%/}/zsh"
+
+#
+# Go
+#
+
+godir="$HOME/Developer/go"
+if [[ -d "$godir" ]]; then
+  typeset -gxUT GOPATH gopath
+  gopath=($godir $gopath)
+  path=("$godir/bin" $path)
+fi
+unset godir
+
+#
+# Git
+#
+
+export GIT_EDITOR="$commands[$EDITOR]"
+
+#
+# Homebrew
+#
+export HOMEBREW_PREFIX="$HOME/.homebrew"
+export HOMEBREW_CACHE="$HOME/.cache/Homebrew"
+export REPOSITORY="https://github.com/Homebrew/homebrew"

@sorin-ionescu
Copy link
Owner

I have not upgraded to the latest Mac OS X. Maybe this is a 10.10 problem.

@jediofthecode
Copy link

@sorin-ionescu This is also occuring in arch linux, i don't think it would be a problem specific to OSX. Which version of zsh are you running ?

@sorin-ionescu
Copy link
Owner

Thank you, @mafredri.

@mafredri
Copy link

@sorin-ionescu no problem, someone had to investigate this 😄 .

This issue should now be fixed with the latest commits to the zsh git repo (36079 and 36084). At least I have not been able to reproduce any more deadlocks in my tests.

It would be helpful if people are able to try it out and see if they can reproduce the issue mentioned here (just to make sure we get all edge-cases ironed out).

@mafredri
Copy link

If any OSX users are eager to test it out, you can apply this patch and install it through Homebrew: brew reinstall zsh --HEAD. Unfortunately, documentation cannot be installed (requires yodl to build).

@sorin-ionescu
Copy link
Owner

Thank you @mafredri. Unfortunately, we can't depend on users installing HEAD Zsh or even the latest Zsh. So, we'll have to use the workaround for a long time.

@mafredri
Copy link

Yes, I agree. I have a branch of zsh-async that essentially tries to use zle instead of kill-signals to communicate with the parent (this is something that's available in zsh 5.0.9 / 5.1, once released). It falls back to using WINCH though. I still have some tweaks left there but essentially it works :).

@sorin-ionescu
Copy link
Owner

@mafredri Could you verify that zsh-async does not interfere with the editor module or wacky themes that use ZLE to display status bars and other contextual data?

@mafredri
Copy link

It should not, it's not Zle in the traditional sense. Zle can be used to
watch file descriptors and attach handlers to them when there is output,
and that's what I'm doing in zsh-async.
On Aug 25, 2015 3:37 AM, "Sorin Ionescu" notifications@github.com wrote:

@mafredri https://github.com/mafredri Could you verify that zsh-async
does not interfere with the editor module or wacky themes that use ZLE to
display status bars and other contextual data?


Reply to this email directly or view it on GitHub
#888 (comment)
.

@cmcginty
Copy link
Contributor

cmcginty commented Nov 5, 2015

This bug is still in master. I can easily hit it after a few commands with prezto enabled. Testing on Linux Mint 17.2

@ishitatsuyuki
Copy link

@cmcginty Possibly you are using long-term-bug version. I'm on Arch Linux with zsh 5.1.1 and no problem exists.

@sorin-ionescu
Copy link
Owner

@ishitatsuyuki Some people can't update Zsh.

@kaluzki
Copy link
Contributor

kaluzki commented Nov 12, 2015

#888 (comment)
Same issue on my vagrant box with trusty. Another prompts (e. g. powerline) seem too work properly.

@bingalls
Copy link

Prezto works fine on local shells, but locks up, when I ssh into a Centos 7 server, with Prezto there.
I've had to resort to running screen; tmux works no better. Does not seem limited to Sorin theme.
Sporadic problems happen, regardless of Terminal, iTerm, iTerm2 (beta), XQuartz terminal. Switching to oh-my-zsh stopped issue, but I still run Prezto locally. All new software, as of Nov, 2015 (El Capitan, etc)
Problem pops up, when exiting vi, running ls. Note that C-\, C-z also fail, like C-c. Not sure, what other signals to try killing with (other than SIGKILL)
HTH.

@sorin-ionescu
Copy link
Owner

@bingalls My theme is not the only async theme. Which themes have you used?

@bingalls
Copy link

bingalls commented Dec 2, 2015

nicoulaj. I seem to recall kylewest & minimal, too.

@sorin-ionescu
Copy link
Owner

@bingalls Those don't use async.

@al-the-x
Copy link

al-the-x commented Jan 8, 2016

FWIW, I've seen long delays on Mac OS X running Prezto when the user's home directory is a git repository. The delay I have observed is definitely caused by a long-running git status command scanning all the files and folders in $HOME/Library/ etc, which may cause similar problems regardless of platform, depending on the contents of $HOME. Removing the repository from $HOME or setting .gitignore to */ corrects this. Please excuse me if this information is irrelevant.

@bingalls @cmcginty @breerly Do any of you have $HOME initialized as a git repo?

@bingalls
Copy link

bingalls commented Jan 8, 2016

David-
Unfortunately, I no longer have access to the problem environment. I
don't recall ~/.git/ however.
-Bruce

On 1/8/16 2:05 PM, David Rogers wrote:

FWIW, I've seen long delays on Mac OS X running Prezto when the user's
home directory is a git repository. The delay I have observed is
definitely caused by a long-running |git status| command scanning all
the files and folders in |$HOME/Library/| etc, which may cause similar
problems regardless of platform, depending on the contents of |$HOME|.
Removing the repository from |$HOME| or setting |.gitignore| to |*/|
corrects this. Please excuse me if this information is irrelevant.

@bingalls https://github.com/bingalls @cmcginty
https://github.com/cmcginty @breerly https://github.com/breerly Do
any of you have |$HOME| initialized as a git repo?


Reply to this email directly or view it on GitHub
#888 (comment).

@HelloGrayson
Copy link
Author

@al-the-x nope:

~ » git st
fatal: Not a git repository (or any of the parent directories): .git

@sorin-ionescu
Copy link
Owner

@al-the-x Execute git-info off in your home directory.

@jefft
Copy link

jefft commented May 18, 2016

As @mafredri suggests, this seems fixed in Zsh 5.1+. Perhaps this bug should be marked 'wontfix' or 'fixed upstream' or something.

On Linux Mint 7.1 with zsh 5.0.2-3ubuntu6 and out-the-box zprezto, I could reliably trigger a hang just by holding down Enter for 20+ seconds in a Git-managed project. After manually installing zsh-5.2 from source I can no longer trigger a hang. For posterity here is a gdb backtrace showing a malloc hang in zsh 5.0.2 (also note that switching to WINCH / signal 28 didn't help):

(gdb) bt
#0  __lll_lock_wait_private () at ../nptl/sysdeps/unix/sysv/linux/x86_64/lowlevellock.S:95
#1  0x00007fcdf2f4bdca in _L_lock_12779 () at malloc.c:5206
#2  0x00007fcdf2f497a5 in __GI___libc_malloc (bytes=264) at malloc.c:2887
#3  0x000000000044776b in lexsave () at ../../Src/lex.c:252
#4  0x0000000000471a89 in dotrapargs (sig=28, sigtr=0x6bbdf0 <sigtrapped+112>, sigfn=0x1ba82a0)
    at ../../Src/signals.c:1192
#5  0x0000000000472918 in dotrap (sig=<optimised out>) at ../../Src/signals.c:1312
#6  0x000000000047299d in handletrap (sig=28) at ../../Src/signals.c:1060
#7  0x0000000000472d34 in zhandler (sig=28) at ../../Src/signals.c:619
#8  <signal handler called>
#9  _int_free (av=0x7fcdf3285760 <main_arena>, p=0x1cbf9e0, have_lock=0) at malloc.c:3958
#10 0x0000000000447c67 in lexrestore () at ../../Src/lex.c:384
#11 0x0000000000449841 in parsestrnoerr (
    s=s@entry=0x7fcdf3f73288 "\212\215editor_info[overwrite]\216%(?:: %F{1}⃯\203\256%f)\212\215VIM:+\232 %B%F{6}V%f%b\232\216") at ../../Src/lex.c:1650
#12 0x000000000044985e in parsestr (
    s=0x7fcdf3f73288 "\212\215editor_info[overwrite]\216%(?:: %F{1}⃯\203\256%f)\212\215VIM:+\232 %B%F{6}V%f%b\232\216") at ../../Src/lex.c:1622
#13 0x000000000047125b in promptexpand (
    s=0x7fcdf3f73288 "\212\215editor_info[overwrite]\216%(?:: %F{1}⃯\203\256%f)\212\215VIM:+\232 %B%F{6}V%f%b\232\216", ns=ns@entry=1, rs=rs@entry=0x0, Rs=Rs@entry=0x0, txtchangep=0x7fcdf21be918 <rpmpt_attr>)
    at ../../Src/prompt.c:186
#14 0x00007fcdf1f950fc in zleread (lp=<optimised out>, rp=0x6b75c0 <rprompt>, flags=3, context=0)
    at ../../../Src/Zle/zle_main.c:1167
#15 0x000000000043f75f in zleentry (cmd=1) at ../../Src/init.c:1462
#16 0x0000000000440336 in inputline () at ../../Src/input.c:281
#17 ingetc () at ../../Src/input.c:217
#18 0x0000000000439bb6 in ihgetc () at ../../Src/hist.c:279
#19 0x000000000044a08c in gettok () at ../../Src/lex.c:714
#20 zshlex () at ../../Src/lex.c:395
#21 0x0000000000466a67 in parse_event () at ../../Src/parse.c:451
#22 0x000000000043cb69 in loop (toplevel=toplevel@entry=1, justonce=justonce@entry=0) at ../../Src/init.c:132
#23 0x000000000043fd66 in zsh_main (argc=<optimised out>, argv=<optimised out>) at ../../Src/init.c:1617
#24 0x00007fcdf2ee8ec5 in __libc_start_main (main=0x40ebf0 <main>, argc=1, argv=0x7fff4b358fa8, 
    init=<optimised out>, fini=<optimised out>, rtld_fini=<optimised out>, stack_end=0x7fff4b358f98)
    at libc-start.c:287
#25 0x000000000040ec1e in _start ()

@basmith89
Copy link

I had the same issue. It seemed the culprit for me was an old version of zsh. I installed zsh 5.2 and it now works fine.

@belak
Copy link
Collaborator

belak commented Jul 25, 2017

Is this still an issue with the changes in master? We've changed how the sorin prompt handles async tasks.

@bingalls
Copy link

Again, my environment changed. I recall a remote ssh terminal issue. That said, I no longer see the problem.

@belak
Copy link
Collaborator

belak commented Nov 10, 2017

I'm closing this because it's a very old issue and the prompt was partially rewritten to add async support which may have fixed this issue.

@belak belak closed this as completed Nov 10, 2017
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