[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#214387: libc6: writev() returns -1 with errno == 0



Package: libc6
Version: 2.3.2-7
Severity: important

I have noticed this bug since I updated to libc6 2.3.2-7.  It was not
occurring before, with 2.3.1 (I think it was that, I don't recall).

I discovered this bug whilst using gtk-gnutella, which is opening many
file descriptors.  At time, randomly, gtk-gnutella was crashing reporting
an unexpected errno of 0 on a write.  I added some debugging information
at the places where write() or writev() was occurring, something like
(just showing the code for write(), but the same logic happens with writev):

    r = write(bio->fd, data, amount);

    if (r == -1 && errno == 0) {
        g_warning("write(fd=%d, len=%d) returned -1 with errno = 0, "
            "assuming EAGAIN", bio->fd, data);
        errno = EAGAIN;
    }

And I started to see the following warnings:

    write(fd=56, len=6386) returned -1 with errno = 0, assuming EAGAIN

in my logs.  But gtk-gnutella no longer crashed and continued (gtk-gnutella
checks the errno on failed writes and panics if it is none of the expected
values).

HOWEVER, this bug also randomly happens in libX11, in the XlibInt.c file.
When a write() fails, X reports an error via its I/O reporting callback.
Since gtk-gnutella is a GTK+ application, the GDK installs a handler via
XSetIOErrorHandle(), which in turns logs the error, showing errno.

And its shows a line looking like this:

    Fatal IO error 0 (Success) on X server.

Looking at the code for gdk_x_io_error(), the installed callback, 0 represents
the errno.  So the same thing happens in the libX11, where a write() returns
-1 with an errno set to 0.

I don't think it's a kernel bug, because my kernel has not changed since
April 2003, and I NEVER had this problem before upgrading my libc.

I tried to patch XlibInt.c to install the same workaround as I did in
gtk-gnutella, but unfortunately, the xlibs do not compile properly on my
machine, and anyway this problem should be fixed at the root, not by
patching all the libraries that depend on libc!

-- System Information
Debian Release: 2.2
Architecture: i386
Kernel: Linux nice 2.4.19 #6 SMP Mon Apr 7 22:26:13 MEST 2003 i686
Locale: LANG=fr_FR, LC_CTYPE=fr_FR

Versions of packages libc6 depends on:
ii  libdb1-compat                 2.1.3-4    The Berkeley database routines [gl




Reply to: