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

Bus error in contour on OSX in master #4222

Closed
efiring opened this issue Mar 15, 2015 · 6 comments
Closed

Bus error in contour on OSX in master #4222

efiring opened this issue Mar 15, 2015 · 6 comments
Assignees
Labels
OS: Apple Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Milestone

Comments

@efiring
Copy link
Member

efiring commented Mar 15, 2015

The test of the new contour code is causing a Bus error: 10 for me on OSX 10.9.5, with both python 2.7.9 and 3.4.3 installed via homebrew. Here is the code as a standalone script sufficient to trigger the error:

import numpy as np
import matplotlib.pyplot as plt

def test_corner_mask():
    n = 60
    mask_level = 0.95
    noise_amp = 1.0
    np.random.seed([1])
    x, y = np.meshgrid(np.linspace(0, 2.0, n), np.linspace(0, 2.0, n))
    z = np.cos(7*x)*np.sin(8*y) + noise_amp*np.random.rand(n, n)
    mask = np.where(np.random.rand(n, n) >= mask_level, True, False)
    z = np.ma.array(z, mask=mask)

    for corner_mask in [False]: #[False, True]:
        fig = plt.figure()
        plt.contourf(z, corner_mask=corner_mask)

test_corner_mask()
@efiring efiring added OS: Apple Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. labels Mar 15, 2015
@tacaswell tacaswell added this to the next point release milestone Mar 15, 2015
@tacaswell
Copy link
Member

I can't reproduce this on the linux, which backend are you using?

@jenshnielsen
Copy link
Member

I can reproduce in on OSX I spent some time today trying to figure out why with no luck. As far as I can see it only happens when the array is masked and with the new c++ contour code. I think that I have narrowed it down to the PyArg_ParseTuple call:

PyArg_ParseTuple(args, "O&O&O&O&il",
                          &x.converter_contiguous, &x,
                          &y.converter_contiguous, &y,
                          &z.converter_contiguous, &z,
                          &mask.converter_contiguous, &mask,
                          &corner_mask,
                          &chunk_size))

In PyQuadContourGenerator_init (_contour_wrapper.cpp) I am guessing that this may relate to
mask being a Boolean array.

I got the following not very helpfull backtrace:

0x0000000103b9fee0 in numpy::array_view<bool const, 2>::~array_view() ()
   from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.dev1-py2.7-macosx-10.10-x86_64.egg/matplotlib/_contour.so
(gdb) bt
#0  0x0000000103b9fee0 in numpy::array_view<bool const, 2>::~array_view() ()
   from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.dev1-py2.7-macosx-10.10-x86_64.egg/matplotlib/_contour.so
#1  0x0000000103b9fe95 in numpy::array_view<bool const, 2>::~array_view() ()
   from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.dev1-py2.7-macosx-10.10-x86_64.egg/matplotlib/_contour.so
#2  0x0000000103b9fbd5 in PyQuadContourGenerator_init(PyQuadContourGenerator*, _object*, _object*) ()
   from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/matplotlib-1.5.dev1-py2.7-macosx-10.10-x86_64.egg/matplotlib/_contour.so
#3  0x0000000100051b5b in type_call () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#4  0x000000010000f0ea in PyObject_Call () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#5  0x000000010008bbd2 in PyEval_EvalFrameEx () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#6  0x0000000100088d7a in PyEval_EvalCodeEx () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#7  0x000000010002d1ae in function_call () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#8  0x000000010000f0ea in PyObject_Call () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#9  0x000000010008b97b in PyEval_EvalFrameEx () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#10 0x0000000100088d7a in PyEval_EvalCodeEx () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#11 0x000000010002d1ae in function_call () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#12 0x000000010000f0ea in PyObject_Call () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#13 0x0000000100019ed7 in instancemethod_call () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#14 0x000000010000f0ea in PyObject_Call () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#15 0x000000010008b97b in PyEval_EvalFrameEx () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#16 0x0000000100088d7a in PyEval_EvalCodeEx () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#17 0x000000010002d1ae in function_call () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#18 0x000000010000f0ea in PyObject_Call () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#19 0x0000000100019ed7 in instancemethod_call () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#20 0x000000010000f0ea in PyObject_Call () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#21 0x0000000100056254 in slot_tp_init () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#22 0x0000000100051b5b in type_call () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#23 0x000000010000f0ea in PyObject_Call () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#24 0x000000010008b97b in PyEval_EvalFrameEx () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#25 0x0000000100088d7a in PyEval_EvalCodeEx () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#26 0x000000010002d1ae in function_call () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#27 0x000000010000f0ea in PyObject_Call () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#28 0x000000010008b97b in PyEval_EvalFrameEx () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#29 0x0000000100088d7a in PyEval_EvalCodeEx () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#30 0x000000010008f59d in fast_function () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#31 0x000000010008c400 in PyEval_EvalFrameEx () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#32 0x0000000100088d7a in PyEval_EvalCodeEx () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#33 0x00000001000887f3 in PyEval_EvalCode () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#34 0x00000001000a88a2 in run_mod () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#35 0x00000001000a8945 in PyRun_FileExFlags () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#36 0x00000001000a84e2 in PyRun_SimpleFileExFlags () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#37 0x00000001000b9c5b in Py_Main () from /usr/local/Cellar/python/2.7.9/Frameworks/Python.framework/Versions/2.7/Python
#38 0x00007fff92a475c9 in start () from /usr/lib/system/libdyld.dylib
#39 0x0000000000000000 in ?? ()

@jenshnielsen
Copy link
Member

I don't think this relates to the backend. It happens to me too when building the docs with the bare Agg backend (How I originally noticed it while trying to fix the Sphinx issues)

Based on the above traceback I did some experiments. Removing the Py_XDECREF(m_arr) call from the destructor of array_view (~array_view) does seem to resolve it. While this is naturally not a solution it does seem to prevent the Bus error. I guess that either the mask array is destroyed to early.

@jenshnielsen
Copy link
Member

I think I see the problem and have a fix in #4223 that seems to resolve the problem for me locally. @efiring can you test if that resolves the problem for you?

@WeatherGod
Copy link
Member

If it is the XDECREF call I am thinking of, @mdboom changed it to that
recently to get llvm warnings to go away.

On Sun, Mar 15, 2015 at 6:30 PM, Jens Hedegaard Nielsen <
notifications@github.com> wrote:

I think I see the problem and have a fix in #4223
#4223 that seems to
resolve the problem for me locally. @efiring https://github.com/efiring
can you test if that resolves the problem for you?


Reply to this email directly or view it on GitHub
#4222 (comment)
.

@jenshnielsen
Copy link
Member

Fixed by #4229

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
OS: Apple Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants