After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 73559 - g_signal_newv can cause crash on Solaris
g_signal_newv can cause crash on Solaris
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gobject
1.3.x
Other Solaris
: Normal minor
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2002-03-05 16:26 UTC by Laszlo (Laca) Peter
Modified: 2011-02-18 15:48 UTC
See Also:
GNOME target: ---
GNOME version: 2.0



Description Laszlo (Laca) Peter 2002-03-05 16:26:08 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.)
Comment 1 Owen Taylor 2002-03-05 16:55:19 UTC
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.)
Comment 2 Laszlo (Laca) Peter 2002-03-05 18:13:25 UTC
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.
Comment 3 Owen Taylor 2002-03-25 22:33:10 UTC
(I consider this minor because the crash only occurs on invalid
input to g_signal_newv())
Comment 4 Owen Taylor 2002-05-20 20:05:03 UTC
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.