'python3.5 -m ensurepip --> segmentation fault

I installed Python 3.5 from source on Ubuntu 21.10.

sudo make install


...
...
...
if test "xupgrade" != "xno"  ; then \
    case upgrade in \
        upgrade) ensurepip="--upgrade" ;; \
        install|*) ensurepip="" ;; \
    esac; \
     ./python -E -m ensurepip \
        $ensurepip --root=/ ; \
fi

Segmentation fault (core dumped)
make: *** [Makefile:1048: install] Error 139

What could be the reason?

What can I do to debug this?



Solution 1:[1]

Similar problem happened when I tried to install python 3.6 from sources on ubuntu 20.10.

Problem is described here: https://bugs.python.org/issue45700

Workaround which worked for me: after ./configure I have modified Makefile and Makefile.pre and changed optimization flags "O3" -> "O2":

OPT=            -DNDEBUG -g -fwrapv -O3 -Wall      # orig line
OPT=            -DNDEBUG -g -fwrapv -O2 -Wall      # fixed line

After this modification continue as usual: make, ...

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 lesnik