Repository navigation
Issues with kqueue #76074
Description
Activity
In Modules/selectmodule.c it is assumed that the kevent structure is defined on FreeBSD and NetBSD as:
struct kevent { uintptr_t ident; short filter; u_short flags; u_int fflags; intptr_t data; uintptr_t udata; };
and on OpenBSD as:
struct kevent { u_int ident; short filter; u_short flags; u_int fflags; intptr_t data; int udata; };
Actually it is defined on FreeBSD as:
struct kevent { uintptr_t ident; short filter; u_short flags; u_int fflags; intptr_t data; void *udata; };
On OpenBSD as:
struct kevent { uintptr_t ident; short filter; u_short flags; u_int fflags; int64_t data; void *udata; };
And on NetBSD as:
struct kevent { uintptr_t ident; uint32_t filter; uint32_t flags; uint32_t fflags; int64_t data; intptr_t udata; };
Other issues are related to rich comparison. Due to integer overflows the ordering is not transitive. The rich comparison protocol is not properly supported, comparing a kevent_event object with a non-kevent_event object don't falls back to the rich comparison methods of the right arguments.
- addedextension-modulesC modules in the Modules dirC modules in the Modules dirtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Oct 29, 2017 The commit b9052a0 broke compilation on FreeBSD:
building 'select' extension
cc -pthread -fPIC -Wno-unused-result -Wsign-compare -g -O0 -Wall -Wstrict-prototypes -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -Werror=implicit-function-declaration -I./Include -I. -I/usr/local/include -I/usr/home/buildbot/python/3.x.koobs-freebsd10/build/Include -I/usr/home/buildbot/python/3.x.koobs-freebsd10/build -c /usr/home/buildbot/python/3.x.koobs-freebsd10/build/Modules/selectmodule.c -o build/temp.freebsd-10.3-STABLE-amd64-3.7-pydebug/usr/home/buildbot/python/3.x.koobs-freebsd10/build/Modules/selectmodule.o
/usr/home/buildbot/python/3.x.koobs-freebsd10/build/Modules/selectmodule.c:1889:63: error: expected ';' at end of declaration
FILTER_FMT_UNIT FLAGS_FMT_UNIT FFLAGS_FMT_UNIT DATA_FMT_UNIT
^
;
1 error generated.
*** WARNING: renaming "_asyncio" since importing it failed: No module named 'select'http://buildbot.python.org/all/#/builders/87/builds/95/steps/3/logs/stdio
Oh, the commit also broke the "x86 Tiger 3.x buildbot:
http://buildbot.python.org/all/#/builders/30/builds/93
======================================================================
FAIL: test_create_event (test.test_kqueue.TestKQueue)
----------------------------------------------------------------------Traceback (most recent call last): File "/Users/db3l/buildarea/3.x.bolen-tiger/build/Lib/test/test_kqueue.py", line 71, in test_create_event self.assertEqual(ev.data, 5) AssertionError: 25769803781 != 5
Oh, I forgot that Mac OS X also in the BSD family.
Thank you Victor for signaling errors.
Tests on all buildbots are passed.
Test fails on x86 Tiger 2.7:
http://buildbot.python.org/all/#/builders/59/builds/17
======================================================================
FAIL: test_create_event (test.test_kqueue.TestKQueue)
----------------------------------------------------------------------Traceback (most recent call last): File "/Users/db3l/buildarea/2.7.bolen-tiger/build/Lib/test/test_kqueue.py", line 39, in test_create_event self.assertRaises(TypeError, cmp, ev, None) AssertionError: TypeError not raised
Same failure on x86-64 El Capitan 2.7/
http://buildbot.python.org/all/#builders/98/builds/17======================================================================
FAIL: test_create_event (test.test_kqueue.TestKQueue)
----------------------------------------------------------------------Traceback (most recent call last): File "/Users/buildbot/buildarea/2.7.billenstein-elcapitan/build/Lib/test/test_kqueue.py", line 39, in test_create_event self.assertRaises(TypeError, cmp, ev, None) AssertionError: TypeError not raised
On also AMD64 FreeBSD 10.x Shared 2.7:
http://buildbot.python.org/all/#/builders/97/builds/17
======================================================================
FAIL: test_create_event (test.test_kqueue.TestKQueue)
----------------------------------------------------------------------Traceback (most recent call last): File "/usr/home/buildbot/python/2.7.koobs-freebsd10/build/Lib/test/test_kqueue.py", line 39, in test_create_event self.assertRaises(TypeError, cmp, ev, None) AssertionError: TypeError not raised
Oh, I didn't test on 2.7.
The old code contradicted the common comparison behavior. It allowed comparing select.kevent with other objects only for equality as for identity.
kevent == otheralways returned False even ifother == keventreturned True.kevent < otherraised a TypeError.The new code uses the default behavior.
kevent == otherreturns the same asother == kevent(False by default if types are not comparable, but may return True ifother.__eq__(kevent)returns True).kevent < otherreturns the same asother > kevent. E.g. raises a TypeError by default in Python 3. But in Python 2 all objects are comparable by default, and this breaks a test which expects that select.kevent is not comparable.There are two ways to fix this:
-
Make select.kevent non-comparable again. This contradicts the default behavior and I don't know reasons why it should be non-comparable, but this was an existing behavior.
-
Remove the tests or change them to test that comparing select.kevent with other object doesn't raise an error.
-
kqueue_event_richcompare() returns NotImplemented if other is not an event:
if (!kqueue_event_Check(o)) { Py_INCREF(Py_NotImplemented); return Py_NotImplemented; }
So I don't understand why tests started to fail with the commit ce51890.
Because the default behavior is different in Python 2 and Python 3. In Python 3 this is a TypeError. In Python 2 all objects are comparable by default.
I suggest to fix the tests, the code looks good to me.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields: