Linux kernel 6.0.16/6.0.18 breaking Python tests: Allows to bind a socket twice

Hello,
in Fedora, we have discovered a possible regression in the Linux kernel (at least versions 6.0.16 and 6.0.18 are known to be affected) which manifests with several Python test failures in:

  • test_asyncio
  • test_multiprocessing_fork
  • test_multiprocessing_forkserver
  • test_multiprocessing_spawn

The failures look like this:

======================================================================
FAIL: test_bind (test.test_asyncore.TestAPI_UseIPv4Poll.test_bind)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python3.11/test/test_asyncore.py", line 752, in test_bind
    self.assertRaises(OSError, s2.bind, (self.addr[0], port))
AssertionError: OSError not raised by bind

======================================================================
FAIL: test_bind (test.test_asyncore.TestAPI_UseIPv4Select.test_bind)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python3.11/test/test_asyncore.py", line 752, in test_bind
    self.assertRaises(OSError, s2.bind, (self.addr[0], port))
AssertionError: OSError not raised by bind

======================================================================
FAIL: test_bind (test.test_asyncore.TestAPI_UseIPv6Poll.test_bind)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python3.11/test/test_asyncore.py", line 752, in test_bind
    self.assertRaises(OSError, s2.bind, (self.addr[0], port))
AssertionError: OSError not raised by bind

======================================================================
FAIL: test_bind (test.test_asyncore.TestAPI_UseIPv6Select.test_bind)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/usr/lib64/python3.11/test/test_asyncore.py", line 752, in test_bind
    self.assertRaises(OSError, s2.bind, (self.addr[0], port))
AssertionError: OSError not raised by bind 

They are all either:

AssertionError: OSError not raised by bind

or:

AssertionError: OSError not raised by Listener 

I’ve checked and all the failing tests basically do:

  • bind a socket
  • bind it again (and assert failure, which fails)

This might have been caused by kernel/git/stable/linux.git - Linux kernel stable tree

This is fixed in kernel 6.1.4.

I am posting this here in case similar failures strat to happen on the buildbots.

2 Likes

I’ve reported the same problem as Test regressions: "OSError not raised by Listener" in test_asyncio test_multiprocessing_* with 6.0.16+ kernel · Issue #100945 · python/cpython · GitHub.