Hardware:
- Apple Mac Book Pro with M1 Chip
- Mac OS BigSur 11.6
Problem:
Long story short fix (no question)!
I started developing in my python module connecting a rest api using the python requests library over OAuth1 to interact with.
I was using a docker container to develop locally.
- Ubuntu 20.04
- Python 3.8.x
- openssl 1.1.1f
When I ran a requests.delete command in my code it returned always a segmentation error (SIGSEGV).
Fatal Python error: Segmentation fault
CodePudding user response:
After a lot of debugging and searching for this issue I found that in the ssl library the error occurs. And this was the entry point how to solved that issue.
Troubleshoot:
Updating to the latest Python Version of 3.9 and using at least openssl==1.1.1g version.
Here is the Dockerfile how to update Python and openssl on Ubuntu 20.04.
FROM ubuntu:20.04
RUN apt update
# SET PYTHON 3.9 AS DEFAULT PYTHON VERSION ON UBUNTU
RUN apt install -y software-properties-common
RUN add-apt-repository ppa:deadsnakes/ppa
RUN apt -y install python3.9
RUN update-alternatives --install /usr/bin/python3 python3 /usr/bin/python3.9 1
RUN update-alternatives --config python3
WORKDIR /<your_work_dir>
COPY requirements.txt ./
RUN apt install -y pip \
&& pip install -r requirements.txt
# FROM HERE OPENSSL
RUN apt install -y wget
RUN wget https://www.openssl.org/source/openssl-1.1.1l.tar.gz
RUN tar -zxf openssl-1.1.1l.tar.gz
WORKDIR /<your_work_dir>/openssl-1.1.1l
RUN ./config
RUN make
RUN make install
RUN mv /usr/bin/openssl ~/tmp
RUN ln -s /usr/local/bin/openssl /usr/bin/openssl
RUN ldconfig
ENV LD_LIBRARY_PATH="/usr/local/lib:${LD_LIBRARY_PATH}"
Notice:
The error occurs obviously on a docker container ubuntu instance when creating it by a M1 chip. Checking the same code on a windows created docker container (code with the wrong dependencies) on a windows machine works.
I hope I helped some guys not spending too much time to debug and search for this issue.
Best regards and have a good weekend!