Bug#214387: libc6: writev() returns -1 with errno == 0
On Mon, Oct 06, 2003 at 10:55:05AM +0200, Raphael Manfredi wrote:
> 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!
Can we have strace output?
--
Daniel Jacobowitz
MontaVista Software Debian GNU/Linux Developer
Reply to: