Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

gh-127545: Replace _Py_ALIGN_AS(V) by _Py_ALIGNED_DEF(N, T)#135209

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Draft
encukou wants to merge3 commits intopython:main
base:main
Choose a base branch
Loading
fromencukou:gc_crash

Conversation

encukou
Copy link
Member

@encukouencukou commentedJun 6, 2025
edited by bedevere-appbot
Loading

_Py_ALIGNED_DEF(N, T) might be a better way to make the various_Alignas alternatives,
which behave in interesting ways,increase (rather thanset) a variable's alignment.

The standardalignas/_Alignas error out if they would decrease the alignment. To prevent that, they can be used again with the defined variable's type.

The standardalignas/_Alignas can't be used on astruct definition, the workaround is to use it on one of thestruct's members.

MSVCdeclspec(aligned) only takes integer literals.

MSVCdeclspec(aligned) had a bug when applied to a combined struct+member definition; a workaround is to separate the struct definition. This avoids the C5274 warning.
This PR does that forPyASCIIObject.state.

zooba reacted with thumbs up emoji
fthainand others added2 commitsJune 2, 2025 10:37
As documented in InternalDocs/garbage_collector.md, the garbage collectorstores flags in the least significant two bits of the _gc_prev pointerin struct PyGC_Head. Consequently, this pointer is only capable of storinga location that's aligned to a 4-byte boundary.This alignment requirement is documented but it's not actually encoded.The code only works when python happens to run on a platform that has asufficiently large minimum alignment for the structs in question.The same problem arises with PyObject pointers because the leastsignificant bits get used for PyStackRef tags.Since we know that 2 bits are needed, we also know the minimum alignmentthat's needed. Let's make that explicit, so the compiler can then makethose bits available.This patch fixes a segfault in _bootstrap_python. In 3.14.0 beta 2this fixes the "Assertion `!PyStackRef_IsTaggedInt(ref)' failed" whenbuilt with --config-pydebug.Also, making the requirements explicit improves clarity.This bug was previously investigated by Adrian Glaubitz here:https://lists.debian.org/debian-68k/2024/11/msg00020.htmlhttps://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1087600Although Adrian's patch isn't really correct (because natural alignmentis not needed), he deserves full credit for finding the root cause.
This is a common façade for the various `_Alignas` alternatives,which behave in interesting ways.The standard `alignas` errors if it would decrease the alignment;to prevent that it can be used again with the defined variable'stype.The standard `alignas` can't be used on a `struct` definition,the workaround is to use it on one of the `struct`'s members.MSVC `declspec(aligned)` only takes integer literals.MSVC `declspec(aligned)` had a bug when applied to a combinedstruct+member definition.The workaround is to separate the struct definition.Do that for `PyASCIIObject.state`.
@encukouencukou added the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelJun 6, 2025
@bedevere-bot
Copy link

🤖 New build scheduled with the buildbot fleet by@encukou for commit512fe58 🤖

Results will be shown at:

https://buildbot.python.org/all/#/grid?branch=refs%2Fpull%2F135209%2Fmerge

If you want to schedule another build, you need to add the🔨 test-with-buildbots label again.

@bedevere-botbedevere-bot removed the 🔨 test-with-buildbotsTest PR w/ buildbots; report in status section labelJun 6, 2025
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

3 participants
@encukou@bedevere-bot@fthain

[8]ページ先頭

©2009-2025 Movatter.jp