GNOME Bugzilla – Bug 110078
Compositing pixbufs causes segfault
Last modified: 2010-07-10 04:08:37 UTC
In my program I create pixbufs to be shown by composing it from several smaller pixbufs. Sometimes the composite command bombs out with segment violation. I'll attach a small test case demonstrating the bug. In it I create two pixbufs, one sized 64x128, the other 64x64. Compositing the small pixbuf on the bottom half of the bigger pixbuf causes segfault.
Created attachment 15501 [details] Example code demonstrating the segfault
Do you know if this works in C? Does composite() allocate new memory or do you need to allocate enough yourself?
I don't know if it works in C or not. I have never coded with plain GTK, only gtkmm. Composite just draws the source image over the target image, which must both be preallocated (as they are in the example). If you try to draw outside the target image, you get a failed assertion. The example does not get this message (so the composition command should be valid), it just crashes.
Created attachment 16619 [details] composite_gtk.c
I have recoded this as C and it still has the same problem - the composite_gtk.c attachment. I don't know whether it's a true bug because I don't know how this is really supposed to work. I'm reassigning this to GTK+ - if you don't get a response then mention this bug on their gtk-list@gnome.org mailing list.
From a quick glance at the C testcase, your destination rectangle (0, 64, 64, 64) is outside of the transformed source image (0, 0, 64, 64). In order to achieve what you want, you'll have to use an offset_y of 64, in order to get the transformed image to (0, 64, 64, 64). We probably should catch this mistake with a g_return_if_fail() and I think there is another gdk-pixbuf bug which already has a patch for that... Please reopen if my analysis is wrong.
Thanks Matthias.