LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Programming (http://www.linuxquestions.org/questions/programming-9/)
-   -   _int_free() call crashes in gtk/pango lib (segmentation fault), what is the reason (http://www.linuxquestions.org/questions/programming-9/_int_free-call-crashes-in-gtk-pango-lib-segmentation-fault-what-is-the-reason-724395/)

benni1 05-07-2009 09:26 AM

_int_free() call crashes in gtk/pango lib (segmentation fault), what is the reason
 
hi,
i used gdb for my core file with this result (backtrace):


#0 0xb79c38d2 in _int_free () from /lib/tls/libc.so.6
#1 0xb79c40ea in free () from /lib/tls/libc.so.6
#2 0xb7ad2d61 in g_free () from /usr/lib/libglib-2.0.so.0
#3 0xb7bc58a5 in pango_glyph_string_free () from /usr/lib/libpango-1.0.so.0
#4 0xb7bcf2dc in pango_layout_line_index_to_x () from /usr/lib/libpango-1.0.so.0
#5 0xb7ae25af in g_slist_foreach () from /usr/lib/libglib-2.0.so.0
#6 0xb7bd004e in pango_layout_line_unref () from /usr/lib/libpango-1.0.so.0
#7 0xb7bd0153 in pango_layout_iter_free () from /usr/lib/libpango-1.0.so.0
#8 0xb7bd0a7d in pango_layout_set_width () from /usr/lib/libpango-1.0.so.0
#9 0xb7b42351 in g_object_unref () from /usr/lib/libgobject-2.0.so.0
#10 0xb7de44e8 in gtk_label_get () from /usr/lib/libgtk-x11-2.0.so.0
#11 0xb7de6ac9 in gtk_label_set_attributes () from /usr/lib/libgtk-x11-2.0.so.0
#12 0xb7de71f1 in gtk_label_set_markup () from /usr/lib/libgtk-x11-2.0.so.0
#13 0x080529d7 in Init_Text () at gtk_gui.c:1922

#14 0x08054d6c in navigate_menus () at gtk_gui.c:3012
#15 0x08056212 in gui_loop () at gtk_gui.c:3382
#16 0x0804b419 in main (argc=1, argv=0xbfee1f64) at main.c:284

#13 is my last own function call. as this problem only occurs from time to time its very hard for me to find the problem, hope someone can give me a hint. init_text() is called in a loop but as i know shouldn't the problem that i free something twice. maybe it is a bug in the pango lib? here is the function Init_Text():
First the important code where i think is the prob:

Init_Text(){
if...{}
else{
gtk_label_set_markup(GTK_LABEL(Artikel_label[i-
index_artikel]),text[i-index_artikel]);


gtk_label_set_markup(GTK_LABEL(Artikel_label_select_1[i-
index_artikel]),text_undertext[i-
index_artikel]);

gtk_label_set_markup(GTK_LABEL(Artikel_label_select_2[i-
index_artikel]),text_price[i-index_artikel]);


sprintf(text[i-index_artikel]," ");
sprintf(text_undertext[i-index_artikel]," ");
sprintf(text_price[i-index_artikel]," ");

free(text[i-index_artikel]);
free(text_undertext[i-index_artikel]);
free(text_price[i-index_artikel]);
}
seite=(index_artikel/10)+1;
von_seiten=(count_selected/10)+1;
snprintf(label_text,sizeof(label_text),"<span font_desc=\"sans 12\">Seite %d von %d </span>",seite,von_seiten);

gtk_label_set_markup(GTK_LABEL(label_seite), label_text);

gtk_widget_show(label_seite);
}
***
the prob is as it seems to me the set_markup_functions or one of them.
i dont know why because this works out 9 of 10 times.
hope u can help me.
and here is the whole function:
***

void Init_Text()
{
int i=0,seite=1,von_seiten=1;

char bild_file[80];
if(index_artikel>count_selected)index_artikel=0;
for(i=index_artikel;i<index_artikel+10;i++)
{
text[i-index_artikel]=(char*)malloc(350*sizeof(char));
text_undertext[i-index_artikel]=char*)malloc(350*sizeof(char));
text_price[i-index_artikel]=(char*)malloc(350*sizeof(char));
if(i<count_selected)
{
komma_format(SelectedGroup[i].Preis, temp);
text[i-index_artikel]=strcpy(text[i-index_artikel],"<span font_desc=\"sans 12\"><b> " );
text[i-index_artikel]=strcat(text[i-index_artikel], SelectedGroup[i].Name);
text[i-index_artikel]=strcat(text[i-index_artikel], " ");

text[i-index_artikel]=strcat(text[i-index_artikel],"</b></span>");
text_price[i-index_artikel]=strcpy(text_price[i-index_artikel],"<span font_desc=\"sans 12\"><b> " );
text_price[i-index_artikel]=strcat(text_price[i-index_artikel], temp);
text_price[i-index_artikel]=strcat(text_price[i-index_artikel]," EUR</b></span>");

if(strlen(SelectedGroup[i].Path_Pic)==0)sprintf(SelectedGroup[i].Path_Pic,"keinbild.");
snprintf(bild_file,sizeof(bild_file), "/mnt/usb/bilder/%s",SelectedGroup[i].Path_Pic);

gtk_image_set_from_file (Image[i-index_artikel],bild_file);


gtk_widget_show (Image[i-index_artikel]);
text_undertext[i-index_artikel]=strcpy(text_undertext[i-index_artikel],"<span font_desc=\"sans 11\"><i> " );
snprintf(temp,sizeof(temp),"%d",SelectedGroup[i].AnzahlFlaschen);
text_undertext[i-index_artikel]=strcat(text_undertext[i-index_artikel], temp);
text_undertext[i-index_artikel]=strcat(text_undertext[i-index_artikel], SelectedGroup[i].Text);
text_undertext[i-index_artikel]=strcat(text_undertext[i-index_artikel], " Pfand ");
komma_format(SelectedGroup[i].PfKisten, temp);
text_undertext[i-index_artikel]=strcat(text_undertext[i-index_artikel], temp);
text_undertext[i-index_artikel]=strcat(text_undertext[i-index_artikel]," EUR</i></span>");

color.red=0xffff;
color.green=0xffff;
color.blue=0xffff;
gtk_widget_modify_bg (Artikel_button[i-index_artikel], GTK_STATE_NORMAL, &color);
color.red=0xffff;
color.green=0xffff;
color.blue=0xffff;
gtk_widget_modify_bg (Artikel_button[i-index_artikel], GTK_STATE_PRELIGHT, &color);
color.red=0xffff;
color.green=0x9999;
color.blue=0x0000;
gtk_widget_modify_bg (Artikel_button[i-index_artikel], GTK_STATE_ACTIVE, &color);

gtk_button_set_image((GtkButton*)Artikel_button[i-index_artikel],(GtkWidget*)Image[i-index_artikel]);
gtk_widget_show (Artikel_button[i-index_artikel]);
AllowToPress[i-index_artikel]=1;
}
else
{
sprintf(text[i-index_artikel]," ");
sprintf(text_undertext[i-index_artikel]," ");
sprintf(text_price[i-index_artikel]," ");
gtk_widget_hide (Artikel_button[i-index_artikel]);
gtk_widget_hide (Arrows[i-index_artikel]);
gtk_widget_hide (Image[i-index_artikel]);
AllowToPress[i-index_artikel]=0;
}
gtk_label_set_markup(GTK_LABEL(Artikel_label[i-index_artikel]),text[i-index_artikel]);
gtk_label_set_markup(GTK_LABEL(Artikel_label_select_1[i-index_artikel]),text_undertext[i-index_artikel]);
gtk_label_set_markup(GTK_LABEL(Artikel_label_select_2[i-index_artikel]),text_price[i-index_artikel]);

sprintf(text[i-index_artikel]," ");
sprintf(text_undertext[i-index_artikel]," ");
sprintf(text_price[i-index_artikel]," ");

free(text[i-index_artikel]);
free(text_undertext[i-index_artikel]);
free(text_price[i-index_artikel]);
}
seite=(index_artikel/10)+1;
von_seiten=(count_selected/10)+1;
snprintf(label_text,sizeof(label_text),"<span font_desc=\"sans 12\">Seite %d von %d </span>",seite,von_seiten);
gtk_label_set_markup(GTK_LABEL(label_seite), label_text);
gtk_widget_show(label_seite);
}

Peter_APIIT 05-08-2009 03:46 AM

Crash often caused by memory access violation.

benni1 05-08-2009 09:36 AM

which means?
Is the fault in my programm or in the library?

Please give me a hint:)


All times are GMT -5. The time now is 06:47 PM.