Repository navigation
Mimalloc header is not installed #116984
Description
Activity
- addedtype-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
on Mar 19, 2024 Slightly unrelated, but I see that mimalloc types are embedded directly in structures such as PyInterpreterState or PyThreadState.
Unless mimalloc has a stable ABI, does it risk breaking if an extension module or an application embedding Python uses its own different version of mimalloc?
It's also weird that a third-party library is included from CPython headers. Perhaps it would be better to hide this behind opaque pointers.
I walked through the discussions in #109914 and seems this issue has been already discussed (at least mentioned, but forgotten later? Or not correctly installed after moved to
Internal/? #109914 (review), #109914 (comment), #109914 (comment)).It's somehow intended that this header is not installed, but since cpython decides to installpycore_*.hheaders, the mimalloc headers need to be installed as well (otherwise the core headers are all broken).I also see some related about this:
Unless mimalloc has a stable ABI, does it risk breaking if an extension module or an application embedding Python uses its own different version of mimalloc?
If I'm not mistaken, no symbol is exported (#109914 (comment)), and the reason mimalloc headers are included is that there's extra patches on top of upstream. But the longterm plan is to upstream those (I cannot find the link to this but I believe saw Sam mentioned it somewhere).
Hope it helped @pitrou
If I'm not mistaken, no symbol is exported
Sure, but:
mimalloc.his included, and it could come from whatever install of mimalloc is used by third-party extension code, not necessarily the mimalloc used for building CPython- the binary layout of
PyInterpreterStateandPyThreadStatedepends on the size of mimalloc types, which may vary from one mimalloc version to another.
mimalloc.his only included in internal headers (pycore_xxx.h). Not in any of the public APIs (IncludeorInclude/cpython).PyInterpreterStateis opaque. The mimalloc structs are included in_PyThreadStateImpl, notPyThreadState._PyThreadStateImplis not in any of the public headers.
@colesbury This issue shows that "internal" headers are included by third-party code. Presumably,
PyInterpreterStateandPyThreadStateare also consumed by third-party code.Yes, people sometimes include our internal headers. People also sometimes copy-paste our internal headers. We don't make attempts to avoid language level name conflicts in these cases.
I certainly don't have a horse in this race, but I find it weird to on the one hand fix this issue by installing the mimalloc headers, and on the other hand to not care about the potential consequences of including said headers in third-party code.
I'd also prefer to not need to add
Internal/mimallocas extra include path, even after the headers are installed, if that's possible.- added a commit that references this issue
on Apr 23, 2024 Reopening this for the
Internal/mimallocinclude path issue.- added a commit that references this issue
on May 9, 2024 Closing for the PRs from @colesbury have been landed, thanks for make this more friendly!
Bug report
Bug description:
Mimalloc is introduced in #109914.
This will cause a header not found when building any extension that includes a
pycore_*.hheader as:See following PR for detail.
CPython versions tested on:
3.13, CPython main branch
Operating systems tested on:
Linux, macOS
Linked PRs