I think this is probably the fastest.
$ docker run -ti python:3.8-slim bash
# pip install mysql-connector-python==8.0.20
# python
>>> import random
>>> import mysql.connector
Segmentation fault
mysql-connector-python now bundles libcrypto.so.1.1 and libssl.so.1.1 from 8.0.20.
$ pip show -f mysql-connector-python | grep lib
Location: /usr/local/lib/python3.8/site-packages
mysql-vendor/libcrypto.so.1.1
mysql-vendor/libssl.so.1.1
import random
Importing random will load libcrypto.so.1.1.
At this time, load libcrypto.so.1.1 installed on the system.
import mysql.connector
This import statement attempts to load libssl.so.1.1 and libcrypto.so.1.1.
At that time, libssl.so.1.1 loads its own bundled one,
libcrypto.so.1.1 is already loaded and will not be loaded.
Therefore, the situation is as follows.
libcrypto.so.1.1 --> /usr/lib/x86_64-linux-gnu/libcrypto.so.1.1
libssl.so.1.1 --> /usr/local/lib/python3.8/site-packages/mysql-vendor/libssl.so.1.1
Since libcrypto.so.1.1 is incompatible, it causes a segmentation fault.
It has already been reported as a bug. https://bugs.mysql.com/bug.php?id=97220
/usr/local/lib/python3.8/site-packages/mysql-vendor/libssl.so.1.1 etc. with LD_PRELOAD8.0.19.I found that it segfaults without loading random separately.
>>> import mysql.connector
Segmentation Fault
The above reasoning cannot be explained a little, so there seems to be another cause. I think it's certain that there is something wrong with the loading order in the bundled library as it can be avoided with LD_PRELOAD.
By the way, strangely, it happens in the python: 3.8-slim image, but not in the python: 3.8 image.
Recommended Posts