Re: Segmentation Fault Question




 No, it does not happen on fuction display:

 Here is what is happening:

 gdb> starting program: /home/harringf/downloads/a.out a.out

Program received signal SIGSEGV, Segmentation fault.
g_string_maybe_expand (string=0x80490cc, len=1) at gstring.c:88
88      {
(gdb) where
#0  g_string_maybe_expand (string=0x80490cc, len=1) at gstring.c:88
#1  0x40405a40 in g_string_insert_c (string=0x80490cc, pos=-1, c=47 '/') at
gstring.c:543
#2  0x404056a8 in g_string_append_c (string=0xa188b852, c=81 'Q') at
gstring.c:452
#3  0x08048e4d in permittedsyscall (regs=0xbfffdc50) at sandbox.c:60
#4  0x08049074 in main (argc=2, argv=0xbfffdd04) at sandbox.c:108
#5  0x420156a4 in __libc_start_main () from /lib/tls/libc.so.6


  So, if you go to sandbox.c at line 60; you will find:

  fpath = g_string_append_c (fpath, (char)nextword);


  Now, if you go to g_string_append source on glib/string.c, you will see:
GString*
g_string_append_c (GString *string,
                   gchar    c)
{
  g_return_val_if_fail (string != NULL, NULL);

  ...
}

 So, you never initialized you path (Gstring* path;).

 Make sure you initialise you  'path' variable inside that function.

 
 Regards.  (by the way, I could not compile your code because there was a
gtk_buttonnew_... that should have been gtk_button_new...)


Regards, Harring.


  

--- Mel Harbour <mrh30 cam ac uk> wrote:
I've managed to narrow the problem down a bit.  The segmentation fault
occurs when the function display() calls gtk_window_new.  Does anyone
have any ideas what gtk_window_new is doing to cause a segfault here?

Mel

Mel Harbour wrote:
Appologies if this isn't the right place to post this!

A program I'm writing, using GTK, is failing to run correctly.  In short 
it throws out a segmentation fault the first time I call something gtk 
related other than gtk_init.

My code is at http://www.srcf.ucam.org/~mrh30/sandbox.c
with header file sandbox.h from the same address.

The fault originates somewhere in the function permittedsyscall.  If I 
comment out the line 'display();' in the above function, the program 
runs as expected and will output a list of all the files opened by the 
program run through the sandbox.

If you get rid of the code to extract those filenames and put the 
display() line back in, it also runs (apparently) correctly, putting a 
window up on screen.

If I have both however, I get segmentation faults, which I would have 
thought was quite odd since neither part has any dealings with the other 
part.

Mel

_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list





_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list


__________________________________
Do you Yahoo!?
Yahoo! SiteBuilder - Free, easy-to-use web site design software
http://sitebuilder.yahoo.com



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