Python shell segmentation fault after exiting when importing pygplates

I am trying to build pygplates from source for python 3.9.10 on debian11-bullseye (python:3.9.10-slim-buster on dockerhub), but when importing pygplates in the python code, after exiting (exit()), python shell returns segmentation fault . Not sure if any of the functionalities of pygplates are affected but this is concerning to me

The commands I use to install in the container:

apt-get update
apt-get install -y cmake libglew-dev python3-dev libboost-dev libboost-python-dev libboost-thread-dev libboost-program-options-dev libboost-test-dev libboost-system-dev libqt5opengl5-dev libqt5svg5-dev libqt5xmlpatterns5-dev libgdal-dev libcgal-dev libproj-dev libqwt-qt5-dev zlib1g-dev libfreetype6-dev libfontconfig1-dev libxrender-dev libice-dev libsm-dev qt5-qmake curl unzip
# qt5-default package replaced by qt5-qmake
curl -L -k >
unzip && rm
export CPLUS_INCLUDE_PATH=/usr/include/gdal
export C_INCLUDE_PATH=/usr/include/gdal
cd /usr/src/pygplates_rev28_src/
cmake .
make -j 4 pygplates

also, when compiling the binaries, lots of warning appear as described here, not sure if this affects installation Pygplates warnings from boost

dependencies info:

||/ Name                               Version              Architecture Description
ii  cmake                              3.18.4-2+deb11u1     amd64        cross-platform, open-source make system
ii  g++                                4:10.2.1-1           amd64        GNU C++ compiler
ii  libboost-dev:amd64                    amd64        Boost C++ Libraries development files (default version)
ii  libboost-program-options-dev:amd64             amd64        program options library for C++ (default version)
ii  libboost-python-dev                   amd64        Boost.Python Library development files (default version)
ii  libboost-system-dev:amd64             amd64        Operating system (e.g. diagnostics support) library (default version)
ii  libboost-test-dev:amd64               amd64        components for writing and executing test suites (default version)
ii  libboost-thread-dev:amd64             amd64        portable C++ multi-threading (default version)
ii  libcgal-dev:amd64                  5.2-3                amd64        C++ library for computational geometry (development files)
ii  libfontconfig1-dev:amd64           2.13.1-4.2           amd64        generic font configuration library - dummy package
ii  libfreetype6-dev:amd64             2.10.4+dfsg-1        amd64        FreeType 2 font engine, development files (transitional package)
ii  libgdal-dev                        3.2.2+dfsg-2+deb11u1 amd64        Geospatial Data Abstraction Library - Development files
ii  libglew-dev:amd64                  2.1.0-4+b1           amd64        OpenGL Extension Wrangler - development environment
ii  libice-dev:amd64                   2:1.0.10-1           amd64        X11 Inter-Client Exchange library (development headers)
ii  libproj-dev:amd64                  7.2.1-1              amd64        Cartographic projection library (development files)
ii  libqt5opengl5-dev:amd64            5.15.2+dfsg-9        amd64        Qt 5 OpenGL library development files
ii  libqt5svg5-dev:amd64               5.15.2-3             amd64        Qt 5 SVG module development files
ii  libqt5xmlpatterns5-dev:amd64       5.15.2-3             amd64        Qt 5 XML patterns development files
ii  libqwt-qt5-dev                     6.1.4-2              amd64        Qt widgets library for technical applications (development, qt5)
ii  libsm-dev:amd64                    2:1.2.3-1            amd64        X11 Session Management library (development headers)
ii  libxrender-dev:amd64               1:0.9.10-1           amd64        X Rendering Extension client library (development files)
ii  python3-dev                        3.9.2-3              amd64        header files and a static library for Python (default)
ii  zlib1g-dev:amd64                   1:1.2.11.dfsg-2      amd64        compression library - development
ii  libgl1-mesa-dev:amd64 20.3.5-1     amd64        transitional dummy package
ii  libgl1-mesa-dri:amd64 20.3.5-1     amd64        free implementation of the OpenGL API -- DRI modules
ii  libglu1-mesa:amd64     9.0.1-1      amd64        Mesa OpenGL utility library (GLU)
ii  libglu1-mesa-dev:amd64 9.0.1-1      amd64        Mesa OpenGL utility library -- development files

I am able to build from source and use pygplates on python3.7 on debian10-buster (python:3.7.10 from dockerhub) without any issues but would like to upgrade to debian11 and python 3.9.

Hi vinnie,

It’s an issue with version 3.9 of Python (when using pyGPlates). As you noted the seg fault happens on exiting. I’m currently looking into it and will let you know when it’s fixed (it looks to be a reference count issue in a boost-python object somewhere).

In regard to the warning messages you mentioned, there’s more recent source code (revision 33) mentioned in this post but it won’t fix the above seg fault.

Hi John,
Thanks for the quick reply! Would you know if the issue with Python3.9 affects anything besides seg faulting when exiting the shell? This is something I’m willing to ignore in the meantime if that’s all the extent of the issue.

I think generally it’s probably OK - this particular crash is happening inside pyGPlates (when it cleans up after itself) - well, not exactly inside pygplates but essentially that’s what’s happening.

However Python would return a non-zero error code, so any scripts calling Python might exit there (if they check the return code). And it’s possible some resources inside Python might not get cleaned up (eg, if you also imported other modules besides pygplates that had temporary files, etc, then they might not get removed, that sort of thing).

1 Like

Here’s pyGPlates version 0.35 that fixes the seg fault on exit with Python 3.9 (also I’ve changed the versioning from revision 35 to “0.35”).

This also contains the first Apple M1 build of pyGPlates.