GNOME Bugzilla – Bug 725198
g-ir-compiler: Caught NULL node, parent=generate_fn
Last modified: 2015-02-07 16:53:11 UTC
Created attachment 270349 [details] .gir file produced by 9d8d159c When building libvips 7.38.5 [1], g-ir-compiler 1.39.90 crashes with the following error: /usr/bin/g-ir-compiler --includedir=. --includedir=. Vips-8.0.gir -o Vips-8.0.typelib Vips-8.0.gir:3374:1: warning: element callback from state 14 is unknown, ignoring Vips-8.0.gir:3381:1: warning: element callback from state 14 is unknown, ignoring ** (g-ir-compiler:20456): ERROR **: Caught NULL node, parent=generate_fn make[3]: *** [Vips-8.0.typelib] Trace/breakpoint trap make[3]: Leaving directory `/builddir/build/BUILD/vips-7.38.1/libvips' 1.39.0 works fine. Bisection blames this commit: commit 9d8d159c28a482de6bdaa06f3805f65d3c55e958 Author: Simon Feltman <sfeltman@src.gnome.org> Date: Wed Dec 25 04:17:50 2013 -0800 scanner: Fix parsing for various typedef struct orderings Add structs parsed from C's "tag namespace" into their own cache for lookup by typdef parsing. This fixes issues where a typedef declared after a struct would not have a correct name. This also cleans up the need for special casing struct tags prefixed with an underscore. https://bugzilla.gnome.org/show_bug.cgi?id=581525 I've attached the .gir files produced by the g-ir-scanner from that commit and from the previous one: $ g-ir-compiler Vips-8.0-good.gir -o Vips-8.0.typelib $ g-ir-compiler Vips-8.0-bad.gir -o Vips-8.0.typelib Vips-8.0-bad.gir:3374:1: warning: element callback from state 14 is unknown, ignoring Vips-8.0-bad.gir:3381:1: warning: element callback from state 14 is unknown, ignoring ** (g-ir-compiler:26047): ERROR **: Caught NULL node, parent=generate_fn Trace/breakpoint trap (core dumped) $ diff -u Vips-8.0-good.gir Vips-8.0-bad.gir | diffstat Vips-8.0-bad.gir | 5026 +++++++++++++++++++++++++++++-------------------------- 1 file changed, 2722 insertions(+), 2304 deletions(-) [1]: http://www.vips.ecs.soton.ac.uk/supported/7.38/vips-7.38.5.tar.gz
Created attachment 270350 [details] .gir file produced by 9d8d159c^
(In reply to comment #0) > /usr/bin/g-ir-compiler --includedir=. --includedir=. Vips-8.0.gir -o > Vips-8.0.typelib > Vips-8.0.gir:3374:1: warning: element callback from state 14 is unknown, > ignoring > Vips-8.0.gir:3381:1: warning: element callback from state 14 is unknown, > ignoring > ** (g-ir-compiler:20456): ERROR **: Caught NULL node, parent=generate_fn It looks like simply having a function pointer field on a GObject causes this crash. The crash seems to have always been around even prior to the given bisected commit. In the case of vips, the bisected commit brings in previously non-introspected stuff, the "generate_fn" function pointer field of "Image" in this case. I'll take a look at the g-ir-compiler code for a fix. Test example which shows crash before the bisected commit: // tests/scanner/regress.h struct _RegressTestObj { GObject parent_instance; ... void (*function_ptr)(); };
Created attachment 270459 [details] [review] g-ir-compiler: Add support for callback fields on GObjects Use ParseState enum instead of a boolean for the ParseContexts embedded_type flag. This allows specific tracking of the embedded type currently being parsed which can now either be STATE_STRUCT_FIELD or STATE_CLASS_FIELD (or allow for future expansion). Add ParseState::STATE_NONE as the default for this field. Fix GObject FieldBlob validation to take into account the sizeof CallbackBlobs (copied from the struct validator). Add static g_object_info_get_field_offset that parallels g_struct_info_get_field_offset which is needed since callback fields may vary in size. Notes: This ended up being much more involved than I expected. A simpler approach would be to just ignore callback fields on GObjects since they apparently are not used in most of the GNOME stack. Ignoring them might also be a safer approach so close to release time.
Review of attachment 270459 [details] [review]: Thanks for this patch, Simon! This looks good to me.
*** Bug 660245 has been marked as a duplicate of this bug. ***
Attachment 270459 [details] pushed as 7027bb2 - g-ir-compiler: Add support for callback fields on GObjects
[Mass-moving gobject-introspection tickets to its own Bugzilla product - see bug 708029. Mass-filter your bugmail for this message: introspection20150207 ]