cups-browsed hangs on SIGTERM after cupsd crashed (socket-activated), gets SIGKILLed after 90 s and leaks its dbus:// subscription
関連するプルリクエストがすでにマージされています。
- #85 @RonitMehta08 による — マージ済み
評価
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- C
- スター
- 51
- フォーク
- 21
- 平均マージ
- 22時間 49分
- マージ済み PR(30日)
- 6
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートなし
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
OpenPrinting/cups-browsed のほかの issue
-
難易度 3/5 1〜2日 初心者へのやさしさ 67/100
OpenPrinting/cups-browsed#82 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 35/100
OpenPrinting/cups-browsed#77 · コメント 1 件 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 42/100
OpenPrinting/cups-browsed#76 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 50/100
OpenPrinting/cups-browsed#75 ·
-
難易度 4/5 3〜5日 初心者へのやさしさ 38/100
OpenPrinting/cups-browsed#71 ·
OpenPrinting/cups-browsed の issue をすべて見る
似ている issue
-
`sha256()` returns a wrong hash when libsql-ffi is built with gcc 11 or later対応中かも @colinhacks が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
tursodatabase/libsql#2333 ·
メンテナーはふだん 11 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 76/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
OpenPrinting/cups#1826 ·
メンテナーはふだん 1 日以内に返信
-
Backport to 3.0 advertises a suffix that does not exist対応中かも このイシューにリンクされたプルリクエストがオープン中、またはマージ済みです。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
389ds/389-ds-base#8152 ·
メンテナーはふだん 2 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
RetroAchievements/rcheevos#580 · コメント 1 件 ·
メンテナーはふだん 5 日以内に返信