Opened 15 years ago

Closed 15 years ago

#1007 closed Bugs (fixed)

boost::signals::trackable::operator= bug

Reported by: anonymous Owned by: Douglas Gregor
Milestone: Component: signals
Version: Boost 1.34.0 Severity: Problem
Keywords: Cc:

Description

Boost: 1.34.0 Compiler: MSVC 8.0 (without SP1).

Here is, minimal example.

struct Conn : public boost::signals::trackable {

void operator()(){}

};

void f() {

boost::signal<void ()> sig; Conn c; sig.connect( c );

c = Conn(); crash inside..

}

The reason is simple. During clear() method of std::list, there are signals::connection destructor calls are happening, which, in turn, calling erase method of the same std::list, and as a result we're getting _DEBUG_ERROR("list erase iterator outside range");

I guess, the bug is with "dying" variable: in destructor, it was set to true, and then signals::connection destructors are not trying to remove themself from the std::list. But in boost::signals::trackable::operator=() there is no dying flag marking.

Evgeny.

Change History (2)

comment:1 by Douglas Gregor, 15 years ago

Owner: set to Douglas Gregor
Status: newassigned

comment:2 by Douglas Gregor, 15 years ago

Resolution: fixed
Status: assignedclosed

This is the fix, which is committed to the Boost trunk for future releases. It is probably too late for 1.34.1:

Index: trackable.hpp =================================================================== RCS file: /cvsroot/boost/boost/boost/signals/trackable.hpp,v retrieving revision 1.19 diff -u -r1.19 trackable.hpp --- trackable.hpp 26 Dec 2004 22:05:19 -0000 1.19 +++ trackable.hpp 11 Jun 2007 20:16:13 -0000 @@ -43,7 +43,9 @@

trackable& operator=(const trackable&) {

+ dying = true;

connected_signals.clear();

+ dying = false;

return *this;

}

Note: See TracTickets for help on using tickets.