matryer / xbar

Put the output from any script or program into your macOS Menu Bar (the BitBar reboot)
https://xbarapp.com
MIT License
17.56k stars 643 forks source link

Segfaults on refresh #739

Open jobor019 opened 3 years ago

jobor019 commented 3 years ago

Hi! Thanks for developing such an amazing app!

Running the 2.10-beta (brew installation) on MacOS 10.15.7, I've noticed quite a lot of crashes when interacting with clickable items. More specifically, it seems that these errors occur when a script refreshes while the menu of a plugin is open, i.e. when the following sequence occurs:

  1. A menu bar plugin is clicked to expand the menu
  2. A refresh occurs
  3. An item in the menu is clicked -> segfault

A minimal example from the readme to reproduce this error: (filename: test.1s.sh):

#!/usr/bin/env bash

echo 'test'
echo '---'
echo 'Open website | href=https://xbarapp.com'

This will crash almost every time Open website is clicked. Changing the filename to test.1m.sh will result in very few crashes in normal usage, but it's still possible to reproduce the error by clicking test, waiting 60 seconds, clicking Open website.

cngarrison commented 3 years ago

I haven't confirmed the same sequence of events (eg, plugin is doing a refresh), but I experience a crash nearly every time I click an xbar menu item. At least one of the plugins I use does a refresh after running a command, so I suspect it's the same issue. Problem started with 2.1.0-beta.

leaanthony commented 3 years ago

Hi. Are you running on M1 by any chance? I've discovered that the code that detects when a menu is open doesn't work on M1, despite the same code working fine on Intel! We use this to ensure that the menus aren't "pulled from under your feet". Could you please try this:

  1. Right click xbar in finder
  2. Select "Get Info"
  3. Check "Open using Rosetta"
  4. Restart xbar

Thanks.

cngarrison commented 3 years ago

I do not have an M1 mac. Sorry I couldn't help with a simple culprit.

jobor019 commented 3 years ago

Same, I'm running this on a 2018 MBP13 (Catalina, as mentioned above), so I'm afraid this isn't the issue.

leaanthony commented 3 years ago

Yeah, sorry about that - this one's on me. Just done some debugging and it turns out my aggressive approach to memory leaks introduced a regression that is ultimately the cause of this. I've created a fix and Mat and I will be testing over the weekend. If all goes well, expect a release shortly.

cngarrison commented 3 years ago

👍

Thanks for the update