Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Segfault when running test_plot_shapefile without the dbf and shx files #1788

Closed
weiji14 opened this issue Mar 6, 2022 · 1 comment · Fixed by #1789
Closed

Segfault when running test_plot_shapefile without the dbf and shx files #1788

weiji14 opened this issue Mar 6, 2022 · 1 comment · Fixed by #1789
Labels
bug Something isn't working upstream Bug or missing feature of upstream core GMT
Milestone

Comments

@weiji14
Copy link
Member

weiji14 commented Mar 6, 2022

Description of the problem

I ran into a segmentation fault when running make test locally after doing a gmt clear all. The problem is with the new test_plot_shapefile test added in #1695. The crash was also mentioned at #1695 (comment).

fig = Figure()
fig.plot(data="@RidgeTest.shp", pen="1p")
return fig

Should we add an extra line of code like pygmt.which("@RidgeTest.shp @RidgeTest.shx @RidgeTest.dbf @RidgeTest.prj") before fig.plot(data="@RidgeTest.shp", ...)? It seems redundant, but the alternative would be to have people go through the extra step of downloading the cache before running the tests. I'm thinking about potential new contributors who are just used to run pytest or make test, and a segfault doesn't look very good.

Another point is - Will users encounter a segfault if they try to plot a shapefile without all of the other files (shx, dbf)? Again, not a very good look.

Full code that generated the error

gmt clear all
pytest --mpl --verbose -k 'shapefile' pygmt/tests/test_plot.py

Full error message

===================================== test session starts =====================================
platform linux -- Python 3.10.2, pytest-7.0.1, pluggy-1.0.0 -- /home/username/mambaforge/envs/pygmt/bin/python
cachedir: .pytest_cache
Matplotlib: 3.5.1
Freetype: 2.10.4
rootdir: /home/username/Documents/github/pygmt, configfile: pyproject.toml
plugins: mpl-0.14.0, cov-3.0.0
collected 26 items / 25 deselected / 1 selected                                               

pygmt/tests/test_plot.py::test_plot_shapefile Fatal Python error: Segmentation fault

Current thread 0x00007f9f5b963740 (most recent call first):
  File "/home/username/Documents/github/pygmt/pygmt/clib/session.py", line 498 in call_module
  File "/home/username/Documents/github/pygmt/pygmt/src/plot.py", line 273 in plot
  File "/home/username/Documents/github/pygmt/pygmt/helpers/decorators.py", line 725 in new_module
  File "/home/username/Documents/github/pygmt/pygmt/helpers/decorators.py", line 585 in new_module
  File "/home/username/Documents/github/pygmt/pygmt/helpers/decorators.py", line 872 in new_module
  File "/home/username/Documents/github/pygmt/pygmt/helpers/decorators.py", line 804 in new_module
  File "/home/username/Documents/github/pygmt/pygmt/helpers/decorators.py", line 804 in new_module
  File "/home/username/Documents/github/pygmt/pygmt/tests/test_plot.py", line 553 in test_plot_shapefile
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/pytest_mpl/plugin.py", line 594 in item_function_wrapper
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/_pytest/python.py", line 192 in pytest_pyfunc_call
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/pluggy/_callers.py", line 39 in _multicall
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/pluggy/_manager.py", line 80 in _hookexec
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/pluggy/_hooks.py", line 265 in __call__
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/_pytest/python.py", line 1718 in runtest
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/_pytest/runner.py", line 168 in pytest_runtest_call
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/pluggy/_callers.py", line 39 in _multicall
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/pluggy/_manager.py", line 80 in _hookexec
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/pluggy/_hooks.py", line 265 in __call__
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/_pytest/runner.py", line 261 in <lambda>
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/_pytest/runner.py", line 340 in from_call
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/_pytest/runner.py", line 260 in call_runtest_hook
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/_pytest/runner.py", line 221 in call_and_report
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/_pytest/runner.py", line 132 in runtestprotocol
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/_pytest/runner.py", line 113 in pytest_runtest_protocol
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/pluggy/_callers.py", line 39 in _multicall
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/pluggy/_manager.py", line 80 in _hookexec
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/pluggy/_hooks.py", line 265 in __call__
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/_pytest/main.py", line 347 in pytest_runtestloop
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/pluggy/_callers.py", line 39 in _multicall
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/pluggy/_manager.py", line 80 in _hookexec
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/pluggy/_hooks.py", line 265 in __call__
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/_pytest/main.py", line 322 in _main
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/_pytest/main.py", line 268 in wrap_session
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/_pytest/main.py", line 315 in pytest_cmdline_main
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/pluggy/_callers.py", line 39 in _multicall
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/pluggy/_manager.py", line 80 in _hookexec
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/pluggy/_hooks.py", line 265 in __call__
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/_pytest/config/__init__.py", line 165 in main
  File "/home/username/mambaforge/envs/pygmt/lib/python3.10/site-packages/_pytest/config/__init__.py", line 188 in console_main
  File "/home/username/mambaforge/envs/pygmt/bin/pytest", line 11 in <module>

Extension modules: markupsafe._speedups, numpy.core._multiarray_umath, numpy.core._multiarray_tests, numpy.linalg._umath_linalg, numpy.fft._pocketfft_internal, numpy.random._common, numpy.random.bit_generator, numpy.random._bounded_integers, numpy.random._mt19937, numpy.random.mtrand, numpy.random._philox, numpy.random._pcg64, numpy.random._sfc64, numpy.random._generator, matplotlib._c_internal_utils, PIL._imaging, matplotlib._path, kiwisolver, pandas._libs.tslibs.dtypes, pandas._libs.tslibs.base, pandas._libs.tslibs.np_datetime, pandas._libs.tslibs.nattype, pandas._libs.tslibs.timezones, pandas._libs.tslibs.ccalendar, pandas._libs.tslibs.tzconversion, pandas._libs.tslibs.strptime, pandas._libs.tslibs.fields, pandas._libs.tslibs.timedeltas, pandas._libs.tslibs.timestamps, pandas._libs.properties, pandas._libs.tslibs.offsets, 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.tslib, pandas._libs.lib, pandas._libs.hashing, pandas._libs.ops, pandas._libs.arrays, pandas._libs.index, pandas._libs.join, pandas._libs.sparse, pandas._libs.reduction, pandas._libs.indexing, pandas._libs.internals, pandas._libs.writers, pandas._libs.window.aggregations, pandas._libs.window.indexers, pandas._libs.reshape, pandas._libs.groupby, pandas._libs.testing, pandas._libs.parsers, pandas._libs.json, cftime._cftime, netCDF4._netCDF4, scipy._lib._ccallback_c, scipy.sparse._sparsetools, scipy.sparse._csparsetools, scipy.sparse.csgraph._tools, scipy.sparse.csgraph._shortest_path, scipy.sparse.csgraph._traversal, scipy.sparse.csgraph._min_spanning_tree, scipy.sparse.csgraph._flow, scipy.sparse.csgraph._matching, scipy.sparse.csgraph._reordering, scipy.io.matlab._mio_utils, scipy.io.matlab._streams, scipy.io.matlab._mio5_utils, matplotlib._image, sip, PyQt5.sip, PyQt5.QtCore, PyQt5.QtGui, PyQt5.QtWidgets (total: 80)
Segmentation fault (core dumped)

System information

Please paste the output of python -c "import pygmt; pygmt.show_versions()":

PyGMT information:
  version: v0.5.1.dev144+gb58af8bf5.d20220306
System information:
  python: 3.10.2 | packaged by conda-forge | (main, Feb  1 2022, 19:28:35) [GCC 9.4.0]
  executable: /home/username/mambaforge/envs/pygmt/bin/python
  machine: Linux-5.15.0-18-generic-x86_64-with-glibc2.35
Dependency information:
  numpy: 1.22.2
  pandas: 1.4.1
  xarray: 2022.3.0
  netCDF4: 1.5.8
  packaging: 21.3
  ghostscript: 9.54.0
  gmt: 6.3.0
GMT library information:
  binary dir: /home/username/mambaforge/envs/pygmt/bin
  cores: 12
  grid layout: rows
  library path: /home/username/mambaforge/envs/pygmt/lib/libgmt.so
  padding: 2
  plugin dir: /home/username/mambaforge/envs/pygmt/lib/gmt/plugins
  share dir: /home/username/mambaforge/envs/pygmt/share/gmt
  version: 6.3.0
@weiji14 weiji14 added the bug Something isn't working label Mar 6, 2022
@weiji14 weiji14 changed the title Segfault when running test_plot_shapefile without having downloaded cached RidgeTest.shp Segfault when running test_plot_shapefile without the dbf and shx files Mar 6, 2022
@seisman
Copy link
Member

seisman commented Mar 6, 2022

hould we add an extra line of code like pygmt.which("@RidgeTest.shp @RidgeTest.shx @RidgeTest.dbf @RidgeTest.prj") before fig.plot(data="@RidgeTest.shp", ...)? It seems redundant, but the alternative would be to have people go through the extra step of downloading the cache before running the tests.

Sounds good.

Will users encounter a segfault if they try to plot a shapefile without all of the other files (shx, dbf)?

Yes, and was reported in GenericMappingTools/gmt#6400.

@weiji14 weiji14 added the upstream Bug or missing feature of upstream core GMT label Mar 6, 2022
@seisman seisman added this to the 0.6.0 milestone Mar 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working upstream Bug or missing feature of upstream core GMT
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants