Skip to content

Commit 5d33ee1

Browse files
bpo-34521: Fix tests in test_multiprocessing_spawn to use correctly CMSG_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(). (cherry picked from commit 077061a) Co-authored-by: Pablo Galindo <[email protected]>
1 parent fe48b6d commit 5d33ee1

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Lib/multiprocessing/reduction.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ def recvfds(sock, size):
150150
'''Receive an array of fds over an AF_UNIX socket.'''
151151
a = array.array('i')
152152
bytes_size = a.itemsize * size
153-
msg, ancdata, flags, addr = sock.recvmsg(1, socket.CMSG_LEN(bytes_size))
153+
msg, ancdata, flags, addr = sock.recvmsg(1, socket.CMSG_SPACE(bytes_size))
154154
if not msg and not ancdata:
155155
raise EOFError
156156
try:

0 commit comments

Comments
 (0)