Title: `_posixsubprocess` passes an incompatible buffer to older musl `getdents64` · Issue #160359 · python/cpython · GitHub
Open Graph Title: `_posixsubprocess` passes an incompatible buffer to older musl `getdents64` · Issue #160359 · python/cpython
X Title: `_posixsubprocess` passes an incompatible buffer to older musl `getdents64` · Issue #160359 · python/cpython
Description: Bug report _posixsubprocess passes a char * buffer to getdents64. In older musl headers, getdents64 is an alias for getdents, which takes struct dirent *. This produces an incompatible-pointer diagnostic. We use musl 1.2.2 for the dynami...
Open Graph Description: Bug report _posixsubprocess passes a char * buffer to getdents64. In older musl headers, getdents64 is an alias for getdents, which takes struct dirent *. This produces an incompatible-pointer diag...
X Description: Bug report _posixsubprocess passes a char * buffer to getdents64. In older musl headers, getdents64 is an alias for getdents, which takes struct dirent *. This produces an incompatible-pointer diag...
Opengraph URL: https://github.com/python/cpython/issues/160359
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"`_posixsubprocess` passes an incompatible buffer to older musl `getdents64`","articleBody":"### Bug report\n\n`_posixsubprocess` passes a `char *` buffer to `getdents64`. In older musl headers, `getdents64` is an alias for `getdents`, which takes `struct dirent *`. This produces an incompatible-pointer diagnostic.\n\nWe use musl 1.2.2 for the dynamic musl builds in `python-build-standalone` and carry a [one-line patch](https://github.com/astral-sh/python-build-standalone/blob/0c5e581b54a4736cdbbe68bdd6d7e571a1dca11e/cpython-unix/patch-posixsubprocess-musl-getdents64.patch) passing the buffer through `void *`. I'd like to upstream that cast; it also works with glibc's declaration.\n\nThe older declaration is discussed [here](https://www.openwall.com/lists/musl/2022/05/24/5). A reduced example is:\n\n```c\n#include \u003cstddef.h>\nstruct dirent;\nint getdents(int, struct dirent *, size_t);\n#define getdents64 getdents\n\nint example(int fd)\n{\n char buffer[4096];\n return getdents64(fd, buffer, sizeof(buffer));\n}\n```\n\nWith GCC 13.3 on Linux, `cc -Werror=incompatible-pointer-types -fsyntax-only example.c` rejects the call. Changing the argument to `(void *)buffer` compiles with both declarations.\n\n\n### CPython versions tested on:\n\nCPython main branch\n\n### Operating systems tested on:\n\nLinux\n\n\u003c!-- gh-linked-prs -->\n### Linked PRs\n* gh-160365\n\u003c!-- /gh-linked-prs -->\n","author":{"url":"https://github.com/zanieb","@type":"Person","name":"zanieb"},"datePublished":"2026-10-22T21:48:11Z","url":"https://github.com/python/cpython/issues/160359"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| 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:c1f3e1c8-c334-5195-3fd9-016a5b3e6a96 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 99F2:2AAD2E:35511CC:4723E39:6B020865 |
| html-safe-nonce | 2d86b8531acbce25640032531dda915ff3762f215664d0611a45f90ed73c10e2 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5OUYyOjJBQUQyRTozNTUxMUNDOjQ3MjNFMzk6NkIwMjA4NjUiLCJ2aXNpdG9yX2lkIjoiMzkxMTk1Mzg2MTA3MzU2OTg5MyIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | 34da20f1677bb6b034e605949a891fec6be7884f5e132cc83e2a1becfb9e783f |
| hovercard-subject-tag | issue:5987989234 |
| 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/160359/issue_layout |
| twitter:image | https://opengraph.githubassets.com/811c33f9e8f8458e680496ecc912bc3efa1691c6ae5bde903d31f63762a0b356/python/cpython/issues/160359 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/811c33f9e8f8458e680496ecc912bc3efa1691c6ae5bde903d31f63762a0b356/python/cpython/issues/160359 |
| og:image:alt | Bug report _posixsubprocess passes a char * buffer to getdents64. In older musl headers, getdents64 is an alias for getdents, which takes struct dirent *. This produces an incompatible-pointer diag... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | zanieb |
| hostname | github.com |
| expected-hostname | github.com |
| None | 87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456 |
| 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 | 423dbb54c5e7bfecc838eb387c1435eb3d0e760d |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width