strange (to me) segfault problem

This is the 4th time I've tried to send to this list...  The
mail server seems to be dumping my posts to the list from my normal
e-mail address (code pizzashack org).  Anyone know why this might
be?  Anyway...

I've finally decided to get my feet wet with GTK programming, but I'm
immediately running into trouble.  You'll recognize the attached
program as being basically the same program as the base.c program from
the tutorial, with an important difference: it calls a function I
wrote which opens a pipe and forks a child to read information from

The problem is that, no matter where I put the call to this function,
the next call to a gtk_* function results in a segfault in malloc().
FWIW, I did try to change all the data structures to glib
replacements, and changed calls from malloc to g_malloc, etc.,
thinking all the while that this shouldn't make a difference.  I was
right; it didn't.  Even with those changes, the resulting program
segfaults.  Here is a backtrace of the program compiled as it is
attached to this message:

  Program received signal SIGSEGV, Segmentation fault.
  0x42074675 in _int_malloc () from /lib/tls/
  (gdb) bt
  #0  0x42074675 in _int_malloc () from /lib/tls/
  #1  0x4207378d in malloc () from /lib/tls/
  #2  0x401bfc78 in g_malloc () from /usr/lib/
  #3  0x401c01f9 in g_mem_chunk_alloc () from /usr/lib/
  #4  0x40189836 in gdk_event_put () from /usr/lib/
#5 0x4018ac52 in gdk_wm_protocols_filter () from /usr/lib/ #6 0x4018aeb4 in gdk_wm_protocols_filter () from /usr/lib/
  #7  0x401be9ae in g_get_current_time () from /usr/lib/
  #8  0x401bee89 in g_get_current_time () from /usr/lib/
  #9  0x401bf124 in g_main_run () from /usr/lib/
  #10 0x400c927f in gtk_main () from /usr/lib/
  #11 0x08048c92 in main (argc=1, argv=0xbffff574) at main.c:17
  #12 0x42015704 in __libc_start_main () from /lib/tls/

The behavior gets stranger, too...  I had originally included some
functions to create other widgets.  If I called get_keys() after those
functions, it returned upon an error reading from the pipe.

Can anyone explain what's going on?

Please DON'T mail me privately...  private replies to this e-mail
address get filtered into my spam folder.  Mail from the list gets
filtered appropriately, so I'll see list replies.  :)

Oh, I should also mention that I'm developing on Red Hat 9, compiling
against gtk 1.2.10 (RH's gtk+-1.2.10-25 package), and I'll be happy to
provide any other information people will think is relevant.


MSN 8 with e-mail virus protection service: 2 months FREE*

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]