Skip to content

test_socket generates several warnings #110012

Open

Description

@sobolevn

Bug report

Repro: ./python.exe -We -m test test_socket -v

======================================================================
ERROR: testSecondCmsgTruncInData (test.test_socket.RecvmsgIntoRFC3542AncillaryUDP6Test.testSecondCmsgTruncInData)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 4324, in testSecondCmsgTruncInData
    msg, ancdata, flags, addr = self.doRecvmsg(
                                ^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 2940, in doRecvmsg
    result = sock.recvmsg_into([buf], *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeWarning: received malformed or improperly-truncated ancillary data

======================================================================
ERROR: testSingleCmsgTruncInData (test.test_socket.RecvmsgIntoRFC3542AncillaryUDP6Test.testSingleCmsgTruncInData)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 4220, in testSingleCmsgTruncInData
    msg, ancdata, flags, addr = self.doRecvmsg(
                                ^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 2940, in doRecvmsg
    result = sock.recvmsg_into([buf], *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeWarning: received malformed or improperly-truncated ancillary data

======================================================================
ERROR: testCmsgTruncLen0 (test.test_socket.RecvmsgIntoSCMRightsStreamTest.testCmsgTruncLen0)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 3897, in testCmsgTruncLen0
    self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(0), maxdata=0)
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 3877, in checkTruncatedArray
    msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock,
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 2940, in doRecvmsg
    result = sock.recvmsg_into([buf], *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeWarning: received malformed or improperly-truncated ancillary data

======================================================================
ERROR: testCmsgTruncLen0Plus1 (test.test_socket.RecvmsgIntoSCMRightsStreamTest.testCmsgTruncLen0Plus1)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 3903, in testCmsgTruncLen0Plus1
    self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(0) + 1, maxdata=1)
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 3877, in checkTruncatedArray
    msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock,
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 2940, in doRecvmsg
    result = sock.recvmsg_into([buf], *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeWarning: received malformed or improperly-truncated ancillary data

======================================================================
ERROR: testCmsgTruncLen1 (test.test_socket.RecvmsgIntoSCMRightsStreamTest.testCmsgTruncLen1)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 3909, in testCmsgTruncLen1
    self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(SIZEOF_INT),
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 3877, in checkTruncatedArray
    msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock,
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 2940, in doRecvmsg
    result = sock.recvmsg_into([buf], *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeWarning: received malformed or improperly-truncated ancillary data

======================================================================
ERROR: testCmsgTruncLen2Minus1 (test.test_socket.RecvmsgIntoSCMRightsStreamTest.testCmsgTruncLen2Minus1)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 3916, in testCmsgTruncLen2Minus1
    self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(2 * SIZEOF_INT) - 1,
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 3877, in checkTruncatedArray
    msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock,
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 2940, in doRecvmsg
    result = sock.recvmsg_into([buf], *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeWarning: received malformed or improperly-truncated ancillary data

======================================================================
ERROR: testSecondCmsgTruncInData (test.test_socket.RecvmsgRFC3542AncillaryUDP6Test.testSecondCmsgTruncInData)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 4324, in testSecondCmsgTruncInData
    msg, ancdata, flags, addr = self.doRecvmsg(
                                ^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 2849, in doRecvmsg
    result = sock.recvmsg(bufsize, *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeWarning: received malformed or improperly-truncated ancillary data

======================================================================
ERROR: testSingleCmsgTruncInData (test.test_socket.RecvmsgRFC3542AncillaryUDP6Test.testSingleCmsgTruncInData)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 4220, in testSingleCmsgTruncInData
    msg, ancdata, flags, addr = self.doRecvmsg(
                                ^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 2849, in doRecvmsg
    result = sock.recvmsg(bufsize, *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeWarning: received malformed or improperly-truncated ancillary data

======================================================================
ERROR: testCmsgTruncLen0 (test.test_socket.RecvmsgSCMRightsStreamTest.testCmsgTruncLen0)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 3897, in testCmsgTruncLen0
    self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(0), maxdata=0)
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 3877, in checkTruncatedArray
    msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock,
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 2849, in doRecvmsg
    result = sock.recvmsg(bufsize, *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeWarning: received malformed or improperly-truncated ancillary data

======================================================================
ERROR: testCmsgTruncLen0Plus1 (test.test_socket.RecvmsgSCMRightsStreamTest.testCmsgTruncLen0Plus1)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 3903, in testCmsgTruncLen0Plus1
    self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(0) + 1, maxdata=1)
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 3877, in checkTruncatedArray
    msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock,
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 2849, in doRecvmsg
    result = sock.recvmsg(bufsize, *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeWarning: received malformed or improperly-truncated ancillary data

======================================================================
ERROR: testCmsgTruncLen1 (test.test_socket.RecvmsgSCMRightsStreamTest.testCmsgTruncLen1)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 3909, in testCmsgTruncLen1
    self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(SIZEOF_INT),
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 3877, in checkTruncatedArray
    msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock,
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 2849, in doRecvmsg
    result = sock.recvmsg(bufsize, *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeWarning: received malformed or improperly-truncated ancillary data

======================================================================
ERROR: testCmsgTruncLen2Minus1 (test.test_socket.RecvmsgSCMRightsStreamTest.testCmsgTruncLen2Minus1)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 3916, in testCmsgTruncLen2Minus1
    self.checkTruncatedArray(ancbuf=socket.CMSG_LEN(2 * SIZEOF_INT) - 1,
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 3877, in checkTruncatedArray
    msg, ancdata, flags, addr = self.doRecvmsg(self.serv_sock,
                                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/Users/sobolev/Desktop/cpython/Lib/test/test_socket.py", line 2849, in doRecvmsg
    result = sock.recvmsg(bufsize, *args)
             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
RuntimeWarning: received malformed or improperly-truncated ancillary data

----------------------------------------------------------------------
Ran 483 tests in 27.924s

FAILED (errors=12, skipped=245)
test test_socket failed
test_socket failed (12 errors)

== Tests result: FAILURE ==

1 test failed:
    test_socket

Total duration: 28.0 sec
Total tests: run=483 skipped=245
Total test files: run=1/1 failed=1
Result: FAILURE

I have a fix ready.

Linked PRs

Activity

  1. added
    type-bugAn unexpected behavior, bug, or error
    testsTests in the Lib/test dir
    on Sep 28, 2023
  2. self-assigned this
    on Sep 28, 2023
  3. added a commit that references this issue on Sep 28, 2023
  4. serhiy-storchaka commented on Sep 29, 2023

    @serhiy-storchaka
    Member

    These three methods that potentially emit a warning generate 18 tests in total.

    $ ./python -m test test_socket --list-cases -m testSingleCmsgTruncInData -m testSecondCmsgTruncInData -m 'testCmsgTruncLen*'
    test.test_socket.RecvmsgIntoRFC3542AncillaryUDP6Test.testSecondCmsgTruncInData
    test.test_socket.RecvmsgIntoRFC3542AncillaryUDP6Test.testSingleCmsgTruncInData
    test.test_socket.RecvmsgIntoRFC3542AncillaryUDPLITE6Test.testSecondCmsgTruncInData
    test.test_socket.RecvmsgIntoRFC3542AncillaryUDPLITE6Test.testSingleCmsgTruncInData
    test.test_socket.RecvmsgIntoSCMRightsStreamTest.testCmsgTruncLen0
    test.test_socket.RecvmsgIntoSCMRightsStreamTest.testCmsgTruncLen0Minus1
    test.test_socket.RecvmsgIntoSCMRightsStreamTest.testCmsgTruncLen0Plus1
    test.test_socket.RecvmsgIntoSCMRightsStreamTest.testCmsgTruncLen1
    test.test_socket.RecvmsgIntoSCMRightsStreamTest.testCmsgTruncLen2Minus1
    test.test_socket.RecvmsgRFC3542AncillaryUDP6Test.testSecondCmsgTruncInData
    test.test_socket.RecvmsgRFC3542AncillaryUDP6Test.testSingleCmsgTruncInData
    test.test_socket.RecvmsgRFC3542AncillaryUDPLITE6Test.testSecondCmsgTruncInData
    test.test_socket.RecvmsgRFC3542AncillaryUDPLITE6Test.testSingleCmsgTruncInData
    test.test_socket.RecvmsgSCMRightsStreamTest.testCmsgTruncLen0
    test.test_socket.RecvmsgSCMRightsStreamTest.testCmsgTruncLen0Minus1
    test.test_socket.RecvmsgSCMRightsStreamTest.testCmsgTruncLen0Plus1
    test.test_socket.RecvmsgSCMRightsStreamTest.testCmsgTruncLen1
    test.test_socket.RecvmsgSCMRightsStreamTest.testCmsgTruncLen2Minus1
    

    But only 12 of them are failed above. Are they always the same tests? What is the difference between tests that passed and tests that failed? Or was they skipped? Try to run only these test (-m testSingleCmsgTruncInData -m testSecondCmsgTruncInData -m 'testCmsgTruncLen*').

  5. sobolevn commented on Nov 20, 2024

    @sobolevn
    MemberAuthor

    Only two warnings are left:

    » ./python.exe -m test test_socket
    Using random seed: 2077083042
    0:00:00 load avg: 1.67 Run 1 test sequentially in a single process
    0:00:00 load avg: 1.67 [1/1] test_socket
    /Users/sobolev/Desktop/cpython2/Lib/test/test_socket.py:2999: RuntimeWarning: received malformed or improperly-truncated ancillary data
      result = sock.recvmsg_into([buf], *args)
    /Users/sobolev/Desktop/cpython2/Lib/test/test_socket.py:2908: RuntimeWarning: received malformed or improperly-truncated ancillary data
      result = sock.recvmsg(bufsize, *args)
    
    == Tests result: SUCCESS ==
    
    1 test OK.
    
    Total duration: 27.2 sec
    Total tests: run=733 skipped=246
    Total test files: run=1/1
    Result: SUCCESS
    
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

testsTests in the Lib/test dirtopic-socketRelated to the socket, socketserver and selectors modulestype-bugAn unexpected behavior, bug, or error

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions