Title: multiprocessing child segfault when passing lock as an argument · Issue #119413 · python/cpython · GitHub
Open Graph Title: multiprocessing child segfault when passing lock as an argument · Issue #119413 · python/cpython
X Title: multiprocessing child segfault when passing lock as an argument · Issue #119413 · python/cpython
Description: Crash report What happened? It seems that the below code will serialize the pointer to the lock handle over to the child process, and then rebuild the raw pointer in https://github.com/python/cpython/blob/main/Modules/_multiprocessing/cl...
Open Graph Description: Crash report What happened? It seems that the below code will serialize the pointer to the lock handle over to the child process, and then rebuild the raw pointer in https://github.com/python/cpyth...
X Description: Crash report What happened? It seems that the below code will serialize the pointer to the lock handle over to the child process, and then rebuild the raw pointer in https://github.com/python/cpyth...
Opengraph URL: https://github.com/python/cpython/issues/119413
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"multiprocessing child segfault when passing lock as an argument","articleBody":"# Crash report\r\n\r\n### What happened?\r\n\r\nIt seems that the below code will serialize the pointer to the lock handle over to the child process, and then rebuild the raw pointer in https://github.com/python/cpython/blob/main/Modules/_multiprocessing/clinic/semaphore.c.h#L331\r\n\r\nthis then segfaults the child process - which seems to cause new children to spin up.\r\n\r\n\r\n```python\r\nimport multiprocessing\r\nimport os\r\n\r\ndef _init(l):\r\n print(os.getpid())\r\n print(l)\r\n\r\ndef main():\r\n ctx = multiprocessing.get_context(method=\"spawn\")\r\n lock = multiprocessing.Lock()\r\n with ctx.Pool(1, initializer=_init, initargs=(lock,)) as pool:\r\n ret = pool.map(print, [1])\r\n\r\nif __name__ == \"__main__\":\r\n main()\r\n```\r\n\r\n\r\n### CPython versions tested on:\r\n\r\n3.10, 3.11\r\n\r\n### Operating systems tested on:\r\n\r\nLinux\r\n\r\n### Output from running 'python -VV' on the command line:\r\n\r\n_No response_","author":{"url":"https://github.com/DylanZA","@type":"Person","name":"DylanZA"},"datePublished":"2024-05-22T16:46:39.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/119413/cpython/issues/119413"}
| 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:4c03c49b-0cf0-f697-5af7-2e575b879447 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | BE0A:1C71E6:B0DA9:F6CEA:696A683C |
| html-safe-nonce | ef77e0bad98db4538ba3952c6be1bb4e70af97da9b35b15724a0f52de644670a |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCRTBBOjFDNzFFNjpCMERBOTpGNkNFQTo2OTZBNjgzQyIsInZpc2l0b3JfaWQiOiI2NDM0NDg5NDAzNTQ2NjkxNjQ0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 5b539e825b400d62b1d16ac3a58fbaff93247a8816ce22d8bbc556ed47ef4229 |
| hovercard-subject-tag | issue:2311020237 |
| 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/119413/issue_layout |
| twitter:image | https://opengraph.githubassets.com/49abb5d6fd88aa01ea382e42bf14260fe101e120f4133f0d28a5b86d4850e9a0/python/cpython/issues/119413 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/49abb5d6fd88aa01ea382e42bf14260fe101e120f4133f0d28a5b86d4850e9a0/python/cpython/issues/119413 |
| og:image:alt | Crash report What happened? It seems that the below code will serialize the pointer to the lock handle over to the child process, and then rebuild the raw pointer in https://github.com/python/cpyth... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | DylanZA |
| hostname | github.com |
| expected-hostname | github.com |
| None | 6fea32d5b7276b841b7a803796d9715bc6cfb31ed549fdf9de2948ac25d12ba6 |
| 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 | f2d9f6432a5a115ec709295ae70623f33bb80aee |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width