GNOME Bugzilla – Bug 144420
Segfault in libsigc++
Last modified: 2004-12-22 21:47:04 UTC
My application has started to segfault with latest glibmm and libsigc++. A backtrace with debug symbols from libraries looks like this: Program received signal SIGSEGV, Segmentation fault. 0x082530da in ?? () (gdb) bt
+ Trace 47143
slot_base.h (libsigc++) line 87 gives me this: inline ~slot_rep() { if (detach_) (*detach_)(this); } main.cc (glibmm) line 72 gives me this: if (self->source_) { GSource* s = self->source_; self->source_ = 0; g_source_destroy(s); delete self; // <-- line 72 } Unfortunately, I havn't had success in providing a simple reproducable example of application code.
I'm sorry, we probably can't do anything without a test case. I recommend valgrind for solving these kinds of appplication problems.
Ok, leave this bug open then. I will try to produce a test case. Unfortunately I'm on vacation at the moment, so I probably won't be able to look at this before august.
Can we rely on the fact that these critical two lines in the code: self->source_ = 0; g_source_destroy(s); get executed in the right order? Or might there be come caching that prevent self->source_ from actually being written into memory?
I can't think why they would not be executed in the right order. If we get a test case then we can run valgrind on it.
Maybe we need to change the _destroy() and _notify() SourceConnectionNode methods to match the changes that I recently made in the regular ConnectionNode. Could you try that? I don't want to risk breaking it without a test case.
Created attachment 29828 [details] [review] source-connection-node.patch: Move deletion of SourceConnectionNode object into destroy_notify_callback() exclusively Note that SourceConnectionNode is substantially different from ConnectionNode in that it wraps a GSource object rather than a glib signal. However, here is a patch that moves the deletion of the SourceConnectionNode object into destroy_notify_callback() exclusively (like you did in the regular ConnectionNode). Maybe this helps. Morten, you should try glibmm from cvs with this patch applied before going through the efforts of creating a simple-as-possible test case.
Created attachment 29829 [details] [review] source-connection-node-changelog.patch: Move deletion of SourceConnectionNode object into destroy_notify_callback() exclusively Same as first patch but with ChangeLog entry ... just in case ;)
I have just tried your patch against my glibmm, and it works flawlessly. It is quite easy to reproduce the problem in my application; and clearly when a copy of glibmm with your patch is installed on my system, the segmentation fault stops to occur. Thank you very much. I hope this patch will be in a glibmm release soon.
OK, please commit. Thanks to both of you. Morten, you really need to try valgrind out.
Committed to cvs.