Title: Build Failure in posixmodule.c with Clang, ThreadSanitizer, and free-threaded build enabled · Issue #140159 · python/cpython · GitHub
Open Graph Title: Build Failure in posixmodule.c with Clang, ThreadSanitizer, and free-threaded build enabled · Issue #140159 · python/cpython
X Title: Build Failure in posixmodule.c with Clang, ThreadSanitizer, and free-threaded build enabled · Issue #140159 · python/cpython
Description: Description: A build failure occurs in Modules/posixmodule.c when compiling CPython from the main branch using Clang with ThreadSanitizer and the --disable-gil flag. The compilation fails with two distinct types of errors: The compiler r...
Open Graph Description: Description: A build failure occurs in Modules/posixmodule.c when compiling CPython from the main branch using Clang with ThreadSanitizer and the --disable-gil flag. The compilation fails with two ...
X Description: Description: A build failure occurs in Modules/posixmodule.c when compiling CPython from the main branch using Clang with ThreadSanitizer and the --disable-gil flag. The compilation fails with two ...
Opengraph URL: https://github.com/python/cpython/issues/140159
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Build Failure in posixmodule.c with Clang, ThreadSanitizer, and free-threaded build enabled","articleBody":"**Description:**\n\nA build failure occurs in `Modules/posixmodule.c` when compiling CPython from the `main` branch using Clang with ThreadSanitizer and the `--disable-gil` flag.\n\nThe compilation fails with two distinct types of errors:\n1. The compiler reports that the `statx` struct has no member named `stx_atomic_write_unit_max_opt`. This error originates from the `MM` macro expansion within the `pystatx_result_members` definition.\n2. Subsequently, multiple errors are reported for an invalid application of `sizeof` to an incomplete type `PyMemberDef[]`. This happens when the `Py_ARRAY_LENGTH` macro is used on `pystatx_result_members`, indicating that the array's definition was not completed due to the initial error.\n\nThis suggests that the feature detection or conditional compilation logic for the `stx_atomic_write_unit_max_opt` member is not functioning correctly under this specific build configuration.\n\n**Steps to Reproduce:**\n1. Check out the `main` branch of cpython.\n2. Configure the build with the following command:\n ```sh\n CC=clang CXX=clang++ ./configure --with-thread-sanitizer --with-pydebug --disable-gil\n ```\n3. Run the build:\n ```sh\n make\n ```\n\n**Expected Behavior:**\nThe build process should complete successfully.\n\n**Actual Behavior:**\nThe build fails with the following errors logged from `Modules/posixmodule.c`:\n\n```\n../Modules/posixmodule.c:3369:5: error: no member named 'stx_atomic_write_unit_max_opt' in 'statx'\n3369 | MM(stx_atomic_write_unit_max_opt, Py_T_UINT, atomic_write_unit_max_opt,\n| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n3370 | \"maximum optimized size for direct I/O with torn-write protection\"),\n| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n./Modules/posixmodule.c:3325:20: note: expanded from macro 'MM'\n3325 | M(#attr, type, offsetof(Py_statx_result, stx.stx_##member), doc)\n| ~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n/usr/lib/llvm-20/lib/clang/20/include/__stddef_offsetof.h:16:24: note: expanded from macro 'offsetof'\n16 | #define offsetof(t, d) __builtin_offsetof(t, d)\n| ^\n./Modules/posixmodule.c:3323:18: note: expanded from macro 'M'\n3323 | {attr, type, offset, Py_READONLY, PyDoc_STR(doc)}\n| ^~~~~~\n./Modules/posixmodule.c:3427:28: error: invalid application of 'sizeof' to an incomplete type 'PyMemberDef[]' (aka 'struct PyMemberDef[]')\n3427 | for (size_t i = 0; i \u003c Py_ARRAY_LENGTH(pystatx_result_members) - 1; ++i) {\n| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n./Include/pymacro.h:190:12: note: expanded from macro 'Py_ARRAY_LENGTH'\n190 | (sizeof(array) / sizeof((array)[0]))\n| ^~~~~~~\n./Modules/posixmodule.c:3447:9: error: invalid application of 'sizeof' to an incomplete type 'PyMemberDef[]' (aka 'struct PyMemberDef[]')\n3447 | if (Py_ARRAY_LENGTH(pystatx_result_members) \u003e 1\n| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n./Include/pymacro.h:190:12: note: expanded from macro 'Py_ARRAY_LENGTH'\n190 | (sizeof(array) / sizeof((array)[0]))\n| ^~~~~~~\n```\n\n**Environment:**\n* **Compiler:** Clang\n* **Configuration Flags:** `--with-thread-sanitizer --with-pydebug --disable-gil`","author":{"url":"https://github.com/ashm-dev","@type":"Person","name":"ashm-dev"},"datePublished":"2025-10-15T14:06:11.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":3},"url":"https://github.com/140159/cpython/issues/140159"}
| 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:8b9ef99f-9192-4b46-b739-4453e3883822 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B1B6:6DA0E:2C7C58:3DD276:6A5517C2 |
| html-safe-nonce | de819c285adf7b702cc3783b829dbe114d24bf6985df2919e31dc721ef493450 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCMUI2OjZEQTBFOjJDN0M1ODozREQyNzY6NkE1NTE3QzIiLCJ2aXNpdG9yX2lkIjoiMTA4MjMyMjA4ODEwOTYxMDk0NiIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | e57b775362043502e3a758839f46c0dbec688b452ad00b90b0f609003ebba12c |
| hovercard-subject-tag | issue:3518220433 |
| 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/140159/issue_layout |
| twitter:image | https://opengraph.githubassets.com/997137bff172b112396b5c0f3d49c70ea14b863bebe07c05b0954c03ea275c4f/python/cpython/issues/140159 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/997137bff172b112396b5c0f3d49c70ea14b863bebe07c05b0954c03ea275c4f/python/cpython/issues/140159 |
| og:image:alt | Description: A build failure occurs in Modules/posixmodule.c when compiling CPython from the main branch using Clang with ThreadSanitizer and the --disable-gil flag. The compilation fails with two ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | ashm-dev |
| hostname | github.com |
| expected-hostname | github.com |
| None | 682d273eacb2ac51680c6eb9c0b270f029f7ce74c32090f319083c34497e28a5 |
| 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 | 3b6d37c6470adadff4194742daaab9a817cc4980 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width