Closed
Description
Bug report
Bug description:
The sock_fd
member in PySocketSockObject
can be mutated while the socket is being used, for example when calling socket.close
or socket.detach
. However, some other threads can access that member without holding the GIL, and without using atomic instructions. This can trip up Thread Sanitizer in test_asyncio
, for example:
0:00:31 load avg: 3.29 [15/52/1] test_asyncio.test_sock_lowlevel worker non-zero exit code (Exit code 66)
==================
WARNING: ThreadSanitizer: data race (pid=7227)
Write of size 4 at 0x7fd903611570 by thread T19:
#0 sock_close /home/runner/work/cpython/cpython/./Modules/socketmodule.c:3339:20 (_socket.cpython-313d-x86_64-linux-gnu.so+0xdbde) (BuildId: 7a12da96172d453cd023792c027755908db49f4e)
[...]
Previous read of size 4 at 0x7fd903611570 by main thread:
#0 sock_sendto_impl /home/runner/work/cpython/cpython/./Modules/socketmodule.c:4474:29 (_socket.cpython-313d-x86_64-linux-gnu.so+0x131e5) (BuildId: 7a12da96172d453cd023792c027755908db49f4e)
#1 sock_call_ex /home/runner/work/cpython/cpython/./Modules/socketmodule.c:968:19 (_socket.cpython-313d-x86_64-linux-gnu.so+0x10fa1) (BuildId: 7a12da96172d453cd023792c027755908db49f4e)
#2 sock_call /home/runner/work/cpython/cpython/./Modules/socketmodule.c:1020:12 (_socket.cpython-313d-x86_64-linux-gnu.so+0xf1a1) (BuildId: 7a12da96172d453cd023792c027755908db49f4e)
#3 sock_sendto /home/runner/work/cpython/cpython/./Modules/socketmodule.c:4532:9 (_socket.cpython-313d-x86_64-linux-gnu.so+0xf1a1)
[...]
CPython versions tested on:
CPython main branch
Operating systems tested on:
Linux
Metadata
Metadata
Assignees
Labels
C modules in the Modules dirC modules in the Modules dirTests in the Lib/test dirTests in the Lib/test dirAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error