clist mystery



Hello, 

I've got a piece of code which runs fine on my linux box but dumps core 
reliably on my sparcstation. The sparc has gtk+ 1.2.6 and the linux box has 
1.2.8 Here is the code:

void load_script_list(gpointer clist1)
{
    extern script_text *active_script_data;    

    gchar *list_data[1][2];    
    gint  script_running;
    gint  x;
    gchar *script_date;

    script_running = get_status_script_page();

    if ( script_running )
    {
         script_date = g_malloc(256);
         sprintf(script_date, "%s/%s/%s", active_script_data->month,          
   
active_script_data->date, active_script_data->year);
    }
    else
    {
         script_date = g_malloc(256);
         strcpy(script_date, "none");
    }

    list_data[0][1] = g_malloc( (strlen(script_date) + 1) );
    list_data[0][0] = g_malloc( (strlen("Date ") + 1) );
    strcpy(list_data[0][0], "Date ");
    strcpy(list_data[0][1], script_date);
    
    gtk_clist_append( (GtkCList *)clist1, list_data[0]);

<snip>
}

Here is the core dump:

#0  0xeecb2988 in strlen () from /usr/lib/libc.so.1
#1  0xef1218bc in g_strdup (str=0x5 <Address 0x5 out of bounds>) at 
gstrfuncs.c:56
#2  0xef352d50 in set_cell_contents (clist=0xdb3c8, clist_row=0xdb9e0, 
column=2, type=GTK_CELL_TEXT, text=0x5 <Address 0x5 out of bounds>,
    spacing=0 '\000', pixmap=0x0, mask=0x0) at gtkclist.c:2469
#3  0xef3537fc in real_insert_row (clist=0xdb3c8, row=0, text=0xefffe5d0) at 
gtkclist.c:2640
#4  0xef353358 in gtk_clist_append (clist=0xdb3c8, text=0xefffe5d0) at 
gtkclist.c:2578
#5  0x58de4 in load_script_list (clist1=0xdb3c8) at script_page.c:997
#6  0x5a7b8 in reload_previous_script (w=0xdb680, user_data=0xda2b0) at 
script_page_callbacks.c:419 
<snip>

The clist loads up fine the first time the function is called, but when I 
want to change the data in the list I clear it then call the function again 
and it dies on the gtk_clist_append() call. As you can see it thinks that the 
pointer to the text for column 2 is out of bounds????? I even tried it with 
static text and I get the same thing every time.... as i said it works fine 
under the Linux box. It seems so simple I must be overlooking something. Is 
this a problem with 1.2.6? Do i need to update to 1.2.8? The clist example 
that comes with the source for 1.2.6 works fine on the sparc and it's 
actually doing the exact same thing I'm trying to do, load a list, clear the
list and reload it.

I'm stumped.

Mike




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