[sigc] attempt to copy-construct an iterator from a singular iterator



Hi,

I was ambitious enough to compile my program with -D_GLIBCXX_DEBUG and
got this error message at runtime when I call connect() on a signal. A
very small program to reproduce this behavior is attached.

/usr/include/c++/4.0.2/debug/safe_iterator.h:127:error: attempt to copy-
    construct an iterator from a singular iterator.

I found this page that explained the error message quite well:

  http://lists.boost.org/Archives/boost/2004/09/73359.php

My system is now Ubuntu 5.10 and this did not occur when I compiled and
executed the same source code on Ubuntu 5.04.

gcc package and version details:

  g++-4.0                                4.0.1-4ubuntu9
  gcc (GCC) 4.0.2 20050808 (prerelease) (Ubuntu 4.0.1-4ubuntu9)

stdc++ package:

  libstdc++6-4.0-dev                     4.0.1-4ubuntu9 

I tried with both the precompiled libsigc++ package version 2.0.10-3 and
2.0.17 compiled from source code.  I can also reproduce this on FreeBSD
6.0-RELEASE with libsigc++ 2.0.17 from ports.


This is the full output from executing the attached program compiled
with -D_GLIBCXX_DEBUG on my system:

----- 8< -----

/usr/include/c++/4.0.2/debug/safe_iterator.h:127:error: attempt to copy-
    construct an iterator from a singular iterator.

Objects involved in the operation:
iterator "this" @ 0x0xbf89d3f4 {
type = N11__gnu_debug14_Safe_iteratorIN10__gnu_norm14_List_iteratorIN4sigc9slot_baseEEEN15__gnu_debug_def4listIS4_SaIS4_EEEEE (mutable iterator);
  state = dereferenceable;
  references sequence with type `N15__gnu_debug_def4listIN4sigc9slot_baseESaIS2_EEE' @ 0x0xbf89d3f4
}
iterator "other" @ 0x0xbf89d370 {
type = N11__gnu_debug14_Safe_iteratorIN10__gnu_norm14_List_iteratorIN4sigc9slot_baseEEEN15__gnu_debug_def4listIS4_SaIS4_EEEEE (mutable iterator);
  state = singular;
  references sequence with type `N15__gnu_debug_def4listIN4sigc9slot_baseESaIS2_EEE' @ 0x0xbf89d370
}
Aborted

----- 8< -----

The backtrace from the abort() looks like this:

#2  0xb7d4d2c9 in abort () from /lib/tls/i686/cmov/libc.so.6
No symbol table info available.
#3  0xb7ec5213 in __gnu_debug::_Error_formatter::_M_error () from /usr/lib/libstdc++.so.6
No symbol table info available.
#4  0x08049843 in _Safe_iterator (this=0xbfd90674, __x= 0xbfd905f0) at safe_iterator.h:124
No locals.
#5  0x08049891 in slot_iterator (this=0xbfd90674, i= 0xbfd905f0) at signal.h:49
No locals.
#6  0x080498c4 in sigc::signal0<void, sigc::nil>::connect (this=0xbfd90668, slot_= 0xbfd90688)
    at signal.h:1690
No locals.
#7  0x08048e30 in main () at singular-slot-iterator.cc:23
        my_class = {<sigc::trackable> = {callback_list_ = 0x804c038}, <No data fields>}
        my_signal = {<sigc::signal0<void,sigc::nil>> = {<sigc::signal_base> = {<sigc::trackable> = {
        callback_list_ = 0x0}, impl_ = 0x804d200}, <No data fields>}, <No data fields>}


The singular iterator seems to come from signal_base::connect(), which
does insert(end(), slot_) on an std::list and returns the result.

1690        { return iterator(signal_base::connect(static_cast<const slot_base&>(slot_))); }


Am I doing something wrong or does this suggest that libsigc++ can be
improved in some way? Any hints on what I could try to do?

Regards,
-- 
-\- David Eriksson -/-                              www.2GooD.nu
 
"I personally refuse to use inferior tools because of ideology."
                                                - Linus Torvalds
/* 
   g++ -D_GLIBCXX_DEBUG \
   `pkg-config sigc++-2.0 --cflags --libs` \
   -o singular-slot-iterator singular-slot-iterator.cc 
 */
#include <sigc++/sigc++.h>

using namespace std;

typedef sigc::signal<void> MySignal;

class MyClass : public sigc::trackable
{
  public:
    void MyHandler()
    {}
};

int main()
{
  MyClass my_class;
  MySignal my_signal;
  my_signal.connect(sigc::mem_fun(my_class, &MyClass::MyHandler));

  return 0;
}


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