cups-browsed hangs on SIGTERM after cupsd crashed (socket-activated), gets SIGKILLed after 90 s and leaks its dbus:// subscription

Đã đóng
#84 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

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
Loại issue
Lỗi
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
c
Lĩnh vực
backend, devops

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) and browse_poll_cancel_subscription() are skipped, so cups-browsed's dbus:// subscription (notify-events=all, owner "anonymous") stays in subscriptions.conf until 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.service socket/path-activated (TriggeredBy=cups.path cups.socket), Restart=on-failure
  • cups-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 around cupsDoRequest(). 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 broad all subscription, 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

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. 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.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của OpenPrinting/cups-browsed

Tất cả issue của OpenPrinting/cups-browsed

Issue tương tự

Thêm issue về C

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.