Huge thanks to our Platinum Members Endace and LiveAction,
and our Silver Member Veeam, for supporting the Wireshark Foundation and project.

Wireshark-dev: Re: [Wireshark-dev] Unable to run wireshark, tshark or dumpcap from the build di

From: Jeff Morriss <jeff.morriss.ws@xxxxxxxxx>
Date: Mon, 04 Oct 2010 16:42:38 -0400
Christopher Maynard wrote:
Jaap Keuter <jaap.keuter@...> writes:

From the top of my head there's an environment variable which can be set on
running glib based apps that cause
these apps to stop when they hit these. Running in a debugger allows you to to
backtrace to the source.
Thanks Jaap.  From http://library.gnome.org/devel/glib/2.12/glib-running.html, I
found that if I set G_DEBUG=fatal_criticals that tshark will abort at the first
occurrence.

With that set, I ran tshark in gdb and got the backtrace, which follows.  I've
been trying to figure out what's going wrong, stepping through the code in gdb,
but haven't been able to draw any conclusions yet.

(gdb) bt
#0  0x0000003e13430015 in raise () from /lib64/libc.so.6
#1  0x0000003e13431980 in abort () from /lib64/libc.so.6
#2  0x0000003e19435050 in g_logv () from /lib64/libglib-2.0.so.0
#3  0x0000003e194350d3 in g_log () from /lib64/libglib-2.0.so.0
#4  0x0000003e1944704b in g_string_insert_c () from /lib64/libglib-2.0.so.0
#5  0x00002aaaabc5780a in dfilter_macro_apply (text=<value optimized out>,
    depth=0, error=0x632d00) at /usr/include/glib-2.0/glib/gstring.h:131

Looks like your glib is attempting to inline g_string_append_c() (this is from a RH5 system):

    120 #ifdef G_CAN_INLINE
    121 static inline GString*
    122 g_string_append_c_inline (GString *gstring,
    123                           gchar    c)
    124 {
    125   if (gstring->len + 1 < gstring->allocated_len)
    126     {
    127       gstring->str[gstring->len++] = c;
    128       gstring->str[gstring->len] = 0;
    129     }
    130   else
    131     g_string_insert_c (gstring, -1, c);  <<<< here
    132   return gstring;
    133 }
    134 #define g_string_append_c(gstr,c)       g_string_append_c_inline (gstr, c)
    135 #endif /* G_CAN_INLINE */

But then when it gets into g_string_insert_c() it doesn't think that -1 is actually a -1 (this code is from 2.12.latest via the git web interface):

GString*
g_string_insert_c (GString *string,
		   gssize   pos,
		   gchar    c)
{
  g_return_val_if_fail (string != NULL, NULL);

  g_string_maybe_expand (string, 1);

  if (pos < 0)
    pos = string->len;             <<<< should have gone down this path
  else
    g_return_val_if_fail (pos <= string->len, string); <<< but your error indicates it came here

Not sure what's going on there. Reinstall glib2? Forcibly undef G_CAN_INLINE (as an experiment at least)?