Skip to content

grdfilter crashes in pygmt if GMT_IN is used  #4577

@seisman

Description

@seisman

Currently, PyGMT opens virtual files using GMT_IN|GMT_IS_REFERENCE, and the following script works well:

import pygmt
grid = pygmt.datasets.load_earth_relief()
smooth_field = pygmt.grdfilter(grid=grid, filter="g600", distance="4")

However, if PyGMT uses GMT_IN, the above script crashes:

grdfilter [ERROR]: G->data is not NULL when memory allocation is about to happen
[Session pygmt-session (3)]: Error returned from GMT API: GMT_PTR_IS_NULL (75)
[Session pygmt-session (3)]: Error returned from GMT API: GMT_PTR_IS_NULL (75)
[Session pygmt-session (3)]: Error returned from GMT API: GMT_OBJECT_NOT_FOUND (60)

...

GMTCLibError: Failed to close virtual file '@GMTAPI@-S-I-G-M-G-N-000000'.

To reproduce the issue, please update your pygmt repository, checkout this PR (GenericMappingTools/pygmt#517), and run the above script.

It crashes with GMT 6.1.1 and GMT master, but it might work for old versions.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions