-
-
Notifications
You must be signed in to change notification settings - Fork 648
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
Yabai seems to partially stop working after upgrading to Big Sur #714
Comments
I can confirm this behavior on my end too. $>ps aux |grep -i yabai | wc -l
31 And this number grows with each command issued by skhd (or others). /usr/local/var/log/yabai/yabai.err.log contains no data. Restarting yabai via I have yet to find a scenario to help reproduce this issue reliably. Happy to help by providing logs and stuff as needed. |
(for the record, I'm on bigsur and updated yabai via homebrew as mentioned in the wiki, I also did the sudoers trick and checked that it works, and I'm using Ubersicht (with yabar) and stackline ). I've enabled debug logging and repdroduced the issue a few times, I don't have one scenario locked down, but under a minute of window focusing and space changing (via the touchpad, not via I've uploaded the debug log in this gist. After the last line in this log, yabai won't answer to any command sent by skhd (ie. |
If this happens, please open activity monitor and grab a sample of the yabai process and paste in a gist or something. |
Not sure I mentioned it earlier, but this is very easy to reproduce (in my case at least), I can't use yabai fore more than a minute before having to restart it. |
@pyrho I had similar issue first. rm -rf /Library/ScriptingAdditions
brew services stop yabai
brew services stop skhd
brew uninstall yabai
brew uninstall skhd
brew cleanup
brew install yabai
brew install skhd
brew services start yabai
brew services start skhd Allowed accessibility in system preferences again. yabai -m space --create Doesn't give any errors or nothing but no new space. yabai -m space --destroy gives me
which makes sense |
@stoffeastrom after running all your steps, i don't get an ever expanding list of yabai processes. however, it does still hang. here's a current dump of my yabai processes: https://gist.github.com/adityavm/f6b2471e65d40462e2dd8c5f1565f6e9 |
Based on that sample I would say that accessibility permission is messed up. Try to stop the brew service, open system preferences and remove accessibility permissions, reboot the system. Start the brew service and re-approve the accessibility permissions. I did a clean install of Big Sur on my machine and forgot to backup the previous certificate that was used for signing the binary, but the accessibility preferences doesn't usually notice this and will be in some wacky state. |
I did manage to reproduce the issue although I am unsure as of now what the cause is. |
@stoffeastrom I tried that. Still have the problem (and the growing number of processes once the yabai daemon (?) stops answering back to client requests). @koekeishiya thanks for looking into it. I did disallow, uninstall, reboot, reinstall, re-allow. Still got the issue. |
So I can somewhat reproduce the issue; I can make it hang a single instance if I really spam messages, but if I kill that one instance everything works again. I do not get tons of zombie processes, and the main instance is still responding if I kill that instance. Tested by opening 4 windows in a space, and running the following infinite loop:
|
@koekeishiya I can confirm that everything gets "unlocked" once I kill the "client" process that caused the issue. I feel like this (killing the culprit) "unstacks" pending calls too. edit: the unstacking behavior is confirmed too as all the other processes that were "waiting" have now disappeared. |
I don't actually get it, the amount of time it takes before a freeze is absolutely random. I've had it take literally 3seconds and now this latest run took closer to 3minutes of just the running infinite loop I posted above. Here is a short snippet of the event queue when we post, dequeue and handle, and finish handling a message.
So after some random amount of time we appear to simply just stop receiving connection requests from/on the socket. |
Me too ! From looking at the code, when the issue happens, the daemon thread seems to be stuck on the Relevant sample snippet:
The code is here, so the client is (Just throwing some ideas around, maybe it'll light a magic bulb above your head :D) edit: So if my intuition is right, the issue might be in the client_send_message function. edit2:
It stops because it's stuck on the edit3: well I git blame'd |
@koekeishiya Could you debug print the value for If you're into that we can rubber duck on zoom or something and maybe I could help you shed some light on that. (disclaimer I'm a typescript dev, my C days are long gone, so don't expect K&R level expertise ^^) |
I changed how the listener interacts with the yabai event-loop and it solved the issue for me, although it should have no effect in practice. Can you build the latest commit from master to verify? |
Simple as |
If you are using brew, the easiest would be to brew uninstall, and then brew install yabai --HEAD |
Well For good measure I also tried via |
This feels so random; it just ran fine for 4min 10sec before it froze. Then the next run lasted 10sec.. |
Yeah it's very random over here too, that's why I was thinking it was maybe a mis-initiliazed buffer; so the randomness would be caused by some random stuff sitting at the particular memory address. edit: Now that I know how to build and run, I'll do some more good'ol |
Agreed; that does seem like the most plausible reason why this would be happening. Likely the client_send_message function. |
Well... This patch: diff --git a/src/yabai.c b/src/yabai.c
index dacee39..87c5f36 100644
--- a/src/yabai.c
+++ b/src/yabai.c
@@ -83,9 +83,12 @@ static int client_send_message(int argc, char **argv)
*temp++ = '\0';
}
+ fprintf(stderr, "[%s]\n", message);
+ fprintf(stderr, "[%i]\n", message_length);
if (!socket_write_bytes(sockfd, message, message_length)) {
error("yabai-msg: failed to send data..\n");
}
+ error("yabai-msg: SENT!\n");
shutdown(sockfd, SHUT_WR); Seems to fix the issue for me; I've run it 5 times and no crashes so far. But it doesn't make sense. Unless printing shit with a |
Oh wait, So the issue is that the client never hears back from the daemon. Maybe it's because the daemon handles the request so fast that it replies before the client has a chance to open the socket to read its reply? Hence the randomness ? |
I don't really understand why the randomness is there. I've verified that the client_send_message function properly builds the message. The buffer is not left uninitialised in any way and we do not overwrite the buffer or have any kinds of buffer overflows. The only thing I'd imagine would be that the loop in socket_read does not terminate after successfully reading the message. |
Which function is called by the daemon as a response to a focus event ? It seems that the client is stuck at the |
I might be on to something, I've printed what is received by the client in the if ((byte_count = recv(sockfd, rsp, sizeof(rsp)-1, 0)) <= 0) {
fprintf(stderr, "IN BREAK: [%s]\n", rsp);
break;
} and it prints what looks like random memory, which does not sound good; thoughts ? edit: well in all cases (only playing with And I also guess that the daemon just closes the socket file descriptor instead of sending a message, so then the issue becomes that the daemon fails to close the socket or closes it before |
So in the meantime, anyone looking for a work around can apply this patch: diff --git a/src/yabai.c b/src/yabai.c
index dacee39..f92e215 100644
--- a/src/yabai.c
+++ b/src/yabai.c
@@ -90,6 +90,9 @@ static int client_send_message(int argc, char **argv)
shutdown(sockfd, SHUT_WR);
int result = EXIT_SUCCESS;
+ socket_close(sockfd);
+ return result; // TEMP HACK
+
int byte_count = 0;
char rsp[BUFSIZ]; Build: this is a very shitty and temporary workaround that will break anything trying to query yabai (like Ubersicht or Hammerspoon); but will let you use yabai until a proper fix is given to us by the gods of random bugs and late nights. |
Should be fixed on master now. |
Fix confirmed on my end, thank you so much ! 💯 |
Released v3.3.4 with this fix. |
@koekeishiya thanks for the fix. confirmed on my end as well. i see you closed this but the moving between spaces still doesn't work |
See this issue regarding focusing spaces: #712 Summary: Make sure SIP is disabled for debugging and filesystem. Reinstall the scripting-addition from the latest yabai version and load it as root. Instructions https://github.com/koekeishiya/yabai/wiki/Installing-yabai-(latest-release) have been updated and may be of interest. |
@koekeishiya i had done all of that, but looks like it didn't work because the i've managed to get it all working again. thanks for getting this fixed up! |
@adityavm Sorry I think that was me giving that faulty instruction 😬. And for others I finally got it all working also after @koekeishiya comment above
e.g had to run: csrutil disable --with kext --with dtrace --with nvram --with basesystem to get it working. Thx all for enabling big sur and a extra shout out for @koekeishiya ofc 👏 |
I've followed all instructions re: adding yabai to sudoers and adding the
--load-sa
line to yabairc. However, yabai seems to randomly (but only partially) stop working some time after starting (or restarting) the service.(I've created a binding for skhd to restart the service, but that's just a temporary relief)
I can make a list of things I've discovered work / don't work:
yabai -m query --spaces
hangs)Yabai v3.3.3
MacOS Big Sur 11.0.1
(I have a screen recording showing it go from working to not working in a span of 30s if it helps.)
The text was updated successfully, but these errors were encountered: