GNOME Bugzilla – Bug 73559
g_signal_newv can cause crash on Solaris
Last modified: 2011-02-18 15:48:02 UTC
gsignal.c has loads of g_warnings that print the result of g_type_name(). g_type_name() can return NULL, which causes a seg.fault on Solaris when passed to *printf(%s). Some of these are already guarded with an if (!g_type_name(xxx)) {...} but most aren't, also this solution suppresses those warnings. Instead I suggest to use a macro: #define g_type_name_str(x) (g_type_name(x) == NULL ? "(null)" : g_type_name(x)) (The g_warning() in line 1241 actually breaks crashes the gtk-doc scanner in libgnomeui and breaks the build.)
I'd make this a static function not a macro... since this only matters in error cases, better to save code size than try to inline stuff. (For libgnomeui build, the solution is to fix the warning, not make it not warn.)
Any chance to include a convenience function in "a future version of glib" to return "(null)" for NULL strings and the string itself otherwise? This type of bug comes up all the time on Solaris.
(I consider this minor because the crash only occurs on invalid input to g_signal_newv())
Mon May 20 15:57:47 2002 Owen Taylor <otaylor@redhat.com> * gsignal.c: When printing errors, handle NULL returns from g_type_debug(). (#73559, Laszlo Peter) I'm not sure about the "(null)" function ... it seems hard to come up a name that both: - Is short enough to be more convenient than just writing a ? a : "(null) - Is clear enough that it doesn't obscure code more than just writing a ? a : "(null)" If you have ideas in this area, please filie a separate bug.