Commit c7ac1741 by PLN (Algolia)

fix(perf): stop DWIM-launching Pulsar into /usr/local/sbin

183 Pulsar SIGABRTs between 2026-08-19 and 2026-09-05, 80 of them inside
one 70-minute window, all from this one block.

perf.sh launched Pulsar in "the script's directory",
$(dirname "${BASH_SOURCE[0]}") -- but perf.sh is deployed root-owned as
/usr/local/sbin/perf-audio (perf-audio.sudoers, for scoped NOPASSWD), so
BASH_SOURCE resolved to /usr/local/sbin and Pulsar got /usr/local/sbin as
its project directory. Coredump argv:
  /opt/Pulsar/pulsar --executed-from=/home/pln --no-sandbox /usr/local/sbin

The Bridge's perf watcher (bridge.py:41 -> perf.py:run_watcher ->
reconcile -> set_mode) shells out here every ~30s, and every mode flag
routes through set_priorities, so the retry was unbounded: crash ->
pgrep finds nothing -> next tick tries again. No backoff, no lock, no
exit-status check. And the "✓ Pulsar launched" line proved nothing: the
verification was a 0.5s pgrep presence poll that caught the doomed
Electron process alive during startup and returned before it aborted.

Fixed by removing the launch, not by resolving the directory better.
Setting priorities is this script's job; starting applications is not.
Ardour, two branches up, has always been prioritize-if-present with no
launch branch -- Pulsar is now symmetric with it. Both the tray and the
Bridge have real Pulsar launchers that pass the right project directory
and surface failures. #116 also wants the hot path unable to start
things by accident, and a root script spawning a GUI editor through
`sudo -u $USER env ...` every 30s is the opposite of that.

NOT LIVE YET: /usr/local/sbin/perf-audio is a root-owned copy and still
carries the bug. It needs
  sudo install -m755 -o root -g root perf.sh /usr/local/sbin/perf-audio
which is outside the sudoers whitelist, so PLN has to run it. Dormant
until then -- the block only fires when no Pulsar is running.
parent d1dbae36
...@@ -625,38 +625,26 @@ set_priorities() { ...@@ -625,38 +625,26 @@ set_priorities() {
# Find Pulsar editor processes and set lower priority # Find Pulsar editor processes and set lower priority
PULSAR_PIDS=$(pgrep -f pulsar) PULSAR_PIDS=$(pgrep -f pulsar)
# DWIM: if no Pulsar, launch it in the script's directory using the user's session env # No auto-launch here, deliberately. This block used to DWIM a Pulsar into
if [ -z "$PULSAR_PIDS" ]; then # existence when none was running, in "the script's directory" --
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)" # $(dirname "${BASH_SOURCE[0]}"). But perf.sh is DEPLOYED root-owned as
REF_PID=$(pgrep -u "$USER" -x kwin_wayland | head -1) # /usr/local/sbin/perf-audio (see perf-audio.sudoers), so BASH_SOURCE resolved
[ -z "$REF_PID" ] && REF_PID=$(pgrep -u "$USER" -x kwin_x11 | head -1) # to /usr/local/sbin and Pulsar was handed /usr/local/sbin as its project
[ -z "$REF_PID" ] && REF_PID=$(pgrep -u "$USER" -x plasmashell | head -1) # directory. It aborted every time: 183 SIGABRTs between 2026-08-19 and
if [ -n "$REF_PID" ] && [ -r "/proc/$REF_PID/environ" ]; then # 2026-09-05, 80 of them in a single 70-minute window, because the Bridge's
echo "ℹ️ Pulsar not running — launching in $SCRIPT_DIR..." # perf watcher calls set_mode() every ~30s and every mode flag routes through
get_env_var() { tr '\0' '\n' < "/proc/$1/environ" | grep "^$2=" | head -1 | cut -d= -f2-; } # here. The "✓ Pulsar launched" line was not evidence of anything -- the check
sudo -u "$USER" env \ # was a pgrep presence poll that caught the doomed process alive during
DISPLAY="$(get_env_var "$REF_PID" DISPLAY)" \ # Electron startup and returned before it died.
WAYLAND_DISPLAY="$(get_env_var "$REF_PID" WAYLAND_DISPLAY)" \ #
XDG_RUNTIME_DIR="$(get_env_var "$REF_PID" XDG_RUNTIME_DIR)" \ # Not fixed by resolving the directory better. Removed, because launching apps
DBUS_SESSION_BUS_ADDRESS="$(get_env_var "$REF_PID" DBUS_SESSION_BUS_ADDRESS)" \ # is not this script's job: perf.sh sets priorities. Ardour, two branches up,
XDG_SESSION_TYPE="$(get_env_var "$REF_PID" XDG_SESSION_TYPE)" \ # has always been prioritize-if-present with no launch branch, and Pulsar is
nohup pulsar "$SCRIPT_DIR" </dev/null >/dev/null 2>&1 & # now symmetric with it. Launching belongs to the tray and the Bridge, which
for _ in $(seq 1 20); do # both have real Pulsar launchers that pass the right project directory and
PULSAR_PIDS=$(pgrep -f pulsar) # report failures. #116 also wants the hot path unable to start things by
[ -n "$PULSAR_PIDS" ] && break # accident, and a root-run script spawning a GUI editor through
sleep 0.5 # `sudo -u $USER env ...` every 30s is the opposite of that.
done
if [ -n "$PULSAR_PIDS" ]; then
echo "✓ Pulsar launched — giving renderer 2s to spawn before prioritizing..."
sleep 2
PULSAR_PIDS=$(pgrep -f pulsar)
else
echo "⚠ Pulsar didn't appear within 10s — skipping priority set"
fi
else
echo "⚠ No user session detected (no kwin/plasma) — skipping Pulsar auto-launch"
fi
fi
if [ ! -z "$PULSAR_PIDS" ]; then if [ ! -z "$PULSAR_PIDS" ]; then
# Pulsar is the INSTRUMENT, not background load, so it stays fast in EVERY # Pulsar is the INSTRUMENT, not background load, so it stays fast in EVERY
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment