Article View: linux.debian.bugs.dist
Article #5146Bug#1154506: tuigreet: 2s stall and exit 1 after a successful power command (cursor query vs EventStream)
From: Yaroslav Molochko
Date: Thu, 19 Nov 2026 20:50
Date: Thu, 19 Nov 2026 20:50
147 lines
7367 bytes
7367 bytes
This is a multi-part MIME message sent by reportbug.
--===============7995098388888926326==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
Package: tuigreet
Version: 0.9.1-7
Severity: normal
Tags: upstream patch
X-Debbugs-Cc: carl.keinath@gmail.com, debian4life@f42.me
Dear Maintainer,
after a power command (shutdown/reboot from the F12 menu) completes
successfully, tuigreet stalls for 2 seconds and then exits with status 1,
without clearing the screen and without leaving raw mode.
This has the same root cause as #1153617 but is a different call site, and
it is NOT fixed by upstream commit 3e18bcb, which the pending 0.11.1-1 on
Salsa backports as
event-start-terminal-stream-after-terminal-initialization.patch. I am filing
it separately so that it does not get closed together with #1153617.
Root cause
----------
Since ratatui-core 0.1.1, Terminal::clear() saves and restores the cursor:
let original_cursor = self.backend.get_cursor_position()?;
self.clear_viewport()?;
self.backend.set_cursor_position(original_cursor)?;
(ratatui-core 0.1.2, src/terminal/buffers.rs). With the crossterm backend
that writes ESC[6n and waits up to 2000 ms for the reply.
tuigreet calls terminal.clear() in two places. 3e18bcb fixes the one at
startup by creating the crossterm EventStream only after it. The second one
runs after a power command has succeeded (src/main.rs:107 in 0.9.1,
crates/tuigreet/src/main.rs:183 in 0.11.1):
execute!(io::stdout(), LeaveAlternateScreen)?;
terminal.set_cursor_position((1, 1))?;
terminal.clear()?;
execute!(io::stdout(), Hide)?;
disable_raw_mode()?;
At that point the EventStream is necessarily running, so crossterm cannot
hand the ESC[1;1R reply to cursor::position(). The query times out, and the
`?` skips disable_raw_mode() and turns a successful power command into a
failure exit. Unlike the startup case this is not timing dependent.
Reproduction
------------
The 0.9.1-7 binary in sid is linked against crossterm 0.29.0 and
ratatui-core 0.1.2 (crate paths embedded in /usr/bin/tuigreet).
I ran `/usr/bin/tuigreet --power-shutdown true` in a pty whose master side
answers every ESC[6n with ESC[1;1R, with GREETD_SOCK pointing at a listening
socket, then sent F12 and Enter. Three runs out of three:
0.00s DSR #1 answered
1.00s sent F12
2.01s sent Enter
2.02s DSR #2 answered
4.02s exited, status=1, 2.02s after Enter
The same harness against upstream master with the attached change:
0.00s DSR #1 answered
1.01s sent F12
2.01s sent Enter
2.02s exited, status=0, 0.01s after Enter
For a user this is a 2 second hang of the greeter after choosing
shutdown/reboot, with the VT left uncleared and in raw mode, and greetd
seeing its greeter exit with a failure status while the system goes down.
Fix
---
The attached patch clears through the backend, which emits the clear
sequence without querying the cursor. The cursor has just been positioned
explicitly on the line above and the back buffer is irrelevant because the
function returns right after. It is made against upstream 0.11.1 and is meant
to sit next to the 3e18bcb backport in the pending 0.11.1-1; the same
one-line change applies to src/main.rs:107 of 0.9.1.
Thanks for picking the package up.
-- System Information:
Debian Release: forky/sid
APT prefers unstable
APT policy: (500, 'unstable'), (1, 'experimental')
Architecture: amd64 (x86_64)
Kernel: Linux 7.3.4+deb14-amd64 (SMP w/8 CPU threads; PREEMPT)
Kernel taint flags: TAINT_OOT_MODULE, TAINT_UNSIGNED_MODULE
Locale: LANG=C, LC_CTYPE=C.UTF-8 (charmap=UTF-8), LANGUAGE not set
Shell: /bin/sh linked to /usr/bin/dash
Init: systemd (via /run/systemd/system)
LSM: AppArmor: enabled
--===============7995098388888926326==
Content-Type: text/plain; charset="us-ascii"
MIME-Version: 1.0
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="main-clear-via-the-backend-after-a-power-command.patch"
From: Yaroslav Molochko <onorua@gmail.com>
Date: Thu, 19 Nov 2026 13:15:11 +0200
Subject: main: clear via the backend after a power command
Since ratatui-core 0.1.1, Terminal::clear() saves and restores the cursor,
which makes the crossterm backend send ESC[6n and wait for the reply. After a
power command has run, the EventStream is live, so cursor::position() never
gets the reply and gives up after 2 seconds. The error is propagated by `?`,
so tuigreet stalls, never clears the screen, skips disable_raw_mode() and
exits with a failure status.
Clear through the backend instead, which does not query the cursor.
Origin: other, https://github.com/onorua/tuigreet/commit/6c600b039c1c5eba2c87770148f9ff1d4ad18485
Forwarded: no
---
--- a/crates/tuigreet/src/main.rs
+++ b/crates/tuigreet/src/main.rs
@@ -180,7 +180,11 @@
) {
execute!(io::stdout(), LeaveAlternateScreen)?;
terminal.set_cursor_position((1, 1))?;
- terminal.clear()?;
+ // `Terminal::clear()` queries the cursor position (`ESC[6n`) since
+ // ratatui-core 0.1.1. crossterm cannot read the reply while the
+ // `EventStream` reader holds the input lock, so the query times out
+ // after 2 seconds and the error skips the cleanup below.
+ terminal.backend_mut().clear()?;
execute!(io::stdout(), Hide)?;
disable_raw_mode()?;
--===============7995098388888926326==--
Technical Details
Message-ID:
<O1heV-cXeG-5@gated-at.bofh.it>Path:
mbox-mo1.pugleaf.net!news-lax.pugleaf.net!news-ams.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!news.servidellagleba.it!bofh.it!news.nic.it!robomodShow Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!news-lax.pugleaf.net!news-ams.pugleaf.net!news.tcpreset.net!newsfeed.bofh.team!usenet.goja.nl.eu.org!3.eu.feeder.erje.net!feeder.erje.net!fu-berlin.de!news.servidellagleba.it!bofh.it!news.nic.it!robomod From: Yaroslav Molochko <debian4life@f42.me> Newsgroups: linux.debian.bugs.dist Subject: Bug#1154506: tuigreet: 2s stall and exit 1 after a successful power command (cursor query vs EventStream) Date: Thu, 19 Nov 2026 21:50:01 +0100 Message-ID: <O1heV-cXeG-5@gated-at.bofh.it> X-Original-To: Debian Bug Tracking System <submit@bugs.debian.org> X-Mailbox-Line: From debian-bugs-dist-request@lists.debian.org Thu Nov 19 20:49:10 2026 Old-Return-Path: <debbugs@buxtehude.debian.org> X-Spam-Flag: NO X-Spam-Score: -1.65 Reply-To: Yaroslav Molochko <debian4life@f42.me>, 1154506@bugs.debian.org Resent-To: debian-bugs-dist@lists.debian.org Resent-Cc: carl.keinath@gmail.com, debian4life@f42.me, packages@qa.debian.org X-Debian-Pr-Message: report 1154506 X-Debian-Pr-Package: tuigreet X-Debian-Pr-Keywords: patch upstream X-Debian-Pr-Source: tuigreet Content-Type: multipart/mixed; boundary="===============7995098388888926326==" MIME-Version: 1.0 X-Mailer: reportbug 13.2.0+nmu1 X-Debian-Message: from BTS X-Mailing-List: <debian-bugs-dist@lists.debian.org> archive/latest/2003616 List-ID: <debian-bugs-dist.lists.debian.org> List-URL: <https://lists.debian.org/debian-bugs-dist/> Approved: robomod@news.nic.it Lines: 147 Organization: linux.* mail to news gateway Sender: robomod@news.nic.it X-Original-Date: Thu, 19 Nov 2026 22:46:33 +0200 X-Original-Message-ID: <179512119389.39122.16828207400162368389.reportbug@x1>