When you specify glib idle callbacks to g_idle_add_full() with different priorities, there is no guarantee that they will be called in the order that you added them. But it’s normal that you’d want, for instance, progress callbacks to have a lower priority than the callback that does the work itself. But you probably need to know when the last callback has been called (so you can release state information), and you probably don’t want to show progress information after the work has actually finished.
I added this generic TnyIdleStopper API to tinymail to help us avoid this problem: It’s a kind of a weak-ref smartpointer thing. It seems to stop the crash, and passes the valgrind test, but I worry that there’s a far simpler solution that I’m overlooking.