cups-browsed hangs on SIGTERM after cupsd crashed (socket-activated), gets SIGKILLed after 90 s and leaks its dbus:// subscription
Một pull request liên quan đã được merge.
- #85 của @RonitMehta08 — đã merge
Đánh giá
- Độ khó
- 4/5
- Thời gian dự kiến
- 3-5 ngày
- Mức phù hợp với người mới
- 52/100
Hướng nghiên cứu
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.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
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.
- Ngôn ngữ chính
- C
- Star
- 51
- Fork
- 21
- Merge trung bình
- 22 giờ 49 phút
- Pull request đã merge (30 ngày)
- 6
Chuẩn bị môi trường
- Không có Dockerfile hay tệp Docker Compose
- Không có mẫu pull request
- Đọc hướng dẫn đóng góp
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của OpenPrinting/cups-browsed
-
Độ khó 3/5 1-2 ngày Mức phù hợp với người mới 67/100
OpenPrinting/cups-browsed#82 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 35/100
OpenPrinting/cups-browsed#77 · 1 bình luận ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 42/100
OpenPrinting/cups-browsed#76 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 50/100
OpenPrinting/cups-browsed#75 ·
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 38/100
OpenPrinting/cups-browsed#71 ·
Tất cả issue của OpenPrinting/cups-browsed
Issue tương tự
-
`sha256()` returns a wrong hash when libsql-ffi is built with gcc 11 or laterCó thể đã có người làm @colinhacks đã nhận hôm nay. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
tursodatabase/libsql#2333 ·
Maintainer thường phản hồi trong vòng 11 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 72/100
OpenPrinting/cups#1826 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Backport to 3.0 advertises a suffix that does not existCó thể đã có người làm Có pull request liên kết đang mở hoặc đã được merge. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
389ds/389-ds-base#8152 ·
Maintainer thường phản hồi trong vòng 2 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 78/100
RetroAchievements/rcheevos#580 · 1 bình luận ·
Maintainer thường phản hồi trong vòng 5 ngày