Date: Sun, 1 May 2011 18:29:38 GMT From: David Naylor <naylor.b.david@gmail.com> To: freebsd-gnats-submit@FreeBSD.org Subject: ports/156759: [patch] lang/python: kevent does not accept KQ_NOTE_EXIT (and other (f)flags) Message-ID: <201105011829.p41ITchR099135@red.freebsd.org> Resent-Message-ID: <201105011830.p41IUB4e020776@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 156759 >Category: ports >Synopsis: [patch] lang/python: kevent does not accept KQ_NOTE_EXIT (and other (f)flags) >Confidential: no >Severity: non-critical >Priority: low >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: sw-bug >Submitter-Id: current-users >Arrival-Date: Sun May 01 18:30:10 UTC 2011 >Closed-Date: >Last-Modified: >Originator: David Naylor >Release: FreeBSD-current >Organization: Private >Environment: FreeBSD dragon.dg 9.0-CURRENT FreeBSD 9.0-CURRENT #0: Wed Apr 13 19:16:40 SAST 2011 root@dragon.dg:/tmp/home/freebsd9/src/sys/DRAGON amd64 >Description: (Taken from upstream bug report: http://bugs.python.org/issue11973) (This issue appears to affect all releases of python) kevent does not accept all legitimate parameters, such as KQ_NOTE_EXIT. For example: >How-To-Repeat: >Fix: Patch attached with submission follows: --- Modules/selectmodule.c~ 2011-05-01 20:05:12.000000000 +0200 +++ Modules/selectmodule.c 2011-05-01 20:19:46.000000000 +0200 @@ -1246,7 +1246,7 @@ PyObject *pfd; static char *kwlist[] = {"ident", "filter", "flags", "fflags", "data", "udata", NULL}; - static char *fmt = "O|hhi" INTPTRT_FMT_UNIT UINTPTRT_FMT_UNIT ":kevent"; + static char *fmt = "O|hHI" INTPTRT_FMT_UNIT UINTPTRT_FMT_UNIT ":kevent"; EV_SET(&(self->e), 0, EVFILT_READ, EV_ADD, 0, 0, 0); /* defaults */ >Release-Note: >Audit-Trail: >Unformatted: >> from select import * >> kevent(0, KQ_FILTER_PROC, KQ_EV_ADD | KQ_EV_ENABLE, KQ_NOTE_EXIT) OverflowError: signed integer is greater than maximum While the following C code compiles (under -Wall -pedantic) without error, or warning: """ #include <sys/types.h> #include <sys/event.h> #include <sys/time.h> int main(int argc, char **argv) { struct kevent ke; EV_SET(&ke, 0, EVFILT_PROC, EV_ADD | EV_ENABLE, NOTE_EXIT, 0, 0); return (0); } """ Looking at the Modules/selectmodule.c file it is clear that the fields "flags" and "fflags" are defined as T_USHORT and T_UINT however the flags passed to PyArg_ParseTupleAndKeywords are 'h' and 'i' respectively (implying signed numbers). A workaround exists where values X > (2**31 - 1) are passed as (X - 2**32). Also the attached patch fixes the error.
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201105011829.p41ITchR099135>