tricontour crashing in QGIS3

I'm looking for help debugging or fixing a problem in matplotlib tricontour. I am using this in a QGIS plugin (www.qgis.org). The call to tricontour causes QGIS to crash. Running python3 on ubuntu 16.04 (matplotlib 1.5.1) and 17.10 (matplotlib 2.0.0).

Running in the debugger gives the following result

Thread 1 "qgis.bin" received signal SIGSEGV, Segmentation fault.
0x00007fff4f7ca098 in qh_initstatistics ()
   from /usr/lib/python3/dist-packages/matplotlib/_qhull.cpython-35m-x86_64-linux-gnu.so
#0 0x00007fff4f7ca098 in qh_initstatistics ()
   from /usr/lib/python3/dist-packages/matplotlib/_qhull.cpython-35m-x86_64-linux-gnu.so
#1 0x00007fff4f7c6f82 in qh_initqhull_start ()
   from /usr/lib/python3/dist-packages/matplotlib/_qhull.cpython-35m-x86_64-linux-gnu.so
#2 0x00007fff4f7d12bc in qh_new_qhull ()
   from /usr/lib/python3/dist-packages/matplotlib/_qhull.cpython-35m-x86_64-linux-gnu.so
#3 0x00007fff4f7a3821 in ?? ()
   from /usr/lib/python3/dist-packages/matplotlib/_qhull.cpython-35m-x86_64-linux-gnu.so
#4 0x00007fff5d977039 in PyCFunction_Call ()
   from /usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0
#5 0x00007fff5da831b5 in PyEval_EvalFrameEx ()
   from /usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0
#6 0x00007fff5db13cac in ?? ()
   from /usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0
#7 0x00007fff5db13d83 in PyEval_EvalCodeEx ()
   from /usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0
#8 0x00007fff5d99bad8 in ?? ()
   from /usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0
....

The python code is

                np.save('/home/chris/temp/data.x',x)
                np.save('/home/chris/temp/data.y',y)
                np.save('/home/chris/temp/data.z',z)
                np.save('/home/chris/temp/data.l',levels)
                print("Extend",repr(extend))
                cs = plt.tricontour(x, y, z, levels, extend=extend)

I've called matplotlib from a simple python script using the saved data (np.save) in a simply python script and it runs without problem, so the problem appears to arise running within the QGIS3 python environment.

Can you suggest any reason why it might be different running from within QGIS and how I can work around/fix this!

Thanks
Chris Crook

···

________________________________

This message contains information, which may be in confidence and may be subject to legal privilege. If you are not the intended recipient, you must not peruse, use, disseminate, distribute or copy this message. If you have received this message in error, please notify us immediately (Phone 0800 665 463 or info at linz.govt.nz) and destroy the original message. LINZ accepts no responsibility for changes to this email, or for any attachments, after its transmission from LINZ. Thank You.

Looks like a conflict for the qhull library, which matplotlib vendors and
builds as a part of its packaging. How did qgis and matplotlib get
installed? Perhaps they were built with conflicting flags, perhaps? Just a
few ideas off of the top of my head.

Ben Root

···

On Sun, Feb 4, 2018 at 3:55 PM, Chris Crook <ccrook at linz.govt.nz> wrote:

I'm looking for help debugging or fixing a problem in matplotlib
tricontour. I am using this in a QGIS plugin (www.qgis.org). The call
to tricontour causes QGIS to crash. Running python3 on ubuntu 16.04
(matplotlib 1.5.1) and 17.10 (matplotlib 2.0.0).

Running in the debugger gives the following result

Thread 1 "qgis.bin" received signal SIGSEGV, Segmentation fault.
0x00007fff4f7ca098 in qh_initstatistics ()
   from /usr/lib/python3/dist-packages/matplotlib/_qhull.
cpython-35m-x86_64-linux-gnu.so
#0 0x00007fff4f7ca098 in qh_initstatistics ()
   from /usr/lib/python3/dist-packages/matplotlib/_qhull.
cpython-35m-x86_64-linux-gnu.so
#1 0x00007fff4f7c6f82 in qh_initqhull_start ()
   from /usr/lib/python3/dist-packages/matplotlib/_qhull.
cpython-35m-x86_64-linux-gnu.so
#2 0x00007fff4f7d12bc in qh_new_qhull ()
   from /usr/lib/python3/dist-packages/matplotlib/_qhull.
cpython-35m-x86_64-linux-gnu.so
#3 0x00007fff4f7a3821 in ?? ()
   from /usr/lib/python3/dist-packages/matplotlib/_qhull.
cpython-35m-x86_64-linux-gnu.so
#4 0x00007fff5d977039 in PyCFunction_Call ()
   from /usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0
#5 0x00007fff5da831b5 in PyEval_EvalFrameEx ()
   from /usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0
#6 0x00007fff5db13cac in ?? ()
   from /usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0
#7 0x00007fff5db13d83 in PyEval_EvalCodeEx ()
   from /usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0
#8 0x00007fff5d99bad8 in ?? ()
   from /usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0
....

The python code is

                np.save('/home/chris/temp/data.x',x)
                np.save('/home/chris/temp/data.y',y)
                np.save('/home/chris/temp/data.z',z)
                np.save('/home/chris/temp/data.l',levels)
                print("Extend",repr(extend))
                cs = plt.tricontour(x, y, z, levels, extend=extend)

I've called matplotlib from a simple python script using the saved data
(np.save) in a simply python script and it runs without problem, so the
problem appears to arise running within the QGIS3 python environment.

Can you suggest any reason why it might be different running from within
QGIS and how I can work around/fix this!

Thanks
Chris Crook

________________________________

This message contains information, which may be in confidence and may be
subject to legal privilege. If you are not the intended recipient, you must
not peruse, use, disseminate, distribute or copy this message. If you have
received this message in error, please notify us immediately (Phone 0800
665 463 or info at linz.govt.nz) and destroy the original message. LINZ
accepts no responsibility for changes to this email, or for any
attachments, after its transmission from LINZ. Thank You.
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org
Matplotlib-users Info Page

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/matplotlib-users/attachments/20180204/2a0be192/attachment.html&gt;

Thanks Benhamin. - I'll certainly look in to that. The installations are all using apt on ubuntu. Using standard repositories apart from the QGIS nightly build. I'm not sure if QGIS uses qhull directly or indirectly - I'll investigate that.

···

________________________________________
From: Benjamin Root [ben.v.root@gmail.com]
Sent: 05 February 2018 11:55
To: Chris Crook
Cc: matplotlib-users at python.org; qgis-developer at lists.osgeo.org
Subject: Re: [Matplotlib-users] tricontour crashing in QGIS3

Looks like a conflict for the qhull library, which matplotlib vendors and builds as a part of its packaging. How did qgis and matplotlib get installed? Perhaps they were built with conflicting flags, perhaps? Just a few ideas off of the top of my head.

Ben Root

On Sun, Feb 4, 2018 at 3:55 PM, Chris Crook <ccrook at linz.govt.nz<mailto:ccrook at linz.govt.nz>> wrote:
I'm looking for help debugging or fixing a problem in matplotlib tricontour. I am using this in a QGIS plugin (www.qgis.org<http://www.qgis.org>). The call to tricontour causes QGIS to crash. Running python3 on ubuntu 16.04 (matplotlib 1.5.1) and 17.10 (matplotlib 2.0.0).

Running in the debugger gives the following result

Thread 1 "qgis.bin" received signal SIGSEGV, Segmentation fault.
0x00007fff4f7ca098 in qh_initstatistics ()
   from /usr/lib/python3/dist-packages/matplotlib/_qhull.cpython-35m-x86_64-linux-gnu.so<http://qhull.cpython-35m-x86_64-linux-gnu.so>
#0 0x00007fff4f7ca098 in qh_initstatistics ()
   from /usr/lib/python3/dist-packages/matplotlib/_qhull.cpython-35m-x86_64-linux-gnu.so<http://qhull.cpython-35m-x86_64-linux-gnu.so>
#1 0x00007fff4f7c6f82 in qh_initqhull_start ()
   from /usr/lib/python3/dist-packages/matplotlib/_qhull.cpython-35m-x86_64-linux-gnu.so<http://qhull.cpython-35m-x86_64-linux-gnu.so>
#2 0x00007fff4f7d12bc in qh_new_qhull ()
   from /usr/lib/python3/dist-packages/matplotlib/_qhull.cpython-35m-x86_64-linux-gnu.so<http://qhull.cpython-35m-x86_64-linux-gnu.so>
#3 0x00007fff4f7a3821 in ?? ()
   from /usr/lib/python3/dist-packages/matplotlib/_qhull.cpython-35m-x86_64-linux-gnu.so<http://qhull.cpython-35m-x86_64-linux-gnu.so>
#4 0x00007fff5d977039 in PyCFunction_Call ()
   from /usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0
#5 0x00007fff5da831b5 in PyEval_EvalFrameEx ()
   from /usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0
#6 0x00007fff5db13cac in ?? ()
   from /usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0
#7 0x00007fff5db13d83 in PyEval_EvalCodeEx ()
   from /usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0
#8 0x00007fff5d99bad8 in ?? ()
   from /usr/lib/x86_64-linux-gnu/libpython3.5m.so.1.0
....

The python code is

                np.save('/home/chris/temp/data.x',x)
                np.save('/home/chris/temp/data.y',y)
                np.save('/home/chris/temp/data.z',z)
                np.save('/home/chris/temp/data.l',levels)
                print("Extend",repr(extend))
                cs = plt.tricontour(x, y, z, levels, extend=extend)

I've called matplotlib from a simple python script using the saved data (np.save) in a simply python script and it runs without problem, so the problem appears to arise running within the QGIS3 python environment.

Can you suggest any reason why it might be different running from within QGIS and how I can work around/fix this!

Thanks
Chris Crook

________________________________

This message contains information, which may be in confidence and may be subject to legal privilege. If you are not the intended recipient, you must not peruse, use, disseminate, distribute or copy this message. If you have received this message in error, please notify us immediately (Phone 0800 665 463 or info at linz.govt.nz<mailto:info at linz.govt.nz>) and destroy the original message. LINZ accepts no responsibility for changes to this email, or for any attachments, after its transmission from LINZ. Thank You.
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users at python.org<mailto:Matplotlib-users at python.org>
https://mail.python.org/mailman/listinfo/matplotlib-users