cups-browsed hangs on SIGTERM after cupsd crashed (socket-activated), gets SIGKILLed after 90 s and leaks its dbus:// subscription
A pull request for this has already been merged.
- #85 by @RonitMehta08 — merged
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 52/100
Research direction
Start by tracing cups-browsed's SIGTERM handling and the local CUPS IPP requests that can block during shutdown; the issue gives no source file or test names. Reproduce the stop while cupsd is unavailable behind the listening socket, then check that cups-browsed exits promptly and stale dbus:// subscriptions are cleaned up or skipped safely. The suggested request timeout, signal handling, and startup cleanup may involve several parts of the service.
Written by the indexing model from the issue text.
Description
Summary
When cupsd dies unexpectedly, systemd restarts cups.service, and because cups-browsed.service has Requires=cups.service, it first stops cups-browsed. At that moment cups.socket is still listening, so cups-browsed's connection to /run/cups/cups.sock succeeds, but nobody answers: cupsd will only be started again after cups-browsed has stopped. cups-browsed blocks in that request, never leaves its main loop, and is killed by systemd after TimeoutStopSec (90 s).
Consequences:
- Printing is unavailable for an extra 90 s after every cupsd crash (cupsd cannot restart before cups-browsed is gone).
- The shutdown cleanup never runs:
cancel_subscription(subscription_id)andbrowse_poll_cancel_subscription()are skipped, so cups-browsed'sdbus://subscription (notify-events=all, owner "anonymous") stays insubscriptions.confuntil its 24 h lease expires, and the generated queues are not removed.
During a normal stop (cupsd still running) everything works: the subscription is cancelled successfully.
Environment
- Ubuntu 26.04.1 LTS
- cups-browsed 2.1.1-0ubuntu4, cups 2.4.16-1ubuntu1.3
cups.servicesocket/path-activated (TriggeredBy=cups.path cups.socket),Restart=on-failurecups-browsed.service:Requires=cups.service,After=cups.service,TimeoutStopUSec=1min 30s
Observed
This happened three times in nine days, each time after cupsd aborted with heap corruption. The crash is a separate issue. The journal shows the same sequence each time:
2026-11-17T15:13:03 cupsd[1578389]: corrupted double-linked list
2026-11-17T15:13:04 systemd[1]: cups.service: Main process exited, code=dumped, status=6/ABRT
2026-11-17T15:13:04 systemd[1]: cups.service: Scheduled restart job, restart counter is at 1.
2026-11-17T15:13:04 systemd[1]: Stopping cups-browsed.service - Make remote CUPS printers available locally...
2026-11-17T15:14:34 systemd[1]: cups-browsed.service: State 'stop-sigterm' timed out. Killing.
2026-11-17T15:14:34 systemd[1]: cups-browsed.service: Killing process 1578393 (cups-browsed) with signal SIGKILL.
2026-11-17T15:14:34 systemd[1]: Stopped cups.service - CUPS Scheduler.
2026-11-17T15:14:34 systemd[1]: Started cups.service - CUPS Scheduler.
2026-11-17T15:14:34 systemd[1]: Started cups-browsed.service - Make remote CUPS printers available locally.
The same sequence occurred on 2026-11-10 at 00:05:25 / 00:06:56 and on 2026-11-14 at 00:18:41 / 00:20:12.
cups-browsed debug log of the killed instance. After Caught signal 15 nothing else is logged for 90 s, not even main loop exited:
Tue Nov 17 15:13:04 2026 124759354349248 Print queue update 1 of this series: BrGenPrintML2_hl_l2300d
Tue Nov 17 15:13:04 2026 124759354349248 Unable to create/modify CUPS queue (Broken pipe)!
Tue Nov 17 15:13:04 2026 124759411907456 cups-browsed: Creating http connection to local CUPS daemon via domain socket: /run/cups/cups.sock
Tue Nov 17 15:13:04 2026 124759411907456 Caught signal 15, shutting down ...
Tue Nov 17 15:14:34 2026 132184071150464 main() in THREAD 132184071150464 <- new instance
For comparison, a normal stop on 2026-11-18 while cupsd was running. Both cancels succeed:
Wed Nov 18 00:08:14 2026 ... Caught signal 15, shutting down ...
Wed Nov 18 00:08:14 2026 ... main loop exited
...
cupsd: [Client 171] Returning IPP successful-ok for Cancel-Subscription (/) from localhost.
cupsd: [Client 172] Returning IPP successful-ok for Cancel-Subscription (/) from localhost.
After the killed instance, its subscription #961 (dbus://, notify-events=all, lease 86400, subscriber "anonymous") is still listed by Get-Subscriptions next to the new instance's #965. cupsd starts a separate notifier/dbus process for each such leftover subscription.
Expected
cups-browsed should exit promptly on SIGTERM even if cupsd does not respond, and should not leave its subscription behind.
Suggestions
- Use a finite timeout for IPP requests to the local cupsd, at least during shutdown, for example
httpSetTimeout()or a deadline aroundcupsDoRequest(). Then a dead cupsd behind a systemd socket cannot block forever. - Handle SIGTERM so the main loop is left even while a worker or the main thread is waiting on cupsd. Skip the cleanup calls that need cupsd if it is unreachable.
- At startup, cancel stale
dbus://subscriptions left by a previous cups-browsed instance, for example by persisting the subscription id in/var/cache/cups-browsed/. That way a crash or SIGKILL does not leak a subscription for 24 h.
Related
- OpenPrinting/cups#1824: with several
dbus://subscriptions, the global lock in the D-Bus notifier decides which subscription's events are emitted. Leftover subscriptions add more notifier processes to that race. This particular leftover is a broadallsubscription, so it causes no loss of events by itself.
- Dominant language
- C
- Stars
- 51
- Forks
- 21
- Avg merge
- 22h 49m
- Merged PRs (30d)
- 6
Getting set up
- No Dockerfile or Docker Compose file
- No pull request template
- Read the contributing guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from OpenPrinting/cups-browsed
-
Difficulty 3/5 1-2 days Newbie friendliness 67/100
OpenPrinting/cups-browsed#82 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
OpenPrinting/cups-browsed#77 · 1 comment ·
-
Difficulty 4/5 3-5 days Newbie friendliness 42/100
OpenPrinting/cups-browsed#76 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 50/100
OpenPrinting/cups-browsed#75 ·
-
Difficulty 4/5 3-5 days Newbie friendliness 38/100
OpenPrinting/cups-browsed#71 ·
All issues in OpenPrinting/cups-browsed
Similar issues
-
`sha256()` returns a wrong hash when libsql-ffi is built with gcc 11 or laterPossibly taken @colinhacks claimed this today. Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
tursodatabase/libsql#2333 ·
Maintainers usually reply within 11 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
OpenPrinting/cups#1826 ·
Maintainers usually reply within 1 day
-
Backport to 3.0 advertises a suffix that does not existPossibly taken A pull request linked to this issue is open or already merged. Open
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
389ds/389-ds-base#8152 ·
Maintainers usually reply within 2 days
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
RetroAchievements/rcheevos#580 · 1 comment ·
Maintainers usually reply within 5 days