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

test_socket (testGetaddrinfo) failing on OS X 10.6.8 (32-bit) #64804

Closed
Wooble mannequin opened this issue Feb 12, 2014 · 6 comments
Closed

test_socket (testGetaddrinfo) failing on OS X 10.6.8 (32-bit) #64804

Wooble mannequin opened this issue Feb 12, 2014 · 6 comments
Assignees
Labels
stdlib Python modules in the Lib dir tests Tests in the Lib/test dir

Comments

@Wooble
Copy link
Mannequin

Wooble mannequin commented Feb 12, 2014

BPO 20605
Nosy @ned-deily, @Wooble

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:

assignee = 'https://github.com/ned-deily'
closed_at = <Date 2014-02-14.06:58:08.787>
created_at = <Date 2014-02-12.02:10:17.542>
labels = ['tests', 'library']
title = 'test_socket (testGetaddrinfo) failing on OS X 10.6.8 (32-bit)'
updated_at = <Date 2014-02-14.06:58:08.786>
user = 'https://github.com/Wooble'

bugs.python.org fields:

activity = <Date 2014-02-14.06:58:08.786>
actor = 'ned.deily'
assignee = 'ned.deily'
closed = True
closed_date = <Date 2014-02-14.06:58:08.787>
closer = 'ned.deily'
components = ['Library (Lib)', 'Tests']
creation = <Date 2014-02-12.02:10:17.542>
creator = 'geoffreyspear'
dependencies = []
files = []
hgrepos = []
issue_num = 20605
keywords = []
message_count = 6.0
messages = ['211053', '211058', '211082', '211120', '211203', '211204']
nosy_count = 3.0
nosy_names = ['ned.deily', 'geoffreyspear', 'python-dev']
pr_nums = []
priority = 'normal'
resolution = 'fixed'
stage = 'resolved'
status = 'closed'
superseder = None
type = None
url = 'https://bugs.python.org/issue20605'
versions = ['Python 2.7', 'Python 3.3', 'Python 3.4']

@Wooble
Copy link
Mannequin Author

Wooble mannequin commented Feb 12, 2014

On OS X 10.6.8, I'm getting the following result for test_socket:

[cpython] % ./python.exe -m test test_socket
[1/1] test_socket
/Users/geoff/Documents/programming/cpython/Lib/test/test_socket.py:1721: RuntimeWarning: received malformed or improperly-truncated ancillary data
  result = sock.recvmsg(bufsize, *args)
/Users/geoff/Documents/programming/cpython/Lib/test/test_socket.py:1812: RuntimeWarning: received malformed or improperly-truncated ancillary data
  result = sock.recvmsg_into([buf], *args)
test test_socket failed -- Traceback (most recent call last):
  File "/Users/geoff/Documents/programming/cpython/Lib/test/test_socket.py", line 1169, in testGetaddrinfo
    socket.getaddrinfo("localhost", None, 0, 0, 0, socket.AI_NUMERICSERV)
socket.gaierror: [Errno 8] nodename nor servname provided, or not known

1 test failed:
test_socket

According to the OS X manpage for getaddrinfo(3), (and RFC 3493) this error is the expected behavior for a POSIX socket implementation:

                AI_NUMERICSERV  If the AI_NUMERICSERV bit is set, then a
                                non-null servname string supplied shall be
                                a numeric port string.  Otherwise, an
                                EAI_NONAME error shall be returned.  This
                                bit shall prevent any type of name resolu-
                                tion service (for example, NIS+) from
                                being invoked.

(servname is the 2nd argument to getaddrinfo(), where the test passes None. EAI_NONAME is Errno 8.)

Confirmed on 2.7.6, 3.3 and current HEAD of 3.4; the offending test code didn't exist in 3.2 and earlier.

@Wooble Wooble mannequin added stdlib Python modules in the Lib dir tests Tests in the Lib/test dir labels Feb 12, 2014
@ned-deily
Copy link
Member

The test works for me on OS X 10.6 and OS X 10.9. My guess is that the problem you are seeing is due to a failing lookup of "localhost". What does your Python report for:

socket.gethostbyname("localhost")

The getaddrinfo(3) man page description does not really cover the case here since Python's socketmodule.c contains a workaround to prevent an OS X segfault (bpo-17269) so the test that is failing is actually equivalent to:

socket.getaddrinfo("localhost", "00", 0, 0, 0, socket.AI_NUMERICSERV)

The equivalent C code executes without error on my systems regardless whether it is meaningful.

@Wooble
Copy link
Mannequin Author

Wooble mannequin commented Feb 12, 2014

Ned:

>>> socket.gethostbyname("localhost")
'127.0.0.1'

>>> socket.getaddrinfo("localhost", "00", 0, 0, 0, socket.AI_NUMERICSERV)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.4/socket.py", line 530, in getaddrinfo
    for res in _socket.getaddrinfo(host, port, family, type, proto, flags):
socket.gaierror: [Errno 8] nodename nor servname provided, or not known

And to show that using AI_NUMERICSERV isn't *completely* broken on my machine:

>>> socket.getaddrinfo("localhost", "80", 0, 0, 0, socket.AI_NUMERICSERV)
[(<AddressFamily.AF_INET: 2>, <SocketType.SOCK_DGRAM: 2>, 17, '', ('127.0.0.1', 80)), (<AddressFamily.AF_INET: 2>, <SocketType.SOCK_STREAM: 1>, 6, '', ('127.0.0.1', 80)), (<AddressFamily.AF_INET6: 30>, <SocketType.SOCK_DGRAM: 2>, 17, '', ('::1', 80, 0, 0)), (<AddressFamily.AF_INET6: 30>, <SocketType.SOCK_STREAM: 1>, 6, '', ('::1', 80, 0, 0)), (<AddressFamily.AF_INET6: 30>, <SocketType.SOCK_DGRAM: 2>, 17, '', ('fe80::1%lo0', 80, 0, 1)), (<AddressFamily.AF_INET6: 30>, <SocketType.SOCK_STREAM: 1>, 6, '', ('fe80::1%lo0', 80, 0, 1))]

@ned-deily
Copy link
Member

OK, OK, it's not just your machine :=) I was finally able to reproduce the same failure on a different 10.6 system. I'm still not sure what the difference between them is but it really doesn't matter. I have a patch forthcoming to make the test work in either case.

@ned-deily ned-deily self-assigned this Feb 13, 2014
@python-dev
Copy link
Mannequin

python-dev mannequin commented Feb 14, 2014

New changeset 6017d19669c3 by Ned Deily in branch '2.7':
Issue bpo-20605: Make test_socket getaddrinfo OS X segfault test more robust.
http://hg.python.org/cpython/rev/6017d19669c3

New changeset 11a75f141cec by Ned Deily in branch '3.3':
Issue bpo-20605: Make test_socket getaddrinfo OS X segfault test more robust.
http://hg.python.org/cpython/rev/11a75f141cec

New changeset 378bdb92e5b7 by Ned Deily in branch 'default':
Issue bpo-20605: Make test_socket getaddrinfo OS X segfault test more robust.
http://hg.python.org/cpython/rev/378bdb92e5b7

@ned-deily
Copy link
Member

The committed changes should prevent spurious test failures. Thanks for the report.

@ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
stdlib Python modules in the Lib dir tests Tests in the Lib/test dir
Projects
None yet
Development

No branches or pull requests

1 participant