Bug#63393: marked as forwarded (poll bug)

From: Debian Bug Tracking System (owner@bugs.debian.org)
Date: Mon May 08 2000 - 22:48:01 EST


Your message dated Tue, 9 May 2000 13:46:54 +1000
with message-id <20000509134654.A2078@gondor.apana.org.au>
and subject line [PATCH: 2.3.99pre6] poll(2) fails with EINVAL too easily
has caused the Debian Bug report #63393,
regarding poll bug
to be marked as having been forwarded to the upstream software
author(s) linux-kernel@vger.rutgers.edu.

(NB: If you are a system administrator and have no idea what I am
talking about this indicates a serious mail system misconfiguration
somewhere. Please contact me immediately.)

Darren Benham
(administrator, Debian Bugs database)

Received: (at submit) by bugs.debian.org; 1 May 2000 23:35:51 +0000
Received: (qmail 7118 invoked from network); 1 May 2000 23:35:50 -0000
Received: from patricia.eyeball.com (204.50.30.7)
  by master.debian.org with SMTP; 1 May 2000 23:35:50 -0000
Received: from marwood by patricia.eyeball.com with local (Exim 3.12 #1 (Debian))
        id 12mPiY-00059V-00
        for <submit@bugs.debian.org>; Mon, 01 May 2000 16:35:10 -0700
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message-ID: <14606.5294.740409.245983@patricia.eyeball.com>
Date: Mon, 1 May 2000 16:35:10 -0700 (PDT)
From: marwood@cs.ubc.ca
To: submit@bugs.debian.org
Subject: poll bug
X-Mailer: VM 6.72 under 21.1 (patch 8) "Bryce Canyon" XEmacs Lucid
Sender: David Marwood <marwood@eyeball.com>

Package: kernel-source-2.2.14
Version: 2.2.14-5

There is a bug in the kernel implementation of poll. The attached
program incorrectly fails with the poll setting errno to EINVAL.
Reducing the 900 to 20 causes the poll to succeed, so that's the
invalid parameter.

Removing the comments causes the poll to succeed for the full 900
pollfd entries.

I would guess there's a resizable array of fds in the kernel and the
900 opens expands that array (I can say more about this if somebody's
willing to fix it). To my understanding, there is no limitation on
the number of pollfds supplied to poll(). If I want to fill them all
with -1s, that's still a valid call. In my particular application, I
might use getrlimit(NOFILE) fds so I allocate enough pollfds at the
start, filling the unused ones with -1.

David Marwood

----------------------------------------------------------------

#include <stdio.h>
#include <sys/poll.h>
#include <string.h>
#include <errno.h>
#include <assert.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>

void main(void)
{
  struct pollfd pollfds[900];

  /*
  for (int i = 0; i < 900; i++)
    {
      int ret = open("test.cpp", O_RDONLY);
      printf("ret = %d\n", ret);
      assert(ret != -1);
    }
  */

  for (int i = 0; i < 900; i++)
    pollfds[i].fd = -1;

  int err = poll(pollfds, 900, 0);

  printf("errno = %d = %s\n", errno, strerror(errno));
}

-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.rutgers.edu
Please read the FAQ at http://www.tux.org/lkml/



This archive was generated by hypermail 2b29 : Mon May 15 2000 - 21:00:12 EST