Skip to contentSkip to conversation

xterm loses data (pty regression)

DISCUSSION Artur Skawina 4 participants 7 messages Aug 10, 2009 Char and misc drivers

lore
Share & tools
lore
#0 lore raw

[I have now gone back to 2.6.30.3 and the writes to the ptys do block there,
so it's a recent regression.]

First noticed it after upgrading to v2.6.31-rc5-246-g90bc1a6, still happens in rc5-381-g7b2aa03.
If i press ^S in an xterm the output stops as expected, but after a ^Q i see only the newly written data, everything in between is lost. Like:

Quoted 1 line

for i in seq 1 111; do echo $i; sleep 1; done

1
2
3
4
9
10
11
12
13
^C

[typed ^S after '4', then ^Q after a few seconds]

If the command doing the printing exits before the ^Q is sent, i don't get any reaction to the ^Q at all, which is why i initially thought it to be an xserver bug.
Text consoles are unaffected, output resumes as it should.

artur
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/

#1 lore raw

[ adding CC:s ]

Quoted 29 lines · Artur Skawina

[I have now gone back to 2.6.30.3 and the writes to the ptys do block there, so it's a recent regression.]

First noticed it after upgrading to v2.6.31-rc5-246-g90bc1a6, still happens in rc5-381-g7b2aa03.
If i press ^S in an xterm the output stops as expected, but after a ^Q i see only the newly written data, everything in between is lost. Like:

Quoted 1 line

for i in seq 1 111; do echo $i; sleep 1; done

1
2
3
4
9
10
11
12
13
^C

[typed ^S after '4', then ^Q after a few seconds]

If the command doing the printing exits before the ^Q is sent, i don't get any reaction to the ^Q at all, which is why i initially thought it to be an xserver bug.
Text consoles are unaffected, output resumes as it should.

artur

#2 lore raw
Quoted 6 lines · Ray Lee
Quoted 5 lines · Artur Skawina

First noticed it after upgrading to v2.6.31-rc5-246-g90bc1a6, still happens in rc5-381-g7b2aa03.
If i press ^S in an xterm the output stops as expected, but after a ^Q i see only the newly written data, everything in between is lost.

Yup, I can confirm that.

Quoted 1 line
Quoted 1 line
Quoted 1 line

for i in seq 1 111; do echo $i; sleep 1; done

(Do ^S/^Q, see data loss)

Will take a look asap, thanks. Although I bet it's the same old commit (d945cb9cc: "pty: Rework the pty layer to use the normal buffering logic") again.

Linus

#3 lore raw
Quoted 12 lines · On Mon, 10 Aug 2009 10:18:41 -0700 (PDT) Linus Torvalds…
Quoted 6 lines · Ray Lee
Quoted 5 lines · Artur Skawina

First noticed it after upgrading to v2.6.31-rc5-246-g90bc1a6, still happens in rc5-381-g7b2aa03.
If i press ^S in an xterm the output stops as expected, but after a ^Q i see only the newly written data, everything in between is lost.

Yup, I can confirm that.

Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

for i in seq 1 111; do echo $i; sleep 1; done

(Do ^S/^Q, see data loss)

Will take a look asap, thanks. Although I bet it's the same old commit (d945cb9cc: "pty: Rework the pty layer to use the normal buffering logic") again.

My guess too. The old pty code abuses throttle/unthrottle in odd ways.

#4 lore raw
In reply to Linus Torvalds
Quoted 11 lines · Linus Torvalds
Quoted 6 lines · Ray Lee
Quoted 5 lines · Artur Skawina

First noticed it after upgrading to v2.6.31-rc5-246-g90bc1a6, still happens in rc5-381-g7b2aa03.
If i press ^S in an xterm the output stops as expected, but after a ^Q i see only the newly written data, everything in between is lost.

Yup, I can confirm that.

Quoted 7 lines
Quoted 1 line
Quoted 1 line
Quoted 1 line

for i in seq 1 111; do echo $i; sleep 1; done

(Do ^S/^Q, see data loss)

Will take a look asap, thanks. Although I bet it's the same old commit (d945cb9cc: "pty: Rework the pty layer to use the normal buffering logic") again.

I think it's really this trivial.

That pty commit removed the checking for tty->stopped in pty_write_buffer() for no clear reason. And when it did that, it broke all the pausing logic in drivers/char/n_tty.c.

Can you confirm?

Linus

---
 drivers/char/pty.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/char/pty.c +2 -0
index 6e6942c..d083c73 100644
@@ -144,6 +144,8 @@ static int pty_write(struct tty_struct *tty, const unsigned char *buf,
 
 static int pty_write_room(struct tty_struct *tty)
 {
+	if (tty->stopped)
+		return 0;
 	return pty_space(tty->link);
 }
 
#5 lore raw
Quoted 13 lines · Linus Torvalds
Quoted 2 lines

(Do ^S/^Q, see data loss)

I think it's really this trivial.

That pty commit removed the checking for tty->stopped in pty_write_buffer() for no clear reason. And when it did that, it broke all the pausing logic in drivers/char/n_tty.c.

Can you confirm?

static int pty_write_room(struct tty_struct *tty) {

drivers/char/pty.c static int pty_write(struct tty_struct *tty, const unsigned char *buf, · line 150

Quoted 4 lines
drivers/char/pty.c +2 -0
+	if (tty->stopped)
+		return 0;
 	return pty_space(tty->link);
 }

w/ this, the pty writes now block again after ^Q, and the data loss is gone.

Thanks,

artur

#6 lore raw
Quoted 10 lines · Artur Skawina

drivers/char/pty.c static int pty_write(struct tty_struct *tty, const unsigned char *buf, · line 150

Quoted 7 lines · Linus Torvalds

static int pty_write_room(struct tty_struct *tty) {

drivers/char/pty.c +2 -0
+	if (tty->stopped)
+		return 0;
 	return pty_space(tty->link);
 }

w/ this, the pty writes now block again after ^Q, and the data loss is gone.

What i meant was "...pty writes now block again after ^S...", sorry.

artur