artemp/tickets2issues — Issue #277: Bus Error during Image render at cairo extract_surface()
Author: artemp
Created: 2011-10-11 15:07:43+00:00
State: closed
Labels: Cairo_Renderer

I'm running python 26, boost 1_37 (from source), and mac 10.5.6 with mapnik r821

I'm not surprised something is wrong because I've still got a cairo install around (that mapnik is linking too) that is built against python 25 installed via macports.

I get a bus error with this code:
{{{
#!python
Python 2.6 (trunk:66714:66715M, Oct 1 2008, 18:36:04)
[GCC 4.0.1 (Apple Computer, Inc. build 5370)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from mapnik import Map, Image, render
>>> m= Map(256,256)
>>> im = Image(m.width,m.height)
>>> render(m,im)
Bus error
}}}

The 'Python Problem Report' that Apple's leopard generates after a python crash seems to point to a cairo function:

{{{
#!sh
Process: Python [138]
Path: /Library/Frameworks/Python.framework/Versions/2.6/Resources/Python.app/Contents/MacOS/Python
Identifier: Python
Version: ??? (???)
Code Type: X86 (Native)
Parent Process: bash [127]

Date/Time: 2009-01-24 22:27:10.473 -0800
OS Version: Mac OS X 10.5.6 (9G55)
Report Version: 6

Exception Type: EXC_BAD_ACCESS (SIGBUS)
Exception Codes: KERN_PROTECTION_FAILURE at 0x000000000000004c
Crashed Thread: 0

Thread 0 Crashed:
0 _mapnik.so	0x00cc989e extract_surface(_object*) + 30
1 ...python-xgcc40-mt-1_37.dylib	0x00974bec boost::python::converter::get_lvalue_from_python(_object*, boost::python::converter::registration const&) + 76 (from_python.cpp:131)
2 _mapnik.so	0x00c72ca9 boost::python::objects::caller_py_function_impl > >::operator()(_object*, _object*) + 121
3 ...python-xgcc40-mt-1_37.dylib	0x0097e8c4 boost::python::objects::function::call(_object*, _object*) const + 468 (function.cpp:234)
4 ...python-xgcc40-mt-1_37.dylib	0x00980025 boost::detail::function::void_function_ref_invoker0::invoke(boost::detail::function::function_buffer&) + 37 (function.cpp:581)
5 ...python-xgcc40-mt-1_37.dylib	0x00986f79 boost::function0::operator()() const + 41 (function_template.hpp:989)
6 ...python-xgcc40-mt-1_37.dylib	0x0098636c boost::python::detail::exception_handler::operator()(boost::function0 const&) const + 204 (errors.cpp:74)
7 _mapnik.so	0x00c6fce4 boost::detail::function::function_obj_invoker2, boost::_bi::list3 (*)(), boost::arg<2> (*)(), boost::_bi::value > >, bool, boost::python::detail::exception_handler const&, boost::function0 const&>::invoke(boost::detail::function::function_buffer&, boost::python::detail::exception_handler const&, boost::function0 const&) + 36
8 ...python-xgcc40-mt-1_37.dylib	0x0098643f boost::python::handle_exception_impl(boost::function0) + 63 (errors.cpp:24)
9 ...python-xgcc40-mt-1_37.dylib	0x0097c472 function_call + 98 (function_template.hpp:849)
10 org.python.python	0x00497716 PyObject_Call + 77 (abstract.c:2487)
11 org.python.python	0x0053afd6 PyEval_EvalFrameEx + 10227 (ceval.c:3890)
12 org.python.python	0x0053f08f PyEval_EvalCodeEx + 1967 (ceval.c:2942)
13 org.python.python	0x0053f246 PyEval_EvalCode + 87 (ceval.c:521)
14 org.python.python	0x005636eb PyRun_InteractiveOneFlags + 501 (pythonrun.c:1330)
15 org.python.python	0x005638de PyRun_InteractiveLoopFlags + 85 (pythonrun.c:758)
16 org.python.python	0x0056413d PyRun_AnyFileExFlags + 155 (pythonrun.c:725)
17 org.python.python	0x00573f0c Py_Main + 3481 (main.c:597)
18 Python	0x00001f8e 0x1000 + 3982
19 Python	0x00001eb5 0x1000 + 3765
}}}

But, this error seems odd because I can trigger it without using a cairo surface. I wonder if there should be some error checking in the cairo code that should be added such that mapnik will throw an exception (since my python versions used to build mapnik and boost differ from pycairo) before a BUS ERROR occurs?