-
Notifications
You must be signed in to change notification settings - Fork 235
Description
Description of the problem
I've occasionally had issues with a double free or corruption (out) error when using PyGMT, which others have also seemed to have. Some of the links below may be relevant:
- double free or corruption (out) #394
- pygmt.Figure.plot doesn't work in Linux. #1196
- Problem after update fftw #309
- Discussion of Image Simplifications pangeo-data/pangeo-stacks#125 (comment)
- https://forum.generic-mapping-tools.org/t/about-free-invalid-next-size-fast-or-double-free-or-corruption-out/4591
- https://forum.generic-mapping-tools.org/t/double-free-or-corruption-out-when-fig-plot-is-called/3631
- https://forum.generic-mapping-tools.org/t/how-to-fix-pygmt-session-error-not-available-in-classic-mode/4573
- https://forum.generic-mapping-tools.org/t/grdimage-aborted-due-to-double-free-or-corruption-out/3095
I'd tried to track down the cause of the error systematically. I used the below Python script, and have tested many different environments, and found which combination of packages causes the error.
Environment that causes the issue:
mamba env create -n test_env python pygmt==0.16.0 gmt==6.5.0 liblapack=*=*mkl
Environments that work:
mamba env create -n test_env python pygmt==0.16.0 gmt==6.6.0 liblapack=*=*mkl
mamba env create -n test_env python pygmt==0.16.0 gmt==6.6.0 liblapack=*=*openblas
mamba env create -n test_env python pygmt==0.16.0 gmt==6.5.0 liblapack=*=*openblas
So specifically, the combination of gmt 6.5.0 and liblapack from mkl causes the issue. The environment from #394 also had liblapack from mkl, so this might also be the cause of that error.
Unfortunately, I can't use gmt 6.6.0 yet because of other dependency issues with some other packages I need (i.e., rioxarray, rasterio).
There is a package nomkl which forces liblapack to use openblas, which creates a working environment.
liblapack is required for both gmt and numpy, but maybe if pygmt adds nomlk as a dependency, this will fix this issue?
I'm not sure if this is something that is better raised in GMT.
Broken environment:
created with mamba env create -n test_env python pygmt==0.16.0 gmt==6.5.0 liblapack=*=*mkl
Output from mamba list:
List of packages in environment: "/home/mdtanker/miniforge3/envs/test_env"
Name Version Build Channel
─────────────────────────────────────────────────────────────────────────
_openmp_mutex 4.5 3_kmp_llvm conda-forge
blosc 1.21.6 he440d0b_1 conda-forge
bzip2 1.0.8 h4bc722e_7 conda-forge
c-ares 1.34.5 hb9d3cd8_0 conda-forge
ca-certificates 2025.8.3 hbd8a1cb_0 conda-forge
curl 8.14.1 h332b0f4_0 conda-forge
dcw-gmt 2.2.0 ha770c72_0 conda-forge
fftw 3.3.10 nompi_hf1063bd_110 conda-forge
freexl 2.0.0 h9dce30a_2 conda-forge
geos 3.13.1 h97f6797_0 conda-forge
ghostscript 10.04.0 h5888daf_0 conda-forge
giflib 5.2.2 hd590300_0 conda-forge
gmt 6.5.0 hf220daf_10 conda-forge
gshhg-gmt 2.3.7 ha770c72_1003 conda-forge
hdf4 4.2.15 h2a13503_7 conda-forge
hdf5 1.14.6 nompi_h6e4c0c1_103 conda-forge
icu 75.1 he02047a_0 conda-forge
json-c 0.18 h6688a6e_0 conda-forge
keyutils 1.6.1 h166bdaf_0 conda-forge
krb5 1.21.3 h659f571_0 conda-forge
ld_impl_linux-64 2.44 h1423503_1 conda-forge
lerc 4.0.0 h0aef613_1 conda-forge
libaec 1.1.4 h3f801dc_0 conda-forge
libarchive 3.8.1 gpl_h98cc613_100 conda-forge
libblas 3.9.0 32_hfdb39a5_mkl conda-forge
libbrotlicommon 1.1.0 hb9d3cd8_3 conda-forge
libbrotlidec 1.1.0 hb9d3cd8_3 conda-forge
libbrotlienc 1.1.0 hb9d3cd8_3 conda-forge
libcblas 3.9.0 32_h372d94f_mkl conda-forge
libcurl 8.14.1 h332b0f4_0 conda-forge
libdeflate 1.24 h86f0d12_0 conda-forge
libedit 3.1.20250104 pl5321h7949ede_0 conda-forge
libev 4.33 hd590300_2 conda-forge
libexpat 2.7.1 hecca717_0 conda-forge
libffi 3.4.6 h2dba641_1 conda-forge
libgcc 15.1.0 h767d61c_4 conda-forge
libgcc-ng 15.1.0 h69a702a_4 conda-forge
libgdal-core 3.11.3 ha8f0914_2 conda-forge
libgdal-jp2openjpeg 3.11.3 hdd07572_2 conda-forge
libgfortran 15.1.0 h69a702a_4 conda-forge
libgfortran-ng 15.1.0 h69a702a_4 conda-forge
libgfortran5 15.1.0 hcea5267_4 conda-forge
libglib 2.84.3 hf39c6af_0 conda-forge
libhwloc 2.11.2 default_h3d81e11_1002 conda-forge
libhwy 1.2.0 hf40a0c7_0 conda-forge
libiconv 1.18 h4ce23a2_1 conda-forge
libjpeg-turbo 3.1.0 hb9d3cd8_0 conda-forge
libjxl 0.11.1 h7b0646d_2 conda-forge
libkml 1.3.0 hf539b9f_1021 conda-forge
liblapack 3.9.0 32_hc41d3b0_mkl conda-forge
liblzma 5.8.1 hb9d3cd8_2 conda-forge
libmpdec 4.0.0 hb9d3cd8_0 conda-forge
libnetcdf 4.9.2 nompi_h21f7587_118 conda-forge
libnghttp2 1.64.0 h161d5f1_0 conda-forge
libnsl 2.0.1 hb9d3cd8_1 conda-forge
libpng 1.6.50 h421ea60_1 conda-forge
librttopo 1.1.0 hd718a1a_18 conda-forge
libspatialite 5.1.0 he17ca71_14 conda-forge
libsqlite 3.50.4 h0c1763c_0 conda-forge
libssh2 1.11.1 hcf80075_0 conda-forge
libstdcxx 15.1.0 h8f9b012_4 conda-forge
libstdcxx-ng 15.1.0 h4852527_4 conda-forge
libtiff 4.7.0 hf01ce69_5 conda-forge
libuuid 2.38.1 h0b41bf4_0 conda-forge
libwebp-base 1.6.0 hd42ef1d_0 conda-forge
libxml2 2.13.8 h04c0eec_1 conda-forge
libzip 1.11.2 h6991a6a_0 conda-forge
libzlib 1.3.1 hb9d3cd8_2 conda-forge
llvm-openmp 20.1.8 h4922eb0_1 conda-forge
lz4-c 1.10.0 h5888daf_1 conda-forge
lzo 2.10 h280c20c_1002 conda-forge
minizip 4.0.10 h05a5f5f_0 conda-forge
mkl 2024.2.2 ha770c72_17 conda-forge
muparser 2.3.5 h5888daf_0 conda-forge
ncurses 6.5 h2d0b736_3 conda-forge
numpy 2.3.2 py313hf6604e3_0 conda-forge
openjpeg 2.5.3 h55fea9a_1 conda-forge
openssl 3.5.1 h7b32b05_0 conda-forge
packaging 25.0 pyh29332c3_1 conda-forge
pandas 2.3.1 py313h08cd8bf_0 conda-forge
pcre 8.45 h9c3ff4c_0 conda-forge
pcre2 10.45 hc749103_0 conda-forge
pip 25.2 pyh145f28c_0 conda-forge
proj 9.6.2 h18fbb6c_1 conda-forge
pygmt 0.16.0 pyhd8ed1ab_0 conda-forge
python 3.13.5 hec9711d_102_cp313 conda-forge
python-dateutil 2.9.0.post0 pyhe01879c_2 conda-forge
python-tzdata 2025.2 pyhd8ed1ab_0 conda-forge
python_abi 3.13 8_cp313 conda-forge
pytz 2025.2 pyhd8ed1ab_0 conda-forge
readline 8.2 h8c095d6_2 conda-forge
six 1.17.0 pyhe01879c_1 conda-forge
snappy 1.2.2 h03e3b7b_0 conda-forge
sqlite 3.50.4 hbc0de68_0 conda-forge
tbb 2021.13.0 hceb3a55_1 conda-forge
tk 8.6.13 noxft_hd72426e_102 conda-forge
tzdata 2025b h78e105d_0 conda-forge
uriparser 0.9.8 hac33072_0 conda-forge
xarray 2025.7.1 pyhd8ed1ab_0 conda-forge
xerces-c 3.2.5 h988505b_2 conda-forge
zlib 1.3.1 hb9d3cd8_2 conda-forge
zstd 1.5.7 hb8e6e7a_2 conda-forgeMinimal Complete Verifiable Example
import pygmt
import faulthandler
faulthandler.enable()
region = [150, 240, -10, 60]
x = [183, 235, 215]
y = [-8, 57, 48]
fig = pygmt.Figure()
fig.basemap(region=region, projection="X6i", frame=True)
fig.plot(x=x, y=y, verbose="d")
fig.show()Full error message
pygmt-session [DEBUG]: Use PS filename /home/mdtanker/.gmt/sessions/gmt_session.3922541/gmt_1.ps-
pygmt-session [DEBUG]: gmtinit_get_current_panel: No current panel selected so not in subplot mode
pygmt-session [DEBUG]: Modern mode: Added -R to options since history is available [150/240/-10/60].
pygmt-session [DEBUG]: Modern: Adding -J to options since history is available [X6i].
pygmt-session [DEBUG]: Revised options: @GMTAPI@-S-I-D-V-T-N-000000 -Vd -R -J
plot [DEBUG]: History: Process -R
plot [DEBUG]: History: Process -J
plot [DEBUG]: Got regular w/e/s/n for region (150/240/-10/60)
plot [INFORMATION]: Processing input table data
plot [DEBUG]: Operation will require 2 input columns [n_cols_start = 2]
plot [DEBUG]: Reset MAP_ANNOT_OBLIQUE to anywhere
plot [DEBUG]: Projected values in meters: 150 240 -10 60
plot [INFORMATION]: Linear projection implies y-axis distance exaggeration relative to the x-axis by a factor of 1.28571
plot [DEBUG]: Computed automatic parameters using dimension scaling: 0.969867
plot [INFORMATION]: Map scale is 0.00590551 km per cm or 1:590.551.
plot [DEBUG]: Running in PS mode modern
plot [DEBUG]: Use PS filename /home/mdtanker/.gmt/sessions/gmt_session.3922541/gmt_1.ps-
plot [DEBUG]: Append to hidden PS file /home/mdtanker/.gmt/sessions/gmt_session.3922541/gmt_1.ps-
plot [DEBUG]: Got session name as pygmt-session and default graphics formats as pdf
plot [DEBUG]: Basemap order: Frame = above Grid = below Tick/Annot = below
plot [DEBUG]: gmtapi_init_import: Passed family = Data Table and geometry = Line
plot [DEBUG]: gmtapi_init_import: Added 1 new sources
plot [DEBUG]: GMT_Init_IO: Returned first Input object ID = 0
plot [DEBUG]: gmtapi_begin_io: Input resource access is now enabled [container]
plot [DEBUG]: gmtapi_import_dataset: Passed ID = -1 and mode = 0
plot [INFORMATION]: Duplicating data table from user 2 column arrays of length 3
plot [DEBUG]: Object ID 1 : Registered Data Table Memory Copy 55a666bf6480 as an Input resource with geometry Point [n_objects = 2]
plot [DEBUG]: gmtapi_import_dataset processed 1 resources
plot [DEBUG]: GMT_End_IO: Input resource access is now disabled
plot [INFORMATION]: Plotting segment 0
plot [DEBUG]: GMT_Destroy_Data: freed memory for a Data Table for object 1
plot [DEBUG]: gmtlib_unregister_io: Unregistering object no 1 [n_objects = 1]
plot [DEBUG]: gmtlib_unregister_io: Object no 1 has non-NULL resource pointer
plot [DEBUG]: Current size of half-baked PS file /home/mdtanker/.gmt/sessions/gmt_session.3922541/gmt_1.ps- = 23950.
double free or corruption (out)
Fatal Python error: Aborted
Current thread 0x00007f0bb82713c0 (most recent call first):
File "/home/mdtanker/miniforge3/envs/test_env/lib/python3.13/site-packages/pygmt/clib/session.py", line 451 in destroy
File "/home/mdtanker/miniforge3/envs/test_env/lib/python3.13/site-packages/pygmt/clib/session.py", line 225 in __exit__
File "/home/mdtanker/miniforge3/envs/test_env/lib/python3.13/site-packages/pygmt/src/plot.py", line 282 in plot
File "/home/mdtanker/miniforge3/envs/test_env/lib/python3.13/site-packages/pygmt/helpers/decorators.py", line 783 in new_module
File "/home/mdtanker/miniforge3/envs/test_env/lib/python3.13/site-packages/pygmt/helpers/decorators.py", line 620 in new_module
File "/home/mdtanker/polartoolkit/crash_test_pygmt.py", line 11 in <module>
Extension modules: numpy._core._multiarray_umath, numpy.linalg._umath_linalg, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._pcg64, numpy.random._mt19937, numpy.random._generator, numpy.random._philox, numpy.random._sfc64, numpy.random.mtrand, pandas._libs.tslibs.ccalendar, pandas._libs.tslibs.np_datetime, pandas._libs.tslibs.dtypes, pandas._libs.tslibs.base, pandas._libs.tslibs.nattype, pandas._libs.tslibs.timezones, pandas._libs.tslibs.fields, pandas._libs.tslibs.timedeltas, pandas._libs.tslibs.tzconversion, pandas._libs.tslibs.timestamps, pandas._libs.properties, pandas._libs.tslibs.offsets, pandas._libs.tslibs.strptime, pandas._libs.tslibs.parsing, pandas._libs.tslibs.conversion, pandas._libs.tslibs.period, pandas._libs.tslibs.vectorized, pandas._libs.ops_dispatch, pandas._libs.missing, pandas._libs.hashtable, pandas._libs.algos, pandas._libs.interval, pandas._libs.lib, pandas._libs.ops, pandas._libs.hashing, pandas._libs.arrays, pandas._libs.tslib, pandas._libs.sparse, pandas._libs.internals, pandas._libs.indexing, pandas._libs.index, pandas._libs.writers, pandas._libs.join, pandas._libs.window.aggregations, pandas._libs.window.indexers, pandas._libs.reshape, pandas._libs.groupby, pandas._libs.json, pandas._libs.parsers, pandas._libs.testing (total: 51)
Aborted (core dumped)System information
PyGMT information:
version: v0.16.0
System information:
python: 3.13.5 | packaged by conda-forge | (main, Jun 16 2025, 08:27:50) [GCC 13.3.0]
executable: /home/mdtanker/miniforge3/envs/test_env/bin/python
machine: Linux-6.5.6-300.fc39.x86_64-x86_64-with-glibc2.38
Dependency information:
numpy: 2.3.2
pandas: 2.3.1
xarray: 2025.7.1
packaging: 25.0
contextily: None
geopandas: None
IPython: None
pyarrow: None
rioxarray: None
gdal: None
ghostscript: 10.04.0
GMT library information:
version: 6.5.0
padding: 2
share dir: /home/mdtanker/miniforge3/envs/test_env/share/gmt
plugin dir: /home/mdtanker/miniforge3/envs/test_env/lib/gmt/plugins
library path: /home/mdtanker/miniforge3/envs/test_env/lib/libgmt.so
cores: 16
grid layout: rows
image layout:
binary version: 6.5.0