Re: Bug in GLib, libglade, libc??



Thank you very much, Yeti and Samuel, for your replies!

I really believe that there is something wrong in MY code, and not in libglade, nor libc, nor GTK, etc., that makes my program react so different every time I compile and run it. However, I still could not figure what exactly is wrong.

I have a suspicion from my lack of practice in C: a module of my program uses a structured type which must contain, as its last member, a dynamic list of strings, i.e., pointers to gchars (**list). Sometimes I need to fill only the first string, and sometimes I will need more than one string. So I suspect that each attempt to set a value for one of these pointers cause a serious corruption of other areas of the program, like the GTK stuff in memory. I have tried to assign values to this (these) pointers both with g_strdup and by creating a local, initialized array and assigning its address to the pointer. Neither worked. Do you think I should give each pointer a malloc'd space somewhere in memory, and then strcpy the value to this pointer?

By the way, I have read a lot of GDB and Valgrind docs, and still could not get anything from them. My application is one of those standard libglade apps with a main() function that only loads a main window from the XML and show it, and I really don´t understand some things from Valgrind:

- "Conditional jump or move depends on uninitialised values", which is by itself not so bad, according to Valgrind docs;

- "Syscall param write (buf) points to uninitialised byte(s)" in the lines which calls gtk_init(&argc, &argv) and gtk_init(); which, if I am right, is normal as there is nothing passed to the application in the command line;

- Various "Invalid read of size 4 (...) Address 0xxxxx is 24 bytes inside a block of size 25 alloc´d" caused by the line with "glade_xml_signal_autoconnect". Hey, what is wrong if an address is WITHIN the alloc´d block?? And look that, until now, there is *not* code of "myself", it is just what every libglade example tells!

- "Invalid free() / delete / delete[]" in the lines right after gtk_main(), where I try to g_free both the pointers to the loaded XML file and the main window widget. I have set breakpoints in GDB right before these lines and they HAD non-NULL values until here...

- The program finishes with surprising 141kB "possibly lost" and 931kB (!) "still reachable" memory leaks. I can´t figure out what exactly is causing such a memory waste -- the only thing the program does until now is loading and closing the main window and a dialog window! In GTK/libglade programming, could you point out which are the most common "to-check" things to avoid that?

Please, sorry for such a big post, but I hope you understand that, as Yeti said, I am really *trying* to debug the thing by myself, instead of just coming here and shout.... but until now I couldn´t really find any big clue with GDB, and, although Valgrind is really impressive, it does not tell much about *what* to do for newbies like me -- as a friend said, it is like going to a physician who says "hmm, it looks like you have fluid in your left lung", but does not tell you how it happened and what to do then...

Thank you again and best regards to all!

Fabricio Rocha
Brasilia, Brasil

        
        
                
_______________________________________________________ O Yahoo! está de cara nova. Venha conferir! http://br.yahoo.com



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