-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
gitstatus_query write error: broken pipe #123
Comments
Let's try to figure out what's going on. This must be something unusual as I've never seen reports of this kind. Please do the following.
( cd $ZSH_CUSTOM/themes/powerlevel10k && git pull )
echo 'GITSTATUS_LOG_LEVEL=DEBUG' >>!~/.zshrc
() {
emulate -L zsh && setopt xtrace
echo $ZSH_VERSION $ZSH_PATCHLEVEL
uname -a
ps --pid $GITSTATUS_DAEMON_PID_POWERLEVEL9K
lsof -p $$
lsof -p $GITSTATUS_DAEMON_PID_POWERLEVEL9K
cat $GITSTATUS_DAEMON_LOG_POWERLEVEL9K
} |
Hi, the following is the result after I've done all commands and triggered the error again:
|
What do you do to trigger the bug? I see in the original screenshot that after logging in you've typed Please run this command after triggering the error and post its output: () {
emulate -L zsh && setopt xtrace
echo $commands[zsh]
zsh --version
echo $ZSH_SUBSHELL $ZSH_VERSION $ZSH_PATCHLEVEL
uname -a
typeset -f -m '_gitstatus_cleanup_*'
ps -f | command grep parent-pid=$$
ps -p $GITSTATUS_DAEMON_PID_POWERLEVEL9K
lsof -p $$
lsof -p $GITSTATUS_DAEMON_PID_POWERLEVEL9K
cat $GITSTATUS_DAEMON_LOG_POWERLEVEL9K
date
} (I'm assuming you haven't removed |
Hi, it was just a coincidence. It usually occurs in the first 5 commands after logging in, and it may be caused by any commands, such as This is the result after triggering the error:
|
Apparently something is killing the background ZSH process that Powerlevel10k spawns. Do you have anything on your system that might do that? Perhaps some antivirus software or something? |
So it means that the error is caused because the child process of Powerlevel10k is killed by others? |
I restart my computer and tried again immediately after the system is ready, and the error just showed up again. |
Let's try to narrow down the problem a bit. Please run the following command. (
emulate -L zsh
setopt err_return no_unset
local tmp && tmp=$(mktemp -d "${TMPDIR:-/tmp}"/p10k.XXXXXXXXXX)
{
cd $tmp
git clone -b bg-zsh --depth 1 https://github.com/romkatv/powerlevel10k.git
echo "GITSTATUS_LOG_LEVEL=DEBUG" >>$tmp/.zshrc
echo "source ${(q)tmp}/powerlevel10k/powerlevel10k.zsh-theme" >>$tmp/.zshrc
ZDOTDIR=$tmp zsh -d
} always {
cd || true
rm -rf $tmp
}
) This will open a temporary ZSH session. Try to trigger the bug there. If you succeed, type |
This is the output of
After I exited the termporary ZSH session and back to the origin session, it showed this:
but it didn't show the |
This is pretty bad. It means the issue is not caused by any of your plugins. Does the bug trigger based on the time that has passed since you've opened ZSH or based on the number of commands you've typed? For example, if you open zsh, don't type anything for a few minutes, and then type a command, will the error appear or not? Is it more likely for the error to appear on the very first command if you wait longer before typing it? |
This is very strange. Can you try it with a different terminal? |
Could the
|
Maybe, although this would be very surprising given that you don't have async mode for zsh-autosuggestions enabled and that you've managed to trigger the same error from a clean ZSH. Let's look deeper into it. First, reenable typeset -m '*ZSH_AUTOSUGGEST*ASYNC*' Then run this code: (
emulate -L zsh
setopt err_return no_unset
local tmp && tmp=$(mktemp -d "${TMPDIR:-/tmp}"/p10k.XXXXXXXXXX)
{
cd $tmp
git clone -b bg-zsh --depth 1 https://github.com/romkatv/powerlevel10k.git
echo "source ${(q)tmp}/powerlevel10k/powerlevel10k.zsh-theme" >>$tmp/.zshrc
ZDOTDIR=$tmp zsh -d
} always {
cd || true
rm -rf $tmp
}
) Once ZSH prompt appears, keep typing the same command: kill -0 $GITSTATUS_DAEMON_PID_POWERLEVEL9K || { wait $GITSTATUS_DAEMON_PID_POWERLEVEL9K; echo $? } The first few runs of this command may print nothing. When the background ZSH eventually gets killed by the unknown actor, something like this will be printed:
Send me this text. I need that number in the middle. It's 143 in my example but could be something else for you. Exit the temporary ZSH session. Type Exit the temporary ZSH session. Disable |
This is expected. These are background processes that someone else is killing before your
This is also expected. You are trying to kill your own interactive ZSH with SIGTERM but it ignores SIGTERM so your command doesn't do anything. The error appears because the background processes get killed by someone else. This error would've appeared even if you'd typed |
This is expected. I just wanted to make sure no rogue code enables async for
This is surprising because this is the same test as in #123 (comment) where you've reported that you were able to trigger the bug in a temporary ZSH session. Or perhaps I've misunderstood? Here's me:
And then you:
I took this to mean you could trigger the bug. Could you clarify? Or perhaps repeat that exact test under the same conditions (
This is expected given that the previous test hasn't triggered the bug.
This is expected given that the previous test hasn't triggered the bug. Let's do one more test because we still don't know which signal kills the background ZSH. First, type this command. ( cd $ZSH_CUSTOM/themes/powerlevel10k && git pull && git checkout bg-zsh ) Then enable wait $GITSTATUS_DAEMON_PID_POWERLEVEL9K; echo $? Finally, revert changes made to powerlevel10k. ( cd $ZSH_CUSTOM/themes/powerlevel10k && git checkout master ) |
I did triggered the error previously, but actually I didn't know how to triggered the error (executing which command?), and I didn't know when it would be triggered (how long since login?). I just kept trying arbitrary commands until it was triggered, and that usually took within 3 minutes and in the first 20 commands. After After reverting the changes to powerlevel10k, the error was triggered in 1 minutes. |
I don't understand why the shell said that the In both conditions, the |
On master that job is disowned (started with
|
I've daemonized the background process in Checkout branch ( cd $ZSH_CUSTOM/themes/powerlevel10k && git pull && git checkout bg-zsh ) Enable |
Ok, I will try it for a few days. |
Have you see those |
Hi, I have never seen that error triggered so far after switching to |
That's great to hear! I've merged changes from ( cd $ZSH_CUSTOM/themes/powerlevel10k && git pull origin master && git checkout master ) If the error reappears, please let me know. |
Just to make sure the last changes I've made are in effect: If yes, then I don't know what else to do. I can tell you I've never seen anyone having even remotely similar problem. If it was my local machine, I likely would be able to figure it out, but doing it by sending commands and their output back and forth is too inefficient. What makes things even more difficult is that running the same code may yield different results, which means the approach we've been using for debugging this problem is unreliable. The same code cannot yield different results under the same conditions, so there must be some externalizes outside of our control. I can suggest several options.
Sorry that I couldn't help you solve this problem. |
Yes, there is no |
Hi, sorry to bother you again. |
What's unusual about your system? Given that you are the only one with this problem, there must be something special. Can you think of anything that isn't standard? Do you change any settings? Manually set any environment variables? Install any non-mainstream applications or packages? |
I've added extra logging in
( cd $ZSH_CUSTOM/themes/powerlevel10k && git pull && git checkout dev )
P.S. The answers to my questions from the previous comment are still important. |
Sorry, I forgot to mention that you need to add one more line to your echo 'GITSTATUS_LOG_LEVEL=DEBUG' >>!~/.zshrc Please run this command and repeat the steps above. P.S. How come your history is owned by root? This is certainly unusual. |
This is the output of
|
OK, now we know that the process is killed with SIGTERM. Let's figure out who sends it.
( cd $ZSH_CUSTOM/themes/powerlevel10k && git pull )
|
I still need answers to these questions. Please send them ASAP. |
If it's not owned by root, this is fine.
I don't use macOS myself and I don't think I can afford the time to figure out which of these applications are mainstream and which are unusual. Perhaps you know the answer?
You had a way to trigger the error reliably by chowning your history to root. Could you use it? It's much easier to deal with errors that can be deterministically reproduced. |
It's not owned by root.
I think those applications are trustworthy. They all developed by famous corporations except for
I have chowned the A few days ago, when we tried to figure out what happened, you daemonized the background process in |
I just tried to switch Powerlevel10k back to the Would it be caused by the connection timeout between my session and gitstatusd? I tried to put the following snippets in the
|
Thanks, this is useful information.
No.
It's unrelated. We know that the background process is killed by Earlier my first thought was that I've added extra logging, now to a file. Please do the following:
( cd $ZSH_CUSTOM/themes/powerlevel10k && git pull && git checkout dev )
|
Sorry, I forget you are on macOS. The cat ${TMPDIR:-/tmp}/gitstatus.log $GITSTATUS_DAEMON_LOG_POWERLEVEL9K The rest looks useful but I still need the content of that |
Hi, because the length of output is too long for my terminal to display on the screen, I redirect the result of the command to a file named
Here is the result:
|
Apparently it's zsh-autosuggestions causing mayhem. This is somewhat surprising because you were able to reproduce this issue when you disabled all plugins except for p10k. Perhaps there was some mistake in that test. Armed with these logs I've added appropriate defense to p10k. Please switch back to ( cd $ZSH_CUSTOM/themes/powerlevel10k && git checkout master && git pull ) You can also remove |
I truly appreciate your all your help on this matter. |
That's good. I'll close the issue then. Please reopen if the error disappears. Thanks for your persistence and patience in assisting with debugging. |
By the way, do you know about |
Thanks, the config the wizard suggested to me looks awesome!! |
901c366b survive `cd` being a function that fails instead of doing its job; see #123 git-subtree-dir: gitstatus git-subtree-split: 901c366b8ecb736e579784b132442ee51bcb0840
I'm getting this same error all the time. I installed p10k via zinit |
@TensorTom Thanks for letting me know. |
Hi,
I found that after I execute some commands in CLI (e.g.,
echo
,vim <file>
), it sometimes showsgitstatus_query:echo:32: write error: broken pipe
, and it shows the error in every result of CLI commands later if it is triggered once..
I install this theme by oh-my-zsh, and my os is MacOSX 10.14.5.
I use iTerm2 as my terminal emulator.
This is a copy of my .zshrc file
Hope to help you replicate the error.
Thanks.
The text was updated successfully, but these errors were encountered: