Skip to content

Cpython build failure: _bootstrap_python segfault #127545

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
fthain opened this issue Dec 3, 2024 · 11 comments
Open

Cpython build failure: _bootstrap_python segfault #127545

fthain opened this issue Dec 3, 2024 · 11 comments
Labels
3.13 bugs and security fixes 3.14 bugs and security fixes 3.15 new features, bugs and security fixes build The build process and cross-build interpreter-core (Objects, Python, Grammar, and Parser dirs) OS-linux OS-unsupported type-crash A hard crash of the interpreter, possibly with a core dump

Comments

@fthain
Copy link

fthain commented Dec 3, 2024

Bug report

Bug description:

When building dev-lang/python-3.13.0 on Gentoo/m68k, the following crash is observed.

./_bootstrap_python ./Programs/_freeze_module.py abc ./Lib/abc.py Python/frozen_modules/abc.h
gc: collecting generation 0...
make: *** [Makefile:1697: Python/frozen_modules/abc.h] Segmentation fault

A patch is available to resolve this issue. A pull request will follow shortly.

CPython versions tested on:

3.13

Operating systems tested on:

Linux

Linked PRs

@fthain fthain added the type-bug An unexpected behavior, bug, or error label Dec 3, 2024
@fthain
Copy link
Author

fthain commented Jun 1, 2025

Debian has a bug report for this issue.
https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=1105110

@picnixz picnixz added build The build process and cross-build interpreter-core (Objects, Python, Grammar, and Parser dirs) and removed build The build process and cross-build labels Jun 1, 2025
@ZeroIntensity ZeroIntensity added build The build process and cross-build type-crash A hard crash of the interpreter, possibly with a core dump 3.13 bugs and security fixes 3.14 bugs and security fixes OS-linux 3.15 new features, bugs and security fixes and removed type-bug An unexpected behavior, bug, or error labels Jun 2, 2025
@AA-Turner
Copy link
Member

Note m86k is not a supported platform per PEP 11.

@ZeroIntensity
Copy link
Member

Reading the Debian reports, it seems like the plan is for m86k to switch to 4-byte alignment anyway. Do we need to fix this?

@fthain
Copy link
Author

fthain commented Jun 4, 2025

Reading the Debian reports, it seems like the plan is for m86k to switch to 4-byte alignment anyway. Do we need to fix this?

@ZeroIntensity, there is no alternative ABI for Linux/m68k. That's why Debian picked up this patch.

No kernel and toolchain patches have been posted that would constitute a new ABI and no effort has been made to design a new ABI to meet the needs of everyone in the Linux/m68k community for the foreseeable future.

Distro maintainers are primarily concerned with their own software and its users, which is understandable.

Regardless, I think the patch stands on its merits because, IMO, the patch improves the python source code by improving correctness, readability, portability and reusability.

@chewi
Copy link

chewi commented Jun 4, 2025

Reading the Debian reports, it seems like the plan is for m86k to switch to 4-byte alignment anyway. Do we need to fix this?

Opinions on this do vary. 🙂 However, as someone who would like to see 4-byte alignment, I don't want to force it on anybody and would still like this fixed. Thank you for your efforts, @fthain.

@ZeroIntensity
Copy link
Member

I'm worried that this might cause more problems with portability than solutions. Py_ALIGNED, as proposed in the PR, is a thin wrapper around GCC's __attribute__((aligned(...))). We could use something like _Py_ALIGN_AS, but then all of a sudden we're requiring compilers to support C11 _Alignas. Allowing the object structure to have a different alignment based on the compiler does not sound fun.

@AA-Turner
Copy link
Member

We also don't test this, as evidenced by that all buildbots & CI don't fail. I would suggest closing, this is an unsupported platform. Perhaps this could be re-evaluated with a BuildBot, but even then the concerns Peter raises remain.

A

@AA-Turner AA-Turner added the pending The issue will be closed if no feedback is provided label Jun 4, 2025
@thesamesam
Copy link
Contributor

thesamesam commented Jun 4, 2025

We could use something like _Py_ALIGN_AS, but then all of a sudden we're requiring compilers to support C11 _Alignas

Python already requires C11 in its headers.

Also, the bits in capi-workgroup/decisions#61 make clear that it's fine as-needed.

@ZeroIntensity
Copy link
Member

Python already requires C11 in its headers.

Yes, but people notoriously don't always follow it (looking at you, Windows).

I think we should definitely get sign-off from the C API WG before requiring _Py_ALIGN_AS to build the core (especially for something as fundamental as PyObject).

@zooba
Copy link
Member

zooba commented Jun 4, 2025

Python already requires C11 in its headers

It shouldn't, the headers are compatible with C++. _Py_ALIGN_AS is designed to be okay anywhere it's needed, but we'll find out very quickly indeed if it isn't sufficient once it appears in PyObject.

@encukou Thoughts here?

@encukou
Copy link
Member

encukou commented Jun 4, 2025

Thoughts here?

If we want to introduce _Py_ALIGN_AS in the regular builds, this looks like the perfect issue to do it.

It is exactly the use case for _Py_ALIGN_AS.

If there are any issues with PyObject, we'll know quickly. If it turns out that we do need to revert, we “only” lose compatibility with an unsupported platform -- we'd be back to the drawing board on this issue.

I'd hold the 3.13 backport though; and maybe even 3.14 just to be safe.
People building for m68k can backport the patch downstream; in GCC-only land there shouldn't be much to worry about.

I think we should definitely get sign-off from the C API WG before requiring _Py_ALIGN_AS to build the core

The sign-off is done. Judging by the vote, the WG prefers _Py_ALIGN_AS being in both builds. It just wasn't needed, and thus tested, in the regular one yet.

We also don't test this [...] this is an unsupported platform.

Read “unsupported” more as “not in our CI” and less as “we won't spend time on this”.

We wouldn't magically add support for m68k with the patch; it's still on Gentoo/m68k & other maintainers to build, test, and report issues/PRs that we might merge.
The important thing for us is that supported platforms don't break.


Thank you for supporting Python on platforms we can't test here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
3.13 bugs and security fixes 3.14 bugs and security fixes 3.15 new features, bugs and security fixes build The build process and cross-build interpreter-core (Objects, Python, Grammar, and Parser dirs) OS-linux OS-unsupported type-crash A hard crash of the interpreter, possibly with a core dump
Projects
Status: No status
Development

No branches or pull requests

8 participants