Skip to content

Commit

Permalink
bpo-34521: Fix tests in test_multiprocessing_spawn to use correctly C…
Browse files Browse the repository at this point in the history
…MSG_SPACE (GH-9613)

After some failures in AMD64 FreeBSD CURRENT Debug 3.x buildbots
regarding tests in test_multiprocessing_spawn and after examining
similar failures in test_socket, some errors in the calculation of
ancillary data buffers were found in multiprocessing.reduction.

CMSG_LEN() can often be used as the buffer size for recvmsg() to
receive a single item of ancillary data, but RFC 3542 requires portable
applications to use CMSG_SPACE() and thus include space for padding,
even when the item will be the last in the buffer.

The failures we experience are due to the usage of CMSG_LEN() instead of
CMSG_SPACE().
  • Loading branch information
pablogsal authored and vstinner committed Sep 28, 2018
1 parent 1fba2ff commit 077061a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Lib/multiprocessing/reduction.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def recvfds(sock, size):
'''Receive an array of fds over an AF_UNIX socket.'''
a = array.array('i')
bytes_size = a.itemsize * size
msg, ancdata, flags, addr = sock.recvmsg(1, socket.CMSG_LEN(bytes_size))
msg, ancdata, flags, addr = sock.recvmsg(1, socket.CMSG_SPACE(bytes_size))
if not msg and not ancdata:
raise EOFError
try:
Expand Down

0 comments on commit 077061a

Please sign in to comment.