Skip to content

Backport to Python 3.10: Fix #ifdef in sha3module.c #98671

Description

@samypr100

Bug report

Bug

Deadsnakes armhf Python 3.10 builds are currently still failing despite the discussed bug fix in #88209

Disabling unaligned memory access in the _sha3 extension when building CPython 3.10 on ARM-based architectures may not appear to be working as intended under some scenarios such as the deadsnakes build.

On the build ./configure reports checking aligned memory access is required... no per log, but it was mentioned in one of the issues that always defining the NO_MISALIGNED_ACCESSES macro might be the safest fix.

Interestingly enough the Python 3.11 builds are working, which implies this might be resolved with a backport.

Logs

Deadsnakes logs on armhf Python 3.10 builds are currently failing: https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa/+build/24544153

Deadsnakes logs on armhf Python 3.11 builds are currently succeeding:
https://launchpad.net/~deadsnakes/+archive/ubuntu/ppa/+build/24568204

History

Commit 3b2a45f attempted to fix these bug reports (#80696, #88209) but it introduced a subtle issue that may have cause NO_MISALIGNED_ACCESSES to not be defined. Additionally, NO_MISALIGNED_ACCESSES might still need to be forcibly set under certain architectures.

Goal

Since the Python 3.11 build works, one potential commit identified to backport is 10a84ff

Particularly, this line change:

-#if HAVE_ALIGNED_REQUIRED && !defined(NO_MISALIGNED_ACCESSES)
+#if defined(HAVE_ALIGNED_REQUIRED) && !defined(NO_MISALIGNED_ACCESSES)

Motivation

Originally this started with trying to get a Python 3.10 wheel for tflite runtime in tensorflow/tensorflow#56137 (currently not possible) which led us down into a rabbit hole reporting it to deadsnakes team in deadsnakes/issues#232 and then finding the above bug reports. Luckily, we eventually noticed that armhf builds were working in Python 3.11 and not Python 3.10 which made us think it’s something that can be backported.

Closing Thoughts

Given that logs on Python 3.11 armhf builds are currently succeeding, backporting the necessary fixes will help Python 3.10 builds on hardware where unaligned memory accesses are not allowed.

[Edit 10/25/2022]: Added more clarifying thoughts and information.

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions