GTK+ Forums

Discussion forum for GTK+ and Programming. Ask questions, troubleshoot problems, view and post example code, or express your opinions.
It is currently Thu Oct 23, 2014 4:32 am

All times are UTC




Post new topic Reply to topic  [ 6 posts ] 
Author Message
 Post subject: Gtk-demo pickers and this simple routine fails in cygwin
PostPosted: Wed Mar 19, 2014 12:03 am 
Offline
Familiar Face

Joined: Sun Mar 16, 2014 2:17 pm
Posts: 6
How can I find out what is wrong or missing? The pickers in gtk-demo fails in both Gtk3 and Gtk2 in cygwin without any error messages. And also this simple program fails in the same way while most others work OK. When I execute this code from the command line it prints OK1 and then exits. No window no error messages. Running it with gdb gives

Program received signal SIGSEGV, Segmentation fault.
0x00000000 in ?? ()

Compiled with mingw it works OK (file chooser window opens and also OK2 is printed).

I use:

gcc fc.c -O2 -Wall -Wextra `pkg-config gtk+-2.0 --cflags --libs`

or

export PKG_CONFIG_LIBDIR=/cygdrive/c/GTK/lib/pkgconfig/
i686-pc-mingw32-gcc.exe fc.c -Wall -O2 -mwindows `pkg-config gtk+-win32-2.0 --cflags --libs --define-variable=prefix=/cygdrive/c/GTK`

Code:
#include <gtk/gtk.h>

int main( int   argc,
          char *argv[] )
{
  GtkWidget *dialog;
  gtk_init (&argc, &argv);
  printf("OK1\n");

  dialog = gtk_file_chooser_dialog_new ("Open File",
               NULL,
               GTK_FILE_CHOOSER_ACTION_OPEN,
               GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL,
               GTK_STOCK_OPEN, GTK_RESPONSE_ACCEPT,
               NULL);
  printf("OK2\n");
  if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_ACCEPT)
    {
      char *filename;
      filename = gtk_file_chooser_get_filename (GTK_FILE_CHOOSER (dialog));
      printf("file: %s\n", filename);
      g_free (filename);
    }
  gtk_widget_destroy (dialog);
  return 0;
}


Top
 Profile  
 
 Post subject: Re: Gtk-demo pickers and this simple routine fails in cygwin
PostPosted: Wed Mar 19, 2014 6:38 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 764
Location: UK
Hello,

Mingw and Cygwin work in different ways so this may account for the ways this problem is being handled.

First do not depend on printf() to tell you where the error is happening as this is buffered and what you see may well be delayed. If you want to use this technique print to "stderr" which is un-buffered.

To trace exactly where the crash has occurred compile your code with debugging symbols and run with a debugger. Which should give you the exact point of the crash and a back trace so that you can work out what has happened.

_________________
E.


Top
 Profile  
 
 Post subject: Re: Gtk-demo pickers and this simple routine fails in cygwin
PostPosted: Wed Mar 19, 2014 8:36 am 
Offline
Familiar Face

Joined: Sun Mar 16, 2014 2:17 pm
Posts: 6
I did compile with -g when I run with gdb. It crashes somewhere in the routine gtk_file_chooser_dialog_new and never reaches a breakpoint after that call in main. So breakpoint at line 10 (dialog =...) reaches the breakpoint, but anything >10 produces that segmentation fault without much details.

Doesn't printf flush when the program crashes ends? At least in this case it gives the same crashpoint in main.

I also tried to run step by step from breakpoint just before gtk_file_chooser_dialog_new. That ended with an gdb internal error. Seems to be somewhere in cygwin internals. Here is some of the last steps.

Code:
(gdb) s
Single stepping until exit from function g_spawn_close_pid,
which has no line number information.
0x610d5f7c in _sigfe_pthread_mutex_unlock () from /usr/bin/cygwin1.dll
(gdb) s
Single stepping until exit from function _sigfe_pthread_mutex_unlock,
which has no line number information.
0x610d4659 in _sigfe () from /usr/bin/cygwin1.dll
(gdb) s
Single stepping until exit from function _sigfe,
which has no line number information.
pthread_mutex_unlock (mutex=<error reading variable: can't compute CFA for this frame>) at /usr/src/debug/cygwin-1.7.28-2/winsup/cygwin/thread.cc:3162
3162    {
(gdb) s
3163      if (pthread_mutex::is_initializer (mutex))
(gdb) s
is_initializer (mutex=<optimized out>) at /usr/src/debug/cygwin-1.7.28-2/winsup/cygwin/thread.cc:204
204                                      PTHREAD_ERRORCHECK_MUTEX_INITIALIZER_NP) != VALID_STATIC_OBJECT)
(gdb) s
/netrel/src/gdb-7.6.50-4/gdb/inline-frame.c:172: internal-error: inline_frame_this_id: Assertion `!frame_id_eq (*this_id, outer_frame_id)' failed.
A problem internal to GDB has been detected,
further debugging may prove unreliable.
Quit this debugging session? (y or n) y


Last edited by zerohour on Wed Mar 19, 2014 6:10 pm, edited 1 time in total.
Code not within code tags


Top
 Profile  
 
 Post subject: Re: Gtk-demo pickers and this simple routine fails in cygwin
PostPosted: Wed Mar 19, 2014 11:28 am 
Offline
Familiar Face

Joined: Sun Mar 16, 2014 2:17 pm
Posts: 6
I tested on another computer. This simple test program (compiled with the problematic computer) worked OK in both cygwin and mingw. Also the pickers in gtk-demo worked. So is there something wrong in my cygwin setup?

Why don't I get a core dump even when gdb reports segmentation fault? I do get a core dump from a simple address error when compiled outside GTK, but a similar error in this test program does not produce an error message nor a core dump.


Top
 Profile  
 
 Post subject: Re: Gtk-demo pickers and this simple routine fails in cygwin
PostPosted: Thu Mar 20, 2014 7:13 am 
Offline
Never Seen the Sunlight

Joined: Mon Apr 28, 2008 5:52 am
Posts: 764
Location: UK
Any output sent to stdout is normally only line buffered, but may end up fully buffered. One example of how this can happen, the output could be piped to grep.

When an application crashes then it ends abnormally. Therefore any buffers which are part of your application are not flushed.

I did suspect that it would be Cygwin as the crash occurred within one of its libraries. You may not have got a core dump as the crash happened within Cygwin.

_________________
E.


Top
 Profile  
 
 Post subject: Re: Gtk-demo pickers and this simple routine fails in cygwin
PostPosted: Thu Mar 20, 2014 7:50 am 
Offline
Familiar Face

Joined: Sun Mar 16, 2014 2:17 pm
Posts: 6
What can I do about it? I have updated cygwin, but that didn't help. The working computer has an older cygwin version (October 2012). Both have 64 bit Windows 7.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 posts ] 

All times are UTC


Who is online

Users browsing this forum: Google Adsense [Bot] and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group