Title: TSan: data race accessing socket fd · Issue #116912 · python/cpython · GitHub
Open Graph Title: TSan: data race accessing socket fd · Issue #116912 · python/cpython
X Title: TSan: data race accessing socket fd · Issue #116912 · python/cpython
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 holdin...
Open Graph 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 threa...
X 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 threa...
Opengraph URL: https://github.com/python/cpython/issues/116912
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"TSan: data race accessing socket fd","articleBody":"# Bug report\n\n### Bug description:\n\nThe `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:\n\n```\n0:00:31 load avg: 3.29 [15/52/1] test_asyncio.test_sock_lowlevel worker non-zero exit code (Exit code 66)\n==================\nWARNING: ThreadSanitizer: data race (pid=7227)\n Write of size 4 at 0x7fd903611570 by thread T19:\n #0 sock_close /home/runner/work/cpython/cpython/./Modules/socketmodule.c:3339:20 (_socket.cpython-313d-x86_64-linux-gnu.so+0xdbde) (BuildId: 7a12da96172d453cd023792c027755908db49f4e)\n[...]\n\n Previous read of size 4 at 0x7fd903611570 by main thread:\n #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)\n #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)\n #2 sock_call /home/runner/work/cpython/cpython/./Modules/socketmodule.c:1020:12 (_socket.cpython-313d-x86_64-linux-gnu.so+0xf1a1) (BuildId: 7a12da96172d453cd023792c027755908db49f4e)\n #3 sock_sendto /home/runner/work/cpython/cpython/./Modules/socketmodule.c:4532:9 (_socket.cpython-313d-x86_64-linux-gnu.so+0xf1a1)\n[...]\n```\n\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nLinux","author":{"url":"https://github.com/pitrou","@type":"Person","name":"pitrou"},"datePublished":"2024-03-16T15:52:35.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":4},"url":"https://github.com/116912/cpython/issues/116912"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:8fe78c5e-9818-e785-7eeb-ee5ef9b3463f |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | CD62:680AB:1CBE4A:26FB15:6969A74D |
| html-safe-nonce | ff505df28765a80b00ec87e94630c6e4b2e05003a84da68e935cc30c3b0331fd |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDRDYyOjY4MEFCOjFDQkU0QToyNkZCMTU6Njk2OUE3NEQiLCJ2aXNpdG9yX2lkIjoiNjEzNzM2MzAxNjI1MzU0ODM2NSIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | b6388797c2093463a507076b10d933e2fcf32c1bad92d8f5fd5adba7e77c1f53 |
| hovercard-subject-tag | issue:2190109750 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/116912/issue_layout |
| twitter:image | https://opengraph.githubassets.com/e03510e472ab8d940d79ace33761db1083d330d84d7eb950b7a4d977687edc3d/python/cpython/issues/116912 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/e03510e472ab8d940d79ace33761db1083d330d84d7eb950b7a4d977687edc3d/python/cpython/issues/116912 |
| og:image:alt | 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 threa... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | pitrou |
| hostname | github.com |
| expected-hostname | github.com |
| None | 24c4c97a2d520cb286b35e1a4c22d7a4df3c26a2fa28dd7cdf0e65db327b4de7 |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 124667f43168afb6c9c03b7c02eb5b1d2e1be3d9 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width