SEGFAULT On Application Quit

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

I hadn't noticed this problem because it didn't really disrupt usability and I wasn't starting the application from the terminal until I had to recompile it on a new system recently.
When I click the X button in the top-right corner of my applications window, there's a SEGFAULT happening.
The application appears to quit, the process vanishes from the process list like it should.

Here's a link to the source at Google Code
http://code.google.com/p/picksel/source/browse/trunk/picksel.c?r=23
  • Anonymous
  • Bot
  • No Avatar
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post 3+ Months Ago

  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

It's somewhere within the call to save_preferences that's inside the quit_running function. Commenting that call out gets rid of the SEGFAULT. That function does not cause a SEGFAULT when called at other times though.

Code: [ Select ]
/*
    Sets running state to false so main() loop knows to quit,
    connected to destroy signal & File->Quit menuitems activate signal
*/
void quit_running()
{
    //save_preferences ();
    running = FALSE;
}
  1. /*
  2.     Sets running state to false so main() loop knows to quit,
  3.     connected to destroy signal & File->Quit menuitems activate signal
  4. */
  5. void quit_running()
  6. {
  7.     //save_preferences ();
  8.     running = FALSE;
  9. }
  • joebert
  • Fart Bubbles
  • Genius
  • User avatar
  • Posts: 13503
  • Loc: Florida

Post 3+ Months Ago

SEGFAULT traces to line 216

Code: [ Select ]
kdata = g_key_file_to_data (prefs, &size, NULL);


Which traces to this warning during compilation,
Code: [ Select ]
picksel.c:216: warning: passing argument 2 of ‘g_key_file_to_data’ from incompatible pointer type


Which leads to this prototype
Code: [ Select ]
gchar*     g_key_file_to_data             (GKeyFile *key_file,
                                            gsize *length,
                                            GError **error);
  1. gchar*     g_key_file_to_data             (GKeyFile *key_file,
  2.                                             gsize *length,
  3.                                             GError **error);


Which points back to the declaration of argument #2, "size"
Code: [ Select ]
    gint        size;


Which seems to be the problem, that causes me to alter that declaration to the following
Code: [ Select ]
    gsize     size;


and cast the new gsize to a gint a for g_file_set_contents
Code: [ Select ]
        g_file_set_contents (path, kdata, (gint)size, NULL);


Which gets rid of that compilation warning, and subsequently the SEGFAULT. :D

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 113 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
 
 

© 1998-2014. Ozzu® is a registered trademark of Unmelted, LLC.