g_main_dispatch frees objects for input_callback before using them (how to prevent it?)

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

 



Hi everyone, I'm trying to revive a very old project: XQF, a graphical game server browser.

Many things are deprecated in this old code, but there is one that particularly bothers me: I try to port gdk_input_* calls to g_io.

I do something like that: https://github.com/XQF/xqf/commit/cf2b506547755c6f7176979cf8b7db189c14c7e4

I rewrite some callbacks with new functions, new types, gdk_input_remove is replaced by g_source_remove, gdk_input_add is replaced by g_io_add_watch and I use GioChannel, etc.

So everything seems to work… until g_main_dispatch calls my callback.

You can read all my investigations here: https://github.com/XQF/xqf/issues/4

I see g_io_add_watch add a callback on a channel with a user_data reference, and yes, It works when I trace the code with gdb. The callback is added with the pointer to user_data, and when I trace the execution, pointers are the good ones.

But when g_io_add_watch returns to the main loop, g_main_dispatch frees some objects and then call the callback… and segfaults because the callback was launched with a null pointer user_data!

You can read a complete walktrough here : https://github.com/XQF/xqf/issues/4#issuecomment-58442986

I'm looking for a way to prevent g_main_dispatch to forget the user_data and conditions before the call of my input_callback.

Is anyone have any idea what's going on?

Thank you in advance!

--
Thomas DEBESSE
_______________________________________________
gtk-list mailing list
gtk-list@xxxxxxxxx
https://mail.gnome.org/mailman/listinfo/gtk-list

[Index of Archives]     [Touch Screen Library]     [GIMP Users]     [Gnome]     [KDE]     [Yosemite News]     [Steve's Art]

  Powered by Linux