#985137 Segfault plotting wind data

Package:
python3-magics++
Source:
magics-python
Description:
Python3 support for Magics++
Submitter:
Enrico Zini
Date:
2021-04-02 14:57:27 UTC
Severity:
important
#985137#5
Date:
2021-03-13 14:06:34 UTC
From:
To:
Hello,

thank you for packaging Magics.

In Debian stable, plotting wind data with Magics causes a segmentation
fault. I'm attaching a test case and test data:

$ python3 wflags-segfault.py
Magics :------------------------------------------------------------------
Magics :
Magics :			  Magics 3.3.1 (64 bit)
Magics :
Magics : Meteorological Applications Graphics Integrated Colour System
Magics :
Magics :			    Developed By
Magics :
Magics :   The European Centre for Medium-Range Weather Forecasts
Magics :
Magics :
Magics :------------------------------------------------------------------
Segmentation fault (core dumped)


Enrico

#985137#10
Date:
2021-04-02 14:54:06 UTC
From:
To:
Dear Maintainer,
I could reproduce the issue inside a minimal stable VM.
It crashes with following backtrace [1].

This crash does not show up with the same input in current testing.
The resulting png file shows a "mesh" on top of a map.
The method GribDecoder::visit changed a bit [2].

Kind regards,
Bernhard


[1]
     Program terminated with signal SIGSEGV, Segmentation fault.
     #0  0x00007f4f07840dce in magics::GribDecoder::visit (this=0x1b1f5e0, transformation=...) at ./src/decoders/GribDecoder.cc:371
     371        transformation.setMinMaxX(matrix_->minX(), matrix_->maxX());
     (gdb) bt
     #0  0x00007f4f07840dce in magics::GribDecoder::visit (this=0x1b1f5e0, transformation=...) at ./src/decoders/GribDecoder.cc:371
     #1  0x00007f4f0755a4f2 in magics::VisualAction::visit (this=0x1b1f440, transformation=...) at /usr/include/c++/8/bits/locale_facets.h:877
     #2  0x00007f4f07553cd4 in magics::BasicSceneObject::dispatch<magics::Transformation> (visitor=..., this=0x1b1d900) at /usr/include/c++/8/bits/stl_iterator.h:783
     #3  magics::BasicSceneObject::visit (transformation=..., this=0x1b1d900) at ./src/basic/BasicSceneObject.h:135
     #4  magics::ViewNode::visit (this=0x1b1d900, tree=...) at ./src/basic/ViewNode.cc:286
     #5  0x00007f4f0753a92c in magics::BasicSceneObject::dispatch<magics::SceneLayer> (visitor=..., this=0x1b1d560) at ./src/common/Layout.h:237
     #6  magics::FortranSceneNode::visit (this=0x1b1d560, tree=...) at ./src/basic/SceneNode.cc:134
     #7  0x00007f4f07536e6b in magics::BasicSceneObject::dispatch<magics::Layout> (visitor=..., this=0x16e3c40) at /usr/include/c++/8/bits/stl_iterator.h:783
     #8  magics::RootScenePage::visualise (this=0x16e3c40) at ./src/basic/RootSceneNode.cc:346
     #9  0x00007f4f0753707a in magics::RootSceneNode::visualise (this=0x1a43240) at ./src/basic/RootSceneNode.cc:331
     #10 0x00007f4f075065d5 in magics::FortranMagics::dispatch (this=this@entry=0x1b15740) at ./src/basic/FortranMagics.cc:509
     #11 0x00007f4f075098c0 in magics::FortranMagics::pclose (this=0x1b15740) at ./src/basic/FortranMagics.cc:144
     #12 0x00007f4f0747a27d in pclose_ () at ./src/common/MagicsCalls.cc:1085
     ...
     (gdb) py-bt
     Traceback (most recent call first):
       File "/usr/lib/python3/dist-packages/Magics/Magics.py", line 181, in finalize
         return dll.mag_close()
       File "/usr/lib/python3/dist-packages/Magics/Magics.py", line 149, in wrapped
         err = fn(*args)
       File "/usr/lib/python3/dist-packages/Magics/macro.py", line 523, in _plot
         Magics.finalize()
       File "wflags-segfault.py", line 29, in <module>
     (gdb) print this->matrix_
     $4 = (magics::Matrix *) 0x0

https://sources.debian.org/src/magics++/3.3.1-1/src/decoders/GribDecoder.cc/#L371

[2]
https://sources.debian.org/src/magics++/4.6.0-2/src/decoders/GribDecoder.cc/#L406