You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@stdcxx.apache.org by "Farid Zaripov (JIRA)" <ji...@apache.org> on 2008/03/16 06:38:24 UTC
[jira] Created: (STDCXX-769) __rw_debug_iter iterators are
partially invalidated after swap() operation
__rw_debug_iter iterators are partially invalidated after swap() operation
--------------------------------------------------------------------------
Key: STDCXX-769
URL: https://issues.apache.org/jira/browse/STDCXX-769
Project: C++ Standard Library
Issue Type: Bug
Components: 24. Iterators
Affects Versions: 4.2.0, 4.1.4, 4.1.3, 4.1.2
Environment: All
Reporter: Farid Zaripov
Priority: Minor
The __rw_debug_iter class contains pointer to associated container. After swap() operation the __rw_debug_iter iterators, obtained from container method (i.e. begin()) are associated with another container variable. Due to this any operation between iterators, obtained before swap and after swap will fail on assert (except operator==(), maybe some others).
The testcase:
{code title=test.cpp}
#include <vector>
#include <cassert>
int main ()
{
typedef std::vector<int> Vector;
typedef Vector::iterator Iter;
Vector v1, v2;
v1.push_back (1);
Iter v1_begin = v1.begin ();
v1.swap (v2);
assert (v1_begin == v2.begin ());
assert (0 == v1_begin - v2.begin ());
return 0;
};
{code}
The testcase result:
{noformat}
rw/_iterbase.h:527: int __thiscall __rw::__rw_debug_iter<class std::vector<int,class std::allocator<int> >,int *,int *>::operator -<int*>(const class __rw::__rw_debug_iter<class std::vector<int,class std::allocator<int> >,int *,int *> &) const: Assertion '_C_cont && _C_cont == __rhs._C_cont' failed.
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
{noformat}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Updated: (STDCXX-769) __rw_debug_iter iterators are
partially invalidated after swap() operation
Posted by "Farid Zaripov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/STDCXX-769?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Farid Zaripov updated STDCXX-769:
---------------------------------
Description:
The __rw_debug_iter class contains pointer to associated container. After swap() operation the __rw_debug_iter iterators, obtained from container method (i.e. begin()) are associated with another container variable. Due to this any operation between iterators, obtained before swap and after swap will fail on assert (except operator==(), maybe some others).
The testcase:
{code:title=test.cpp}
#include <vector>
#include <cassert>
int main ()
{
typedef std::vector<int> Vector;
typedef Vector::iterator Iter;
Vector v1, v2;
v1.push_back (1);
Iter v1_begin = v1.begin ();
v1.swap (v2);
assert (v1_begin == v2.begin ());
assert (0 == v1_begin - v2.begin ());
return 0;
};
{code}
The testcase result:
{noformat}
rw/_iterbase.h:527: int __thiscall __rw::__rw_debug_iter<class std::vector<int,class std::allocator<int> >,int *,int *>::operator -<int*>(const class __rw::__rw_debug_iter<class std::vector<int,class std::allocator<int> >,int *,int *> &) const: Assertion '_C_cont && _C_cont == __rhs._C_cont' failed.
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
{noformat}
was:
The __rw_debug_iter class contains pointer to associated container. After swap() operation the __rw_debug_iter iterators, obtained from container method (i.e. begin()) are associated with another container variable. Due to this any operation between iterators, obtained before swap and after swap will fail on assert (except operator==(), maybe some others).
The testcase:
{code title=test.cpp}
#include <vector>
#include <cassert>
int main ()
{
typedef std::vector<int> Vector;
typedef Vector::iterator Iter;
Vector v1, v2;
v1.push_back (1);
Iter v1_begin = v1.begin ();
v1.swap (v2);
assert (v1_begin == v2.begin ());
assert (0 == v1_begin - v2.begin ());
return 0;
};
{code}
The testcase result:
{noformat}
rw/_iterbase.h:527: int __thiscall __rw::__rw_debug_iter<class std::vector<int,class std::allocator<int> >,int *,int *>::operator -<int*>(const class __rw::__rw_debug_iter<class std::vector<int,class std::allocator<int> >,int *,int *> &) const: Assertion '_C_cont && _C_cont == __rhs._C_cont' failed.
This application has requested the Runtime to terminate it in an unusual way.
Please contact the application's support team for more information.
{noformat}
> __rw_debug_iter iterators are partially invalidated after swap() operation
> --------------------------------------------------------------------------
>
> Key: STDCXX-769
> URL: https://issues.apache.org/jira/browse/STDCXX-769
> Project: C++ Standard Library
> Issue Type: Bug
> Components: 24. Iterators
> Affects Versions: 4.1.2, 4.1.3, 4.1.4, 4.2.0
> Environment: All
> Reporter: Farid Zaripov
> Priority: Minor
>
> The __rw_debug_iter class contains pointer to associated container. After swap() operation the __rw_debug_iter iterators, obtained from container method (i.e. begin()) are associated with another container variable. Due to this any operation between iterators, obtained before swap and after swap will fail on assert (except operator==(), maybe some others).
> The testcase:
> {code:title=test.cpp}
> #include <vector>
> #include <cassert>
> int main ()
> {
> typedef std::vector<int> Vector;
> typedef Vector::iterator Iter;
> Vector v1, v2;
> v1.push_back (1);
> Iter v1_begin = v1.begin ();
> v1.swap (v2);
> assert (v1_begin == v2.begin ());
> assert (0 == v1_begin - v2.begin ());
> return 0;
> };
> {code}
> The testcase result:
> {noformat}
> rw/_iterbase.h:527: int __thiscall __rw::__rw_debug_iter<class std::vector<int,class std::allocator<int> >,int *,int *>::operator -<int*>(const class __rw::__rw_debug_iter<class std::vector<int,class std::allocator<int> >,int *,int *> &) const: Assertion '_C_cont && _C_cont == __rhs._C_cont' failed.
> This application has requested the Runtime to terminate it in an unusual way.
> Please contact the application's support team for more information.
> {noformat}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (STDCXX-769) __rw_debug_iter iterators are
partially invalidated after swap() operation
Posted by "Farid Zaripov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/STDCXX-769?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12579276#action_12579276 ]
Farid Zaripov commented on STDCXX-769:
--------------------------------------
Then we should eliminate the debugging iterators at all, because all checks in it's members are using pointer to associated container and this pointer becomes invalid after swap operation.
> __rw_debug_iter iterators are partially invalidated after swap() operation
> --------------------------------------------------------------------------
>
> Key: STDCXX-769
> URL: https://issues.apache.org/jira/browse/STDCXX-769
> Project: C++ Standard Library
> Issue Type: Bug
> Components: 24. Iterators
> Affects Versions: 4.1.2, 4.1.3, 4.1.4, 4.2.0
> Environment: All
> Reporter: Farid Zaripov
> Priority: Minor
>
> The __rw_debug_iter class contains pointer to associated container. After swap() operation the __rw_debug_iter iterators, obtained from container method (i.e. begin()) are associated with another container variable. Due to this any operation between iterators, obtained before swap and after swap will fail on assert (except operator==(), maybe some others).
> The testcase:
> {code:title=test.cpp}
> #include <vector>
> #include <cassert>
> int main ()
> {
> typedef std::vector<int> Vector;
> typedef Vector::iterator Iter;
> Vector v1, v2;
> v1.push_back (1);
> Iter v1_begin = v1.begin ();
> v1.swap (v2);
> assert (v1_begin == v2.begin ());
> assert (0 == v1_begin - v2.begin ());
> return 0;
> };
> {code}
> The testcase result:
> {noformat}
> rw/_iterbase.h:527: int __thiscall __rw::__rw_debug_iter<class std::vector<int,class std::allocator<int> >,int *,int *>::operator -<int*>(const class __rw::__rw_debug_iter<class std::vector<int,class std::allocator<int> >,int *,int *> &) const: Assertion '_C_cont && _C_cont == __rhs._C_cont' failed.
> This application has requested the Runtime to terminate it in an unusual way.
> Please contact the application's support team for more information.
> {noformat}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (STDCXX-769) __rw_debug_iter iterators are
partially invalidated after swap() operation
Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/STDCXX-769?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12579267#action_12579267 ]
Martin Sebor commented on STDCXX-769:
-------------------------------------
I realize that, but I still don't understand why the debugging iterators shouldn't provide the same guarantees as the ordinary ones. If anything, they should be more robust, i.e., provide additional guarantees beyond those required of the ordinary ones.
> __rw_debug_iter iterators are partially invalidated after swap() operation
> --------------------------------------------------------------------------
>
> Key: STDCXX-769
> URL: https://issues.apache.org/jira/browse/STDCXX-769
> Project: C++ Standard Library
> Issue Type: Bug
> Components: 24. Iterators
> Affects Versions: 4.1.2, 4.1.3, 4.1.4, 4.2.0
> Environment: All
> Reporter: Farid Zaripov
> Priority: Minor
>
> The __rw_debug_iter class contains pointer to associated container. After swap() operation the __rw_debug_iter iterators, obtained from container method (i.e. begin()) are associated with another container variable. Due to this any operation between iterators, obtained before swap and after swap will fail on assert (except operator==(), maybe some others).
> The testcase:
> {code:title=test.cpp}
> #include <vector>
> #include <cassert>
> int main ()
> {
> typedef std::vector<int> Vector;
> typedef Vector::iterator Iter;
> Vector v1, v2;
> v1.push_back (1);
> Iter v1_begin = v1.begin ();
> v1.swap (v2);
> assert (v1_begin == v2.begin ());
> assert (0 == v1_begin - v2.begin ());
> return 0;
> };
> {code}
> The testcase result:
> {noformat}
> rw/_iterbase.h:527: int __thiscall __rw::__rw_debug_iter<class std::vector<int,class std::allocator<int> >,int *,int *>::operator -<int*>(const class __rw::__rw_debug_iter<class std::vector<int,class std::allocator<int> >,int *,int *> &) const: Assertion '_C_cont && _C_cont == __rhs._C_cont' failed.
> This application has requested the Runtime to terminate it in an unusual way.
> Please contact the application's support team for more information.
> {noformat}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Closed: (STDCXX-769) __rw_debug_iter iterators are partially
invalidated after swap() operation
Posted by "Farid Zaripov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/STDCXX-769?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Farid Zaripov closed STDCXX-769.
--------------------------------
Resolution: Won't Fix
This is a just documenting issue. I don't think that it's will be fixed, because it's can be fixed only by removing these asserts.
Closing as Won't Fix.
> __rw_debug_iter iterators are partially invalidated after swap() operation
> --------------------------------------------------------------------------
>
> Key: STDCXX-769
> URL: https://issues.apache.org/jira/browse/STDCXX-769
> Project: C++ Standard Library
> Issue Type: Bug
> Components: 24. Iterators
> Affects Versions: 4.1.2, 4.1.3, 4.1.4, 4.2.0
> Environment: All
> Reporter: Farid Zaripov
> Priority: Minor
>
> The __rw_debug_iter class contains pointer to associated container. After swap() operation the __rw_debug_iter iterators, obtained from container method (i.e. begin()) are associated with another container variable. Due to this any operation between iterators, obtained before swap and after swap will fail on assert (except operator==(), maybe some others).
> The testcase:
> {code:title=test.cpp}
> #include <vector>
> #include <cassert>
> int main ()
> {
> typedef std::vector<int> Vector;
> typedef Vector::iterator Iter;
> Vector v1, v2;
> v1.push_back (1);
> Iter v1_begin = v1.begin ();
> v1.swap (v2);
> assert (v1_begin == v2.begin ());
> assert (0 == v1_begin - v2.begin ());
> return 0;
> };
> {code}
> The testcase result:
> {noformat}
> rw/_iterbase.h:527: int __thiscall __rw::__rw_debug_iter<class std::vector<int,class std::allocator<int> >,int *,int *>::operator -<int*>(const class __rw::__rw_debug_iter<class std::vector<int,class std::allocator<int> >,int *,int *> &) const: Assertion '_C_cont && _C_cont == __rhs._C_cont' failed.
> This application has requested the Runtime to terminate it in an unusual way.
> Please contact the application's support team for more information.
> {noformat}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (STDCXX-769) __rw_debug_iter iterators are
partially invalidated after swap() operation
Posted by "Farid Zaripov (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/STDCXX-769?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12579256#action_12579256 ]
Farid Zaripov commented on STDCXX-769:
--------------------------------------
This issue talking about __rw_debug_iter wraper class, that used in debug builds in all container classes when _RWSTD_NO_DEBUG_ITER macro is not defined.
STDCXX-635 is related to deque iterator with no matter _RWSTD_NO_DEBUG_ITER defined or not.
> __rw_debug_iter iterators are partially invalidated after swap() operation
> --------------------------------------------------------------------------
>
> Key: STDCXX-769
> URL: https://issues.apache.org/jira/browse/STDCXX-769
> Project: C++ Standard Library
> Issue Type: Bug
> Components: 24. Iterators
> Affects Versions: 4.1.2, 4.1.3, 4.1.4, 4.2.0
> Environment: All
> Reporter: Farid Zaripov
> Priority: Minor
>
> The __rw_debug_iter class contains pointer to associated container. After swap() operation the __rw_debug_iter iterators, obtained from container method (i.e. begin()) are associated with another container variable. Due to this any operation between iterators, obtained before swap and after swap will fail on assert (except operator==(), maybe some others).
> The testcase:
> {code:title=test.cpp}
> #include <vector>
> #include <cassert>
> int main ()
> {
> typedef std::vector<int> Vector;
> typedef Vector::iterator Iter;
> Vector v1, v2;
> v1.push_back (1);
> Iter v1_begin = v1.begin ();
> v1.swap (v2);
> assert (v1_begin == v2.begin ());
> assert (0 == v1_begin - v2.begin ());
> return 0;
> };
> {code}
> The testcase result:
> {noformat}
> rw/_iterbase.h:527: int __thiscall __rw::__rw_debug_iter<class std::vector<int,class std::allocator<int> >,int *,int *>::operator -<int*>(const class __rw::__rw_debug_iter<class std::vector<int,class std::allocator<int> >,int *,int *> &) const: Assertion '_C_cont && _C_cont == __rhs._C_cont' failed.
> This application has requested the Runtime to terminate it in an unusual way.
> Please contact the application's support team for more information.
> {noformat}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (STDCXX-769) __rw_debug_iter iterators are
partially invalidated after swap() operation
Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/STDCXX-769?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12579278#action_12579278 ]
Martin Sebor commented on STDCXX-769:
-------------------------------------
Well, that sounds like a design problem with the debugging iterators. It may not be one that can be fixed without breaking binary compatibility but I think if it is, in fact, a problem (there's some question regarding what iterator validity means for non-invalidating operations like {{swap()}} or {{list::splice()}}), we must fix it.
> __rw_debug_iter iterators are partially invalidated after swap() operation
> --------------------------------------------------------------------------
>
> Key: STDCXX-769
> URL: https://issues.apache.org/jira/browse/STDCXX-769
> Project: C++ Standard Library
> Issue Type: Bug
> Components: 24. Iterators
> Affects Versions: 4.1.2, 4.1.3, 4.1.4, 4.2.0
> Environment: All
> Reporter: Farid Zaripov
> Priority: Minor
>
> The __rw_debug_iter class contains pointer to associated container. After swap() operation the __rw_debug_iter iterators, obtained from container method (i.e. begin()) are associated with another container variable. Due to this any operation between iterators, obtained before swap and after swap will fail on assert (except operator==(), maybe some others).
> The testcase:
> {code:title=test.cpp}
> #include <vector>
> #include <cassert>
> int main ()
> {
> typedef std::vector<int> Vector;
> typedef Vector::iterator Iter;
> Vector v1, v2;
> v1.push_back (1);
> Iter v1_begin = v1.begin ();
> v1.swap (v2);
> assert (v1_begin == v2.begin ());
> assert (0 == v1_begin - v2.begin ());
> return 0;
> };
> {code}
> The testcase result:
> {noformat}
> rw/_iterbase.h:527: int __thiscall __rw::__rw_debug_iter<class std::vector<int,class std::allocator<int> >,int *,int *>::operator -<int*>(const class __rw::__rw_debug_iter<class std::vector<int,class std::allocator<int> >,int *,int *> &) const: Assertion '_C_cont && _C_cont == __rhs._C_cont' failed.
> This application has requested the Runtime to terminate it in an unusual way.
> Please contact the application's support team for more information.
> {noformat}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.
[jira] Commented: (STDCXX-769) __rw_debug_iter iterators are
partially invalidated after swap() operation
Posted by "Martin Sebor (JIRA)" <ji...@apache.org>.
[ https://issues.apache.org/jira/browse/STDCXX-769?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=12579252#action_12579252 ]
Martin Sebor commented on STDCXX-769:
-------------------------------------
But we fixed STDCXX-635 which deals with invalidating {{deque::iterator}} after calling {{std::swap}} . How is this different?
> __rw_debug_iter iterators are partially invalidated after swap() operation
> --------------------------------------------------------------------------
>
> Key: STDCXX-769
> URL: https://issues.apache.org/jira/browse/STDCXX-769
> Project: C++ Standard Library
> Issue Type: Bug
> Components: 24. Iterators
> Affects Versions: 4.1.2, 4.1.3, 4.1.4, 4.2.0
> Environment: All
> Reporter: Farid Zaripov
> Priority: Minor
>
> The __rw_debug_iter class contains pointer to associated container. After swap() operation the __rw_debug_iter iterators, obtained from container method (i.e. begin()) are associated with another container variable. Due to this any operation between iterators, obtained before swap and after swap will fail on assert (except operator==(), maybe some others).
> The testcase:
> {code:title=test.cpp}
> #include <vector>
> #include <cassert>
> int main ()
> {
> typedef std::vector<int> Vector;
> typedef Vector::iterator Iter;
> Vector v1, v2;
> v1.push_back (1);
> Iter v1_begin = v1.begin ();
> v1.swap (v2);
> assert (v1_begin == v2.begin ());
> assert (0 == v1_begin - v2.begin ());
> return 0;
> };
> {code}
> The testcase result:
> {noformat}
> rw/_iterbase.h:527: int __thiscall __rw::__rw_debug_iter<class std::vector<int,class std::allocator<int> >,int *,int *>::operator -<int*>(const class __rw::__rw_debug_iter<class std::vector<int,class std::allocator<int> >,int *,int *> &) const: Assertion '_C_cont && _C_cont == __rhs._C_cont' failed.
> This application has requested the Runtime to terminate it in an unusual way.
> Please contact the application's support team for more information.
> {noformat}
--
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.