Segfault on exit




Hello,
        I am kind of new to this gtk stuff, so please bear with me...

I am working with a fairly large program that uses a considerable number
of threads. The programmer previously in control of the code wrote a
little gtk thread that graphically displayed the state of the program.
That was off in its own thread, and it worked fine.

I decided that I needed to have a dialog box on start up that allowed me
to set a number of parameters without re-compiling. So, I wrote a little
bit of gtk code to provide this. The basic flow is now:

1) init some data structures
2) call gtk_init
3) build window
4) call gtk_main()
5) wait for gtk_main() to return (from Run or Cancel being clicked)
6) start spawning threads (including gtk thread which is optional)
7) end by calling exit(0); from one of the threads


Now, this does work. Sometimes. I am running simulations, and if I
increase the number of things I'm simulating (and thus the number of
data structures and threads), when I do the run, I get a Segfault. It core
dumps right on the exit() call which makes it hard to tell what exactly is
going on. However, the stack trace I get from gdb is:

#0  0xef046694 in t_splay () from /usr/lib/libc.so.1
#1  0xef046504 in t_delete () from /usr/lib/libc.so.1
#2  0xef0461d8 in realfree () from /usr/lib/libc.so.1
#3  0xef046944 in _free_unlocked () from /usr/lib/libc.so.1
#4  0xef046894 in free () from /usr/lib/libc.so.1
#5  0xef129ac4 in _XFreeDisplayStructure () from
/usr/openwin/lib/libX11.so.4
#6  0xef122b50 in XCloseDisplay () from /usr/openwin/lib/libX11.so.4
#7  0xef61f450 in gdk_exit_func () from /usr/local/lib/libgdk-1.2.so.0
#8  0xef018da8 in _exithandle () from /usr/lib/libc.so.1
#9  0xef0882e4 in exit () from /usr/lib/libc.so.1   

So, it looks like there is something from gtk that isn't being cleaned up,
but I can't tell what it is, or how to fix it. I've tried many different
variations. If I take out all gtk calls, it works fine. If I just leave
the gtk_init() in and no other gtk calls, it works fine. If I put the
status thread in, it works fine. But the second I add the dialog window
in, it fails (but only for a run of sufficent size). The dialog box only
consists of like ten spinners. If anyone has any idea what I am doing
wrong, I would really appreciate it.

-Christopher





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