Commit 6a55cba
committed
Specify minimum PyGC_Head alignment to fix build failure
As documented in InternalDocs/garbage_collector.md, the garbage collector
stores flags in the least significant two bits of the _gc_prev pointer
in struct PyGC_Head. Consequently, this pointer is only capable of storing
a location that's aligned to a 4-byte boundary.
This alignment requirement is documented but it's not actually encoded.
The code works when python happens to run on a platform that has a large
minimum alignment, but fails otherwise.
Since we know that 2 bits are needed, we also know the minimum alignment
that's needed. Let's make that explicit, so the compiler can then make
sure those 2 bits are available.
This patch fixes a segfault in _bootstrap_python. It also clarifies the
code by making the actual requirement explicit.
This bug was investigated by Adrian Glaubitz here:
https://lists.debian.org/debian-68k/2024/11/msg00020.html
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1087600
Although Adrian's patch isn't really correct (because natural alignment
is not needed), he deserves full credit for finding the root cause.1 parent 12397a5 commit 6a55cba
File tree
2 files changed
+3
-1
lines changed- Include/internal
- Misc/NEWS.d/next/Build
2 files changed
+3
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
16 | 16 | | |
17 | 17 | | |
18 | 18 | | |
| 19 | + | |
19 | 20 | | |
20 | | - | |
| 21 | + | |
21 | 22 | | |
22 | 23 | | |
23 | 24 | | |
| |||
Lines changed: 1 addition & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
0 commit comments