Found: Shortest way to trigger core-dump :-(



Hello,

it took me more than two days to strip a programm with more than
4000 lines of code to this 20 line code which shows the same
"Segmentation fault" error.  In fact in a medium state of the
stripping process it changed from an original "Bus-Error" to the
"Segmentation fault" it shows in this state.  Dmalloc dies shamelessly
without any message.

If I remove any line of the following code the error will mysteriousely
disappear and so I found the "shortest way" to let GTK+ die :-(.

Can anybody enlighten me, WHY?  I'm really confused and don't know
what to do to make it work right.

Many thanks for any help!!

      Andreas.

Here comes the program followed by a small Makefile.

------------------------ cbtest.c -------------------------------------
#include <gtk/gtk.h>


static void Function(void *data, GtkSignalFunc func, char *question)
{
  GtkWidget *window, *button;

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_signal_connect(GTK_OBJECT(window), "destroy", GTK_SIGNAL_FUNC(gtk_widget_destroyed), &window);

  button = gtk_button_new_with_label("Press me!");
  gtk_signal_connect(GTK_OBJECT(button), "clicked", func, NULL);
  gtk_signal_connect_object(GTK_OBJECT(button), "clicked", GTK_SIGNAL_FUNC(gtk_widget_destroy), 
                            GTK_OBJECT(window));
  gtk_container_add(GTK_CONTAINER(window), button);

  gtk_widget_show_all(window);
}


static void Callback()
{
  g_warning("That's all for today!");
}

static void MainCallback(GtkWidget *button, char *dummy)
{
  char    *file, *buf;

  file = g_strdup("");
  buf  = g_strdup("");
  Function(file, GTK_SIGNAL_FUNC(Callback), buf);
  if ( buf )  g_free(buf); 
}

void main(int argc, char **argv)
{
  GtkWidget *window;

  gtk_init(&argc, &argv);

  window = gtk_window_new(GTK_WINDOW_TOPLEVEL);
  gtk_signal_connect(GTK_OBJECT(window), "configure_event", GTK_SIGNAL_FUNC(MainCallback), NULL);
  gtk_widget_show(window);

  gtk_main();
}

-----------------------------------------------------------------------

NAME=cbtest

CFLAGS=-g -O2 -Wall `gtk-config --cflags`
LDFLAGS=`gtk-config --libs` -s

$(NAME): $(NAME).o
$(NAME).o: $(NAME).c




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