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

Cairo crash on OSX due to floating point/divide by zero when rendering map with labels to PDF/PS #387

Closed
artemp opened this issue Oct 11, 2011 · 7 comments
Milestone

Comments

@artemp
Copy link
Member

artemp commented Oct 11, 2011

NOTE: this is only happening with pycairo compiled using XCode (part of my Mapnik binary/framework installer project).

Also:

  • only on mac osx
  • osx versions I'm running: mapnik trunk, Cairo 1.8.8 and Cairomm 1.8.0 from macports linked statically
  • pycairo 1.8.4 compiled with XCode
  • SVG rendering works, PDF and PS crash but only when rendering a map with labels
  • SVG and labels work fine
  • test case attached

Run:

{{{
python cairo_test.py
}}}

Crash output: http://dpaste.de/gYst/

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[springmeyer] see also #392

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[springmeyer] {{{
Process: Python [10086]
Path: /System/Library/Frameworks/Python.framework/Versions/2.5/Resources/Python.app/Contents/MacOS/Python
Identifier: Python
Version: ??? (???)
Code Type: X86 (Native)
Parent Process: bash [10076]

Interval Since Last Report: 8468 sec
Crashes Since Last Report: 2
Per-App Interval Since Last Report: 0 sec
Per-App Crashes Since Last Report: 1

Date/Time: 2009-07-19 10:48:39.770 -0700
OS Version: Mac OS X 10.5.7 (9J61)
Report Version: 6
Anonymous UUID: 3EE7A00D-B218-4641-83C5-E3AE14622523

Exception Type: EXC_ARITHMETIC (SIGFPE)
Exception Codes: EXC_I386_DIV (divide by zero)
Crashed Thread: 0

Thread 0 Crashed:
0 _cairo.so 0x00578258 _cairo_hash_table_lookup_internal + 40
1 _cairo.so 0x0057843e _cairo_hash_table_resize + 190
2 _cairo.so 0x0057866c _cairo_hash_table_insert + 76
3 _cairo.so 0x00571e9a _cairo_cache_insert + 42
4 _cairo.so 0x0058ae14 _cairo_scaled_glyph_lookup + 580
5 _cairo.so 0x0059bd63 _cairo_sub_font_map_glyph + 131
6 _cairo.so 0x0059c1e9 _cairo_sub_font_create + 233
7 _cairo.so 0x0059c5de _cairo_scaled_font_subsets_map_glyph + 974
8 _cairo.so 0x005a31a8 _cairo_pdf_operators_emit_cluster + 88
9 _cairo.so 0x005a378d _cairo_pdf_operators_show_text_glyphs + 989
10 _cairo.so 0x005bf331 _cairo_pdf_surface_show_text_glyphs + 641
11 _cairo.so 0x00590c3e _cairo_surface_show_text_glyphs + 894
12 _cairo.so 0x0057d7bd _cairo_meta_surface_replay_internal + 2349
13 _cairo.so 0x0057f973 _paint_page + 435
14 _cairo.so 0x0057fc37 _cairo_paginated_surface_show_page + 55
15 com.springmeyer.Mapnik 0x01b7d8bf cairo_surface_show_page + 79
16 com.springmeyer.Mapnik 0x01b63cd8 cairo_gstate_show_page + 24
17 com.springmeyer.Mapnik 0x01b5dadb cairo_show_page + 43
18 com.springmeyer.Mapnik 0x01b50455 Cairo::Context::show_page() + 21
19 mapnik.so 0x0107a051 mapnik::feature_style_processormapnik::cairo_renderer<Cairo::Surface >::apply() + 433 (feature_style_processor.hpp:102)
20 mapnik.so 0x01071372 render4(mapnik::Map const&, PycairoSurface) + 170
21 mapnik.so 0x01073155 object boost::python::detail::invoke<int, void ()(mapnik::Map const&, PycairoSurface), boost::python::arg_from_python<mapnik::Map const&>, boost::python::arg_from_python<PycairoSurface*> >(boost::python::detail::invoke_tag<true, false>, int const&, void (
&)(mapnik::Map const&, PycairoSurface
), boost::python::arg_from_python<mapnik::Map const&>&, boost::python::arg_from_python<PycairoSurface*>&) + 59 (none.hpp:16)
22 _mapnik.so 0x01076564 boost::python::detail::caller_arity<2u>::impl<void ()(mapnik::Map const&, PycairoSurface), boost::python::default_call_policies, boost::mpl::vector3<void, mapnik::Map const&, PycairoSurface*> >::operator()(object, object) + 132 (caller.hpp:223)
23 _mapnik.so 0x010df364 boost::python::objects::function::call(object, object) const + 468
24 _mapnik.so 0x010e0cc5 boost::detail::function::void_function_ref_invoker0<boost::python::objects::(anonymous namespace)::bind_return, void>::invoke(boost::detail::function::function_buffer&) + 37
25 _mapnik.so 0x010e7cf9 boost::function0::operator()() const + 41
26 _mapnik.so 0x010e70ec boost::python::detail::exception_handler::operator()(boost::function0 const&) const + 204
27 mapnik.so 0x01071f43 boost::python::detail::translate_exception<mapnik::config_error, void (*)(mapnik::config_error const&)>::operator()(boost::python::detail::exception_handler const&, boost::function0 const&, void ()(mapnik::config_error const&)) const + 25 (translate_exception.hpp:46)
28 _mapnik.so 0x01071fa6 bool boost::_bi::list3boost::arg<1, boost::arg<2>, boost::bi::value<void ()(mapnik::config_error const&)> >::operator()<bool, boost::python::detail::translate_exception<mapnik::config_error, void ()(mapnik::config_error const&)>, boost::_bi::list2<boost::python::detail::exception_handler const&, boost::function0 const&> >(boost::_bi::type, boost::python::detail::translate_exception<mapnik::config_error, void ()(mapnik::config_error const&)>&, boost::_bi::list2<boost::python::detail::exception_handler const&, boost::function0 const&>&, long) + 42
29 _mapnik.so 0x01071fe3 bool boost::_bi::bind_t<bool, boost::python::detail::translate_exception<mapnik::config_error, void ()(mapnik::config_error const&)>, boost::_bi::list3boost::arg<1, boost::arg<2>, boost::_bi::value<void ()(mapnik::config_error const&)> > >::operator()<boost::python::detail::exception_handler, boost::function0 >(boost::python::detail::exception_handler const&, boost::function0 const&) + 55
30 _mapnik.so 0x01072007 boost::detail::function::function_obj_invoker2<boost::_bi::bind_t<bool, boost::python::detail::translate_exception<mapnik::config_error, void ()(mapnik::config_error const&)>, boost::_bi::list3boost::arg<1, boost::arg<2>, boost::_bi::value<void ()(mapnik::config_error const&)> > >, 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&) + 31 (function_template.hpp:131)
31 _mapnik.so 0x010e71bf boost::python::handle_exception_impl(boost::function0) + 63
32 _mapnik.so 0x010dd052 function_call + 98
33 org.python.python 0x00121505 PyObject_Call + 50
34 org.python.python 0x0018f832 PyEval_EvalFrameEx + 17904
35 org.python.python 0x00191173 PyEval_EvalCodeEx + 1638
36 org.python.python 0x00191260 PyEval_EvalCode + 87
37 org.python.python 0x001a883c PyErr_Display + 1896
38 org.python.python 0x001a8e66 PyRun_FileExFlags + 135
39 org.python.python 0x001aa7d2 PyRun_SimpleFileExFlags + 421
40 org.python.python 0x001b5a57 Py_Main + 3095
41 org.python.pythonapp 0x00001fca 0x1000 + 4042

}}}

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[springmeyer] Closing as invalid. I'm now pretty convinced that this only occurs when compiling pycairo with XCode (for reasons unknown) on osx, and is not a Mapnik or Cairo issue.

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[artem] I just compiled on 10.6.1 (x86_64) :

{{{
mapnik-trunk
cairo 1.8.8
cairomm-1.8.2
libsigc++-2.2.4
pixman-0.16.2
pycairo-1.8.8
}}}

from source and I'm getting 'Floating point error' . Sorry, re-opening :)

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[springmeyer] ruh roh :)

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[artem] OK, it turned out that _cairo.so was linked to /usr/X11/lib/libcairo.2.dylib and not /usr/local/lib/libcairo.2.dylib. I'm closing this one again. Dane, could you check your setup ?

@artemp
Copy link
Member Author

artemp commented Oct 11, 2011

[springmeyer] Artem, thanks so much for that hint. It has taken me a few days work, but I've now fully rebuilt my XCode/Framework build system to use all shared dylib's for cairo dependencies. After finishing making sure that both the Mapnik C++ lib, the python bindings, and pycairo were linked to dylib's, I still experienced the same exact crashes, but I saw that libsigc++ might be involved (whereas before both it and cairomm where not showing up in the backtrace). These problems still persisted even after playing around with getting the exact same compiler flags to build pycairo as the official makefiles use (which I thought might have been the problem, particularly the '-undefined dynamic' flags that allow runtime search for libs).

But I stuck with compile time linking so I could be sure the libraries that were being used. Still the crashes. Then I removed some temporary directories of staged libraries (in /opt/local) and when doing '>>> import mapnik' I then finally saw dynamic linking errors for libsigc++ and libfreetype. It seems that I was linking to symlinks that did not exist and the python dylib was falling back to find other libraries without error (I thought this would only happen when using '-undefined dynamic'???). So, when removed these duplicate libs in /opt/local I saw that it was looking for 'libsigc-2.0' (not in /opt/local, actually in the right place within the Mapnik Framework) and not finding 'libsigc-2.0.0'. Holy $^%$^. Anyway, after solving those linking problems with 'install_name_tool' I've now finally got 'rundemo.py' working with map labels and PDF,SVG, and PS output. Hurray! Hurray!

Lessons learned:

  • Static linking to static libs makes library problems really difficult to debug (in this case impossible) (but the solution would have been the same)
  • Dylibs are better, but...
  • Gotta make sure you are linking where you think you are, not just by path but down to the library name/symlink, and don't trust the lack of runtime errors
  • Obscure libsigc++ problems seem to be my personal PITA: https://bugs.launchpad.net/ubuntu/+source/cairomm/+bug/452733

@artemp artemp closed this as completed Oct 11, 2011
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant