Segmentation fault in malloc() called from gdk



Hello.

I'm writing a GTK+ application on FreeBSD(intel) and Solaris2(sparc),
but only the Solaris version sometimes dumps core.

The program calls gdk_gc_new() like this:

| extern GtkWidget *toplevel;
  :
| int thum(char *thm)
| {
|     GdkGC *gc;
  :
|     gc = gdk_gc_new(toplevel->window);
  :
  :

When I got SEGV, gdb shows the following stack trace.

| Program received signal SIGSEGV, Segmentation fault.
| 0x6fa4b94c in _malloc_unlocked ()
| (gdb) where
| #0  0x6fa4b94c in _malloc_unlocked ()
| #1  0x6fa4b710 in malloc ()
| #2  0x6fc20a8c in XCreateGC ()
| #3  0x6fdce3e8 in gdk_gc_new_with_values (window=0x47fe8, values=0x0, 
|     values_mask=0) at gdkgc.c:261
| #4  0x6fdcdfd8 in gdk_gc_new (window=0x47fe8) at gdkgc.c:36
| #5  0x14f40 in thum (
|     thm=0x7bd50 '\001' <repeats 18 times>, "\017\017\r", '\001' <repeats 41
| times>, "\003\017", '\001' <repeats 99 times>) at gthum.c:59
  :
  :

I use some malloc()/calloc() calls in my application,
but don't use any free()s (to make the problem clear).
Does anyone know why SEGV occurs in an X11 function ?
or any ideas about how to check my code ?

I use GCC 2.95, X11R6.4(fix03), glib-1.2.8, gtk+-1.2.8(--enable-xim=no)
on Solaris 2.5.1(sparc).

On another FreeBSD host (FreeBSD 4.1R, XFree86 4.0.1, GCC 2.95,
and glib/gtk+-1.28), the same program (compiled from the same sources)
runs fine.

Thanks.

---
Junji SAKAI




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