Products › lamco-dbus-tools › Use cases

A window that takes 15 seconds to open: Finding a D-Bus deadlock

A window that takes 15 seconds to open: Finding a D-Bus deadlock, two programs waiting on each other, with a dbussee ring and dbustell pending naming the ring.

A viewer's window opens 15 seconds late every time, timed at the caller, and nothing crashes and no log says anything. lamco-dbus-tools found the cause with dbussee, whose ring was running before the stall, and dbustell, whose pending named the two programs waiting on each other.

Real runs: First on 2026-11-30 on Debian 13 on the session bus of a desktop in use, then on 2026-12-01 on a bus of its own, dbus-run-session -- ./run.sh BIN, with a development build of lamco-dbus-tools, version 0.1.0. The two programs are the use case's own, in services.py, not a real application. run.sh ran it; every output quoted is in the use case's directory, and the captures are in out/.

The symptom

A viewer opens a file, and the window appears 15 seconds late, every time, as the run's script timed it at the caller:

$ gdbus call --session --dest com.example.Viewer --object-path /com/example/Viewer --method com.example.Viewer.Open photo.jpg
('opened, thumbnail rendered with failed: Timeout was reached',)
the window waited 15.0 s

Nothing crashes, and no log says anything.

Looking while it hangs finds nothing

$ dbussee pending --all --duration 3
After listening 3 s to 3 messages, no call was waiting for a reply when it ended.

What this can't see:
  A call made before the recording began isn't seen, so it can't be counted as waiting.
  ...

Started 7 seconds into the stall, it can't see the calls already made, and it says so. A message carries no time and no state; whoever wants to know that a call is waiting has to have seen it sent.

A ring, running before it happens

dbussee record --all --ring 60 --on-pending 5000 --after 2 --duration 90 --out caught.json

The recorder keeps the last 60 seconds in memory and nothing else. When a call has waited 5 seconds, it keeps 2 seconds more and writes all of it. Then the window was opened again:

$ dbustell pending caught.json
Of 11 messages, 3 calls were waiting for a reply when it ended:

      7.01 s  :1.13 -> com.example.Viewer (:1.1 python3 (2652006))
              com.example.Viewer.Open on /com/example/Viewer, serial 3
      7.01 s  :1.1 python3 (2652006) -> com.example.Thumbs (:1.2 python3 (2652005))
              com.example.Thumbs.Render on /com/example/Thumbs, serial 12
      7.01 s  :1.2 python3 (2652005) -> com.example.Viewer (:1.1 python3 (2652006))
              com.example.Viewer.Settings on /com/example/Viewer, serial 7

Who waits on whom:
  :1.13 -> :1.1 python3 (2652006) -> :1.2 python3 (2652005)

Waiting on each other, so none of them can answer:
  :1.1 python3 (2652006) -> :1.2 python3 (2652005) -> :1.1 python3 (2652006)

Each connection is named with the process behind it, read from the bus when the recording was made. And as findings, the three waits and the ring:

$ dbustell findings caught.json
CALL-001 (problem): Calls were left without an answer
    3 calls had waited a second or more when the recording ended, the longest :1.13 to com.example.Viewer com.example.Viewer.Open for 7.01 s.
    Records: 25, 26, 27
CALL-002 (problem): Callers wait on each other in a ring
    :1.1 -> :1.2 each wait for the next to answer, and the last for the first, so none can.
    Records: 26, 27

The cause

The window asked the viewer to open the file. The viewer asked the thumbnailer for a thumbnail and waited for it, blocking. The thumbnailer, to render, asked the viewer for its settings and waited too. The viewer couldn't answer while it waited, so the two held each other until the thumbnailer's own 15-second timeout gave up.

What the bus never showed

A recording of the whole stall:

$ dbustell timing whole.json --by method
...
-            com.example.Viewer.Open                              1      0    15.02 s    15.02 s    15.02 s    15.02 s    15.02 s
-            com.example.Thumbs.Render                            1      0    15.01 s    15.01 s    15.01 s    15.01 s    15.01 s
-            com.example.Viewer.Settings                          1      0    15.01 s    15.01 s    15.01 s    15.01 s    15.01 s
$ dbustell errors whole.json
No errors.

All three calls ended about 15 seconds after they were made, at the bus, without an error. The timeout happened inside the thumbnailer; it then answered the viewer, which, free again, answered the thumbnailer's call that nobody was waiting for any more. A timeout is the caller's own decision and never crosses the bus. Only the late answers do, so the timing is where a stall like this shows, and the ring is what names who caused it.

The fix

The viewer mustn't block on a call while it serves calls: Make the call asynchronous, or answer Settings from a second thread or connection. With either, the ring above can't form.

What made it findable

  • The ring had to be running before the stall. A look afterwards sees nothing.
  • --on-pending fired on the wait itself, with no error and no log to fire on.
  • The pending lens joins each waiting call to the waiting caller's own calls, so two programs holding each other show as a ring, not as three slow calls.

Related