Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Some tests in test_smtplib and test_logging failed when Python is configured with --disable-ipv6 #121275

Closed
aisk opened this issue Jul 2, 2024 · 6 comments
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error

Comments

@aisk
Copy link
Contributor

aisk commented Jul 2, 2024

Bug report

Bug description:

There is a error sample:

ERROR: test_basic (test.test_logging.SMTPHandlerTest.test_basic)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/asaka/Codes/cpython/Lib/test/test_logging.py", line 1121, in test_basic
    server = TestSMTPServer((socket_helper.HOST, 0), self.process_message, 0.001,
                            sockmap)
  File "/home/asaka/Codes/cpython/Lib/test/test_logging.py", line 882, in __init__
    smtpd.SMTPServer.__init__(self, addr, None, map=sockmap,
    ~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                              decode_data=True)
                              ^^^^^^^^^^^^^^^^^
  File "/home/asaka/Codes/cpython/Lib/test/support/smtpd.py", line 641, in __init__
    self.bind(localaddr)
    ~~~~~~~~~^^^^^^^^^^^
  File "/home/asaka/Codes/cpython/Lib/test/support/asyncore.py", line 332, in bind
    return self.socket.bind(addr)
           ~~~~~~~~~~~~~~~~^^^^^^
OSError: bind(): bad family

This is caused by SMTPServer is using socket.getaddrinfo to get the socket family, which also include IPv6 result even if IPv6 support is disabled, and it's value will be used to socket.bind:

gai_results = socket.getaddrinfo(*localaddr,
type=socket.SOCK_STREAM)
self.create_socket(gai_results[0][0], gai_results[0][1])

--disable-ipv6 must be specified when --with-thread-sanitizer is specified on my machine (Arch with Clang17), so I think it's better to fix it although --disable-ipv6 is not widely used.

CPython versions tested on:

CPython main branch

Operating systems tested on:

Linux

Linked PRs

@aisk aisk added the type-bug An unexpected behavior, bug, or error label Jul 2, 2024
@aisk aisk added the tests Tests in the Lib/test dir label Jul 2, 2024
@vstinner
Copy link
Member

vstinner commented Jul 5, 2024

--disable-ipv6 must be specified when --with-thread-sanitizer is specified on my machine (Arch with Clang17)

Would you mind to elaborate?

@aisk
Copy link
Contributor Author

aisk commented Jul 6, 2024

I didn't dig too much, but ./configure --with-thread-sanitizer on my machine will cause a:

configure: error: You must get working getaddrinfo() function or pass the "--disable-ipv6" option to configure.

Maybe it's caused by google/sanitizers#1592

@vstinner
Copy link
Member

vstinner commented Jul 8, 2024

Do you want to work on a PR to skip some tests if IPv6 is disabled?

@aisk
Copy link
Contributor Author

aisk commented Jul 8, 2024

Do you want to work on a PR to skip some tests if IPv6 is disabled?

Working on it.

@aisk
Copy link
Contributor Author

aisk commented Jul 17, 2024

Hi @vstinner, I found that the following tests will fail when using --disable-ipv6:

  • test_smtplib
  • test_logging
  • test_asyncio.test_events
  • test_asyncio.test_streams

The first two can be solved by #121276. For the last two, I think it's not just a bug in the tests, but it could also cause problems in user's code.

@aisk
Copy link
Contributor Author

aisk commented Jul 17, 2024

Hi @vstinner, I found that the following tests will fail when using --disable-ipv6:

  • test_smtplib
  • test_logging
  • test_asyncio.test_events
  • test_asyncio.test_streams

The first two can be solved by #121276. For the last two, I think it's not just a bug in the tests, but it could also cause problems in user's code.

Sorry, I missed an import information for the last sentence:

For the last two, I think it's not just a bug in the tests, but it could also cause problems in user's code, and I created #121913 for the detail and future discussion.

kumaraditya303 pushed a commit that referenced this issue Jul 25, 2024
…d IPv6 support (#121276)

Fix test_logging and test_smtplib with Python build withoud IPv6 support
@aisk aisk closed this as completed Jul 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
tests Tests in the Lib/test dir type-bug An unexpected behavior, bug, or error
Projects
None yet
Development

No branches or pull requests

2 participants