Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Bug#507817: screen -r still sometimes fails with "WriteMessage: Bad file descriptor"

29 views
Skip to first unread message

Sami Liedes

unread,
Dec 4, 2008, 1:10:23 PM12/4/08
to
Package: screen
Version: 4.0.3-11
Severity: normal

Hi,

I still sometimes get the error "WriteMessage: Bad file descriptor"
when running screen -r with 4.0.3-11. This is obviously related to
#477739, however the conditions seem somewhat different so I decided
to open a different bug.

Contrary to #477739, I have two sessions:

------------------------------------------------------------
sliedes@lh:~/scratch/chess/scid-open$ screen -ls
There are screens on:
25929.pts-1.lh (11/27/2008 06:47:30 AM) (Detached)
5942.pts-4.lh (11/26/2008 02:38:47 AM) (Attached)
2 Sockets in /var/run/screen/S-sliedes.
------------------------------------------------------------

At least when I last time saw it happen, that was the state of the
sessions: One (the one to be resumed) was detached, the other
attached, and I did not use -d. I'm not exactly sure if it has been so
always.

Unfortunately this seems to happen rather rarely (how rarely? I don't
know, I tried screen -r 27 times and it happened on times #1 and #27
now). I've seen it maybe 10-20 times now. Also I couldn't reproduce it
under strace with maybe 200 tries.

Please tell me if you need me to further try to debug it somehow (you
can assume I know how to use strace, gdb and friends, I'm a
developer).

Sami

-- System Information:
Debian Release: lenny/sid
APT prefers unstable
APT policy: (500, 'unstable'), (500, 'testing')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.27.7 (SMP w/4 CPU cores; PREEMPT)
Locale: LANG=en_US.UTF-8, LC_CTYPE=en_US.UTF-8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages screen depends on:
ii libc6 2.7-16 GNU C Library: Shared libraries
ii libncursesw5 5.7+20081129-1 shared libraries for terminal hand
ii libpam0g 1.0.1-4+b1 Pluggable Authentication Modules l

screen recommends no packages.

screen suggests no packages.

-- no debconf information

--
To UNSUBSCRIBE, email to debian-bugs-...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listm...@lists.debian.org

Jan Christoph Nordholz

unread,
Feb 25, 2009, 8:40:07 PM2/25/09
to
Hi,

sorry it took me so long to get back to you.

> I still sometimes get the error "WriteMessage: Bad file descriptor"
> when running screen -r with 4.0.3-11. This is obviously related to
> #477739, however the conditions seem somewhat different so I decided
> to open a different bug.

Hm. I haven't seen this bug for quite some time now, so any further
material (gdb dumps, strace logs) is highly appreciated. I'll have a
look at the code and check whether I've missed another race condition
(or failed to properly fix the one from #477739).


Thanks!

Jan

signature.asc

Sami Liedes

unread,
Feb 26, 2009, 11:30:13 AM2/26/09
to
On Thu, Feb 26, 2009 at 02:25:45AM +0100, Jan Christoph Nordholz wrote:
> > I still sometimes get the error "WriteMessage: Bad file descriptor"
> > when running screen -r with 4.0.3-11. This is obviously related to
> > #477739, however the conditions seem somewhat different so I decided
> > to open a different bug.
>
> Hm. I haven't seen this bug for quite some time now, so any further
> material (gdb dumps, strace logs) is highly appreciated. I'll have a
> look at the code and check whether I've missed another race condition
> (or failed to properly fix the one from #477739).

Now that I think, I haven't seen it for a while either. And thinking
further, it might have been that the screen I tried to attach to
contained lots of screens started with :screen /dev/pts/nn (qemu with
a serial console). Although for some reason I failed to mention that
in my report, so it might be that either I ruled that out or forgot --
hard to remember which :(

Sami

Vincent Lefevre

unread,
Jul 30, 2015, 8:30:04 AM7/30/15
to
Control: found -1 4.3.1-1

On 2008-12-04 19:50:35 +0200, Sami Liedes wrote:
> I still sometimes get the error "WriteMessage: Bad file descriptor"
> when running screen -r with 4.0.3-11. [...]

I also get this error with a probability of about a few percents.

Note: I usually don't see this error directly because I invoke screen
via a script from my window manager, and the terminal window just
immediately disappears without I have the time to see anything in it
(I'll have to update my script so that error messages can be visible).
As I was wondering, I tried screen manually:

zira:~> =screen -T screen-bce -dRR mutt -t mutt
Remove dead screens with 'screen -wipe'.
WriteMessage: Bad file descriptor

(The = in zsh allows to bypass any alias and shell function.)

--
Vincent Lefèvre <vin...@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)

Vincent Lefevre

unread,
Jul 30, 2015, 9:40:04 AM7/30/15
to
On 2015-07-30 14:20:13 +0200, Vincent Lefevre wrote:
> zira:~> =screen -T screen-bce -dRR mutt -t mutt
> Remove dead screens with 'screen -wipe'.
> WriteMessage: Bad file descriptor

When this happens while a session is already attached, the session
is not detached, i.e. this error occurs quite early.

I could not reproduce the problem with strace.

Axel Beckert

unread,
Jul 30, 2015, 10:00:03 AM7/30/15
to
Hi Vincent,

Vincent Lefevre wrote:
> On 2015-07-30 14:20:13 +0200, Vincent Lefevre wrote:
> > zira:~> =screen -T screen-bce -dRR mutt -t mutt
> > Remove dead screens with 'screen -wipe'.
> > WriteMessage: Bad file descriptor
>
> When this happens while a session is already attached, the session
> is not detached, i.e. this error occurs quite early.

https://savannah.gnu.org/bugs/?func=detailitem&item_id=43744 (the only
upstream bug report where this error message appears) suggests that
this issue maybe related to to session creation time patch in Debian:
https://sources.debian.net/src/screen/4.3.1-1/debian/patches/80EXP_session_creation_time.patch/

Any chance that you can rebuild Debian's screen without(*) that patch
and check if you get the same percentage of error messages?

(*) It's the last patch so doing "quilt pop -a" and then removing it's
entry from debian/patches/series before rebuilding the package
should suffice.

Regards, Axel
--
,''`. | Axel Beckert <a...@debian.org>, http://people.debian.org/~abe/
: :' : | Debian Developer, ftp.ch.debian.org Admin
`. `' | 4096R: 2517 B724 C5F6 CA99 5329 6E61 2FF9 CD59 6126 16B5
`- | 1024D: F067 EA27 26B9 C3FC 1486 202E C09E 1D89 9593 0EDE

Vincent Lefevre

unread,
Jul 31, 2015, 4:00:02 AM7/31/15
to
Hi,

On 2015-07-30 15:51:43 +0200, Axel Beckert wrote:
> Any chance that you can rebuild Debian's screen without(*) that patch
> and check if you get the same percentage of error messages?

The problem is that I can no longer reproduce the bug (with the
official package) while I didn't change anything.

--
Vincent Lefèvre <vin...@vinc17.net> - Web: <https://www.vinc17.net/>
100% accessible validated (X)HTML - Blog: <https://www.vinc17.net/blog/>
Work: CR INRIA - computer arithmetic / AriC project (LIP, ENS-Lyon)


Vincent Lefevre

unread,
Oct 17, 2015, 9:20:03 AM10/17/15
to
On 2015-07-30 15:51:43 +0200, Axel Beckert wrote:
> https://savannah.gnu.org/bugs/?func=detailitem&item_id=43744 (the only
> upstream bug report where this error message appears) suggests that
> this issue maybe related to to session creation time patch in Debian:
> https://sources.debian.net/src/screen/4.3.1-1/debian/patches/80EXP_session_creation_time.patch/
>
> Any chance that you can rebuild Debian's screen without(*) that patch
> and check if you get the same percentage of error messages?
>
> (*) It's the last patch so doing "quilt pop -a" and then removing it's
> entry from debian/patches/series before rebuilding the package
> should suffice.

Several weeks ago, the problem was occurring again quite often.
So, I rebuilt screen without this patch on September 21, and
since then, the problem has no longer occurred.

Note: of course, I have not removed the dead screens.

Vincent Lefevre

unread,
Jun 24, 2016, 9:30:02 AM6/24/16
to
Control: found -1 4.4.0-3
Control: tags -1 patch

I'm tagging patch since the patch is to reverse the patch as mentioned
below.

On 2015-10-17 15:15:22 +0200, Vincent Lefevre wrote:
> On 2015-07-30 15:51:43 +0200, Axel Beckert wrote:
> > https://savannah.gnu.org/bugs/?func=detailitem&item_id=43744 (the only
> > upstream bug report where this error message appears) suggests that
> > this issue maybe related to to session creation time patch in Debian:
> > https://sources.debian.net/src/screen/4.3.1-1/debian/patches/80EXP_session_creation_time.patch/
> >
> > Any chance that you can rebuild Debian's screen without(*) that patch
> > and check if you get the same percentage of error messages?
> >
> > (*) It's the last patch so doing "quilt pop -a" and then removing it's
> > entry from debian/patches/series before rebuilding the package
> > should suffice.
>
> Several weeks ago, the problem was occurring again quite often.
> So, I rebuilt screen without this patch on September 21, and
> since then, the problem has no longer occurred.

I've installed the new screen 4.4.0-3 binary package, which has
the culprit patch, and the bug occurs again:

Remove dead screens with 'screen -wipe'.
WriteMessage: Bad file descriptor
Press [Enter] to quit.

Now this occurs very often:

zira:~> screen -dRR <15:22:36
Remove dead screens with 'screen -wipe'.
WriteMessage: Bad file descriptor
zsh: exit 1 escreen -T screen -dRR
zira:~[1]> screen -dRR <15:22:39
Remove dead screens with 'screen -wipe'.
WriteMessage: Bad file descriptor
zsh: exit 1 escreen -T screen -dRR
zira:~[1]> screen -dRR <15:22:40
Remove dead screens with 'screen -wipe'.
[detached from 5613.mutt]
zira:~> screen -dRR <15:22:42
Remove dead screens with 'screen -wipe'.
WriteMessage: Bad file descriptor
zsh: exit 1 escreen -T screen -dRR
zira:~[1]> screen -dRR <15:22:44
Remove dead screens with 'screen -wipe'.
[detached from 5613.mutt]
zira:~> screen -dRR <15:22:45
Remove dead screens with 'screen -wipe'.
[detached from 5613.mutt]
zira:~> screen -dRR <15:22:47
Remove dead screens with 'screen -wipe'.
WriteMessage: Bad file descriptor
zsh: exit 1 escreen -T screen -dRR
zira:~[1]> screen -dRR <15:23:00
Remove dead screens with 'screen -wipe'.
[detached from 5613.mutt]
zira:~> screen -dRR <15:23:04
Remove dead screens with 'screen -wipe'.
WriteMessage: Bad file descriptor
zsh: exit 1 escreen -T screen -dRR
zira:~[1]> screen -dRR <15:23:05
Remove dead screens with 'screen -wipe'.
WriteMessage: Bad file descriptor
zsh: exit 1 escreen -T screen -dRR
zira:~[1]> screen -dRR <15:23:06
Remove dead screens with 'screen -wipe'.
WriteMessage: Bad file descriptor
zsh: exit 1 escreen -T screen -dRR
zira:~[1]> screen -dRR <15:23:07
Remove dead screens with 'screen -wipe'.
[detached from 5613.mutt]

Vincent Lefevre

unread,
Jun 24, 2016, 9:40:03 AM6/24/16
to
On 2016-06-24 15:23:52 +0200, Vincent Lefevre wrote:
> Now this occurs very often:
[...]

But I cannot reproduce the failure with strace.
A race condition somewhere?

Axel Beckert

unread,
Jun 24, 2016, 10:20:03 AM6/24/16
to
Hi Vincent,

Vincent Lefevre wrote:
> On 2016-06-24 15:23:52 +0200, Vincent Lefevre wrote:
> > Now this occurs very often:
> [...]
>
> But I cannot reproduce the failure with strace.
> A race condition somewhere?

Thanks for that hint. That is a possible explaination why I have
issues reproducing it as well as why users see it with some versions
more often than with others despite the accused patch hasn't seen a
change for quite a while.

I'll check the patch for a potential race condition. But I do also
consider disabling it as there nowadays are enough evidentiary facts
that it's really the cause for this issue.

My preference is neverthelesss to keep the patch -- especially if the
patch can be fixed.

Axel Beckert

unread,
Aug 7, 2016, 1:20:02 PM8/7/16
to
Hi,

Axel Beckert wrote:
> Vincent Lefevre wrote:
> > On 2016-06-24 15:23:52 +0200, Vincent Lefevre wrote:
> > > Now this occurs very often:
> > [...]
> >
> > But I cannot reproduce the failure with strace.
> > A race condition somewhere?
>
> Thanks for that hint. That is a possible explaination why I have
> issues reproducing it as well as why users see it with some versions
> more often than with others despite the accused patch hasn't seen a
> change for quite a while.

While I was able to reproduce the issue rather often (about 30% of all
calls) with one local build, I was later no more able to do so despite
having built the package from the very same commit again. Also
installing 4.4.0-3 didn't help to reproduce the issue again, despite
Vincent confirmed that it happened with that version on his machine.
:-/

> I'll check the patch for a potential race condition. But I do also
> consider disabling it as there nowadays are enough evidentiary facts
> that it's really the cause for this issue.

Jan Christoph Nordholz, the original author of the patch, tried to fix
the issue, but since he couldn't reproduce it nor I can't reproduce it
anymore, even with the old packages, I can not verify or guarantee
that the fix actually works for all users.

So please reopen this bug report in case you run into the "WriteMessage:
Bad file descriptor" again with Debian's screen package, version
4.4.0-4 or later.

I'd also be happy about confirmations that this bug is indeed fixed
with today's upload (4.4.0-4).

Thanks in advance for any feedback on this issue!
0 new messages