After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 306249 - signal_impl::slots_ leaks slots
signal_impl::slots_ leaks slots
Status: RESOLVED FIXED
Product: libsigc++
Classification: Bindings
Component: signals
2.0.x
Other Windows
: Normal normal
: ---
Assigned To: Martin Schulze
Martin Schulze
Depends on:
Blocks:
 
 
Reported: 2005-06-02 11:49 UTC by Andreas Ames
Modified: 2005-06-07 13:46 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
A quick hack as workaround (1.66 KB, patch)
2005-06-02 11:52 UTC, Andreas Ames
none Details | Review
Simple test case to demonstrate the bug. (1.26 KB, text/plain)
2005-06-06 09:47 UTC, Andreas Ames
  Details

Description Andreas Ames 2005-06-02 11:49:25 UTC
Version details: 2.0.11
Distribution/Version: XP SP2 with MSVC .NET 2003 (7.1)

Disconnecting a connection while the corresponding signal (without an
accumulator) is emitted leaks the related slot_base instance.

The reason is that

struct signal_emit2<T_return, T_arg1,T_arg2, nil>::emit (in signal.h)

relies on a specific sequence of destructor calls for the automatic variables
'exec' (of type signal_exec) and 'slots' (of type temp_slot_list). 
Unfortunately my compiler has it the 'wrong' way around.

I attach a hack which works around this but I don't believe it's worth to be
checked in because:

* it is ugly

* it only handles signal_emit2 while I think that the other signal_emit# classes
have the same problem (in the specialisation without accumulator)

* as Bug 303896 and other recent discussions, IMHO, seem to suggest, the current
semantics of connecting and disconnecting slots during emission seems to warrant
a more profound reimplementation and I seem to have read that something like
that is underway (?)
Comment 1 Andreas Ames 2005-06-02 11:52:21 UTC
Created attachment 47134 [details] [review]
A quick hack as workaround
Comment 2 Murray Cumming 2005-06-05 12:39:03 UTC
signal.h is a generated file. Please try to submit a cvs patch, changing the .m4
file, and also patching the ChangeLog.

For instance,
cvs -z3 diff -up > something.patch.

A test case would be nice too.
Comment 3 Andreas Ames 2005-06-06 09:44:54 UTC
Oops, you're right, I've forgotten to mention that my 'patch' is diffed against
2.0.11.  Sorry for any confusion cuased by that.

Diffing against cvs unfortunately doesn't work for me by courtesy of a corporate
firewall.  Sorry for that.  The hack is to just introduce a new inner scope in
which 'slots' is created.  Thus it is ensured that its destructor is called
before 'exec's destructor.

A simple test case is attached.
Comment 4 Andreas Ames 2005-06-06 09:47:08 UTC
Created attachment 47308 [details]
Simple test case to demonstrate the bug.
Comment 5 Andreas Ames 2005-06-07 10:33:53 UTC
BTW:  This also happens with cygwin's g++ (version 3.3.3 (cygwin special)) and
libsigc++ 2.0.10.
Comment 6 Murray Cumming 2005-06-07 13:46:43 UTC
Thanks, I've applied basically the same thing to the .m4 file. The test case
failed on my Fedora Core 3 g++ 3.4 too.