[Mono-dev] SIGSEGV in Cairo.CairoAPI:cairo_get/set_matrix()
Idan Gazit
idan at fastmail.fm
Sun Oct 30 18:39:22 EST 2005
OK, So this email touches on Mono.Cairo in 3 parts:
1. SIGSEGV
==========
OK, I got some help from Michael Dominic, who pointed out that
cairo_get_matrix (IntPtr cr, Matrix_T matrix);
should really be:
cairo_get_matrix (IntPtr cr, ref Matrix_T matrix);
It seems that any CairoAPI function which takes a matrix should pass a
ref Matrix_T and not a Matrix_T. This seems to include the following:
cairo_transform
cairo_get/set_matrix
cairo_set_font_matrix
cairo_pattern_get/set_matrix
I'm preparing a patch to this effect.
2. Class Or Struct?
===================
About this time, lewing (in #mono) suggested that there's no point for
Matrix to be a class hiding a Matrix_T struct, rather make Matrix a
struct. So I went ahead and did this, and I'm testing it now (looks OK).
I don't know the reasons behind wrapping Matrix_T in a class, so can
somebody tell me (not sarcastic) why? If there are advantages to having
Matrix be a struct and doing away with Matrix_T then I have the patch
ready to go.
3. Miscellaneous Design Improvements(?)
=======================================
Either way to go (struct or class), I saw a few places where changes
seemed logical to me:
- "Identify" should be "Identity"
- Have Translate/Rotate/Scale et al return (this); so as to enable
things like myMatrix.Translate().Rotate().Scale().
- public static Matrix Identity property as an easy way of getting at
the identity matrix.
- No need for Pointer nor Raw properties in Matrix (they're not used
elsewhere...)?
- override Matrix.ToString () to produce something useful for debugging.
At any rate, all of these together constitutes a patch to Cairo.cs,
Graphics.cs, Matrix.cs, and Pattern.cs. I can make patches for each of
the three individually, or whatever.
Please let me know how to proceed, I'd be very happy to put in my first
patch for mono. :)
-Idan
Idan Gazit wrote:
> Hey,
>
> So I manage to segfault when playing with the Graphics.Matrix property.
> Basically anything that would result in a call to cairo_get_matrix or
> cairo_set_matrix segfaults.
>
> The stacktrace for this segfault when doing get is below, but triggering
> it is pretty easy:
>
> // set up graphics here, then
> System.Console.WriteLine(g.Matrix.ToString());
>
> the same for set:
>
> Cairo.Matrix transformMatrix = new Cairo.Matrix ();
> transformMatrix.CreateIdentify ();
> // set up graphics here, then
> g.Matrix = transformMatrix;
>
>
> Should I be talking to the cairo devs aobut this, instead?
>
> -Idan
>
> =================================================================
> Got a SIGSEGV while executing native code. This usually indicates
> a fatal error in the mono runtime or one of the native libraries
> used by your application.
> =================================================================
>
> Stacktrace:
>
>
> Native stacktrace:
>
> in <0x4> (wrapper managed-to-native) Cairo.CairoAPI:cairo_get_matrix
> (intptr,Cairo.Matrix_T)
> in <0xffffffa1> (wrapper managed-to-native)
> Cairo.CairoAPI:cairo_get_matrix (intptr,Cairo.Matrix_T)
> in <0x49> Cairo.Graphics:get_Matrix ()
> in [0xc1] Meshwork.NetworkMap.ZoomableCairoArea:OnExposeEvent
> (Gdk.EventExpose)
> in [0x14] Gtk.Widget:exposeevent_cb (intptr,intptr)
> in <0x49cce3> (wrapper native-to-managed) Gtk.Widget:exposeevent_cb
> (intptr,intptr)
> in <0x4> (wrapper managed-to-native) Gtk.Application:gtk_main ()
> in <0xffffffe7> (wrapper managed-to-native) Gtk.Application:gtk_main ()
> in [0x0] Gtk.Application:Run ()
> in [0xb] MainClass:Main (string[])
> in <0x50bbe2f9> (wrapper runtime-invoke)
> System.Object:runtime_invoke_void_string[] (object,intptr,intptr,intptr)
> mono(mono_handle_native_sigsegv+0x73) [0x813d883]
> mono [0x81108db]
> [0xffffe440]
> /usr/lib/libcairo.so.2(cairo_get_matrix+0x1b) [0xb69343fb]
> [0xb67d4064]
> [0xb67d3fc2]
> [0xb67d0145]
> [0xb67cf725]
> [0xb67cf37e]
> /usr/lib/libgtk-x11-2.0.so.0(_gtk_marshal_BOOLEAN__BOXED+0x58)
> [0xb6c6c02c]
> /usr/lib/libgobject-2.0.so.0(g_closure_invoke+0x11e) [0xb697b3a8]
> /usr/lib/libgobject-2.0.so.0 [0xb6989c9f]
> /usr/lib/libgobject-2.0.so.0(g_signal_emit_valist+0x41e) [0xb698aec3]
> /usr/lib/libgobject-2.0.so.0(g_signal_emit+0x29) [0xb698b4c3]
> /usr/lib/libgtk-x11-2.0.so.0 [0xb6d4e16f]
> /usr/lib/libgtk-x11-2.0.so.0(gtk_main_do_event+0x4f7) [0xb6c6ad72]
> /usr/lib/libgdk-x11-2.0.so.0 [0xb6ae6bfa]
> /usr/lib/libgdk-x11-2.0.so.0(gdk_window_process_all_updates+0x95)
> [0xb6ae6ccd]
> /usr/lib/libgdk-x11-2.0.so.0 [0xb6ae6d4e]
> /usr/lib/libglib-2.0.so.0 [0xb7f0d750]
> /usr/lib/libglib-2.0.so.0(g_main_context_dispatch+0x1dc) [0xb7f0b4ee]
> /usr/lib/libglib-2.0.so.0 [0xb7f0e4f6]
> /usr/lib/libglib-2.0.so.0(g_main_loop_run+0x1a1) [0xb7f0e7e3]
> /usr/lib/libgtk-x11-2.0.so.0(gtk_main+0xb4) [0xb6c69e65]
> [0xb67cf6a1]
> [0xb67cf660]
> [0xb74d2f12]
> [0xb74d2813]
> mono(mono_runtime_exec_main+0x52) [0x8090ae2]
> mono(mono_runtime_run_main+0x12f) [0x80934ef]
> mono(mono_main+0xeff) [0x805d26f]
> /lib/tls/i686/cmov/libc.so.6(__libc_start_main+0xd2) [0xb7d7bea2]
> mono [0x805be11]
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
More information about the Mono-devel-list
mailing list