public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/35969]  New: GLIBCXX_DEBUG: list::merge triggers bad assert
@ 2008-04-18  3:12 greened at obbligato dot org
  2008-04-18  3:13 ` [Bug libstdc++/35969] " greened at obbligato dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: greened at obbligato dot org @ 2008-04-18  3:12 UTC (permalink / raw)
  To: gcc-bugs

The attached preprocessed source when compiled with -D_GLIBCXX_DEBUG encounters
a runtime assert at the final call to splice.  According to
http://www.sgi.com/tech/stl/List.html, all iterators remain valid after a merge
operation.  I believe that libstdc++ is not updating the _M_sequence members of
the safe iterators merged into list1.

I've also attached unpreprocessed source with comments indicating the problem.

To reproduce the problem:

% g++ -D_GLIBCXX_DEBUG list.ii
% ./a.out
/usr/include/c++/4.2/debug/list:350:error: attempt to splice an iterator
    from a different container.

Objects involved in the operation:
iterator "__i" @ 0x0xbfd5ea30 {
type =
N11__gnu_debug14_Safe_iteratorINSt6__norm14_List_iteratorIiEENSt7__debug4listIiSaIiEEEEE
(mutable iterator);
  state = dereferenceable;
  references sequence with type `NSt7__debug4listIiSaIiEEE' @ 0x0xbfd5ea30
}
sequence "__x" @ 0x0xbfd5e9c4 {
  type = NSt7__debug4listIiSaIiEEE;
}
Aborted


-- 
           Summary: GLIBCXX_DEBUG: list::merge triggers bad assert
           Product: gcc
           Version: 4.2.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: greened at obbligato dot org
 GCC build triplet: i486-linux-gnu
  GCC host triplet: i486-linux-gnu
GCC target triplet: i486-linux-gnu


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35969


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/35969] GLIBCXX_DEBUG: list::merge triggers bad assert
  2008-04-18  3:12 [Bug libstdc++/35969] New: GLIBCXX_DEBUG: list::merge triggers bad assert greened at obbligato dot org
@ 2008-04-18  3:13 ` greened at obbligato dot org
  2008-04-18  3:14 ` greened at obbligato dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: greened at obbligato dot org @ 2008-04-18  3:13 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from greened at obbligato dot org  2008-04-18 03:12 -------
Created an attachment (id=15493)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15493&action=view)
Preprocessed source


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35969


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/35969] GLIBCXX_DEBUG: list::merge triggers bad assert
  2008-04-18  3:12 [Bug libstdc++/35969] New: GLIBCXX_DEBUG: list::merge triggers bad assert greened at obbligato dot org
  2008-04-18  3:13 ` [Bug libstdc++/35969] " greened at obbligato dot org
@ 2008-04-18  3:14 ` greened at obbligato dot org
  2008-04-18  3:24 ` pinskia at gcc dot gnu dot org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: greened at obbligato dot org @ 2008-04-18  3:14 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from greened at obbligato dot org  2008-04-18 03:13 -------
Created an attachment (id=15494)
 --> (http://gcc.gnu.org/bugzilla/attachment.cgi?id=15494&action=view)
Unpreprocessed source

Includes comments describing the problem.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35969


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/35969] GLIBCXX_DEBUG: list::merge triggers bad assert
  2008-04-18  3:12 [Bug libstdc++/35969] New: GLIBCXX_DEBUG: list::merge triggers bad assert greened at obbligato dot org
  2008-04-18  3:13 ` [Bug libstdc++/35969] " greened at obbligato dot org
  2008-04-18  3:14 ` greened at obbligato dot org
@ 2008-04-18  3:24 ` pinskia at gcc dot gnu dot org
  2008-04-18  3:27 ` greened at obbligato dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pinskia at gcc dot gnu dot org @ 2008-04-18  3:24 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from pinskia at gcc dot gnu dot org  2008-04-18 03:23 -------
I don't know if the SGI website has been updated to take into account what the
C++ standard says.  Since STL was originally from HP/SGI, that page is old and
might not reflect reality any more.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35969


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/35969] GLIBCXX_DEBUG: list::merge triggers bad assert
  2008-04-18  3:12 [Bug libstdc++/35969] New: GLIBCXX_DEBUG: list::merge triggers bad assert greened at obbligato dot org
                   ` (2 preceding siblings ...)
  2008-04-18  3:24 ` pinskia at gcc dot gnu dot org
@ 2008-04-18  3:27 ` greened at obbligato dot org
  2008-04-18  4:17 ` greened at obbligato dot org
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: greened at obbligato dot org @ 2008-04-18  3:27 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from greened at obbligato dot org  2008-04-18 03:26 -------
Subject: Re:  GLIBCXX_DEBUG: list::merge triggers bad
 assert

pinskia at gcc dot gnu dot org wrote:
> ------- Comment #3 from pinskia at gcc dot gnu dot org  2008-04-18 03:23 -------
> I don't know if the SGI website has been updated to take into account what the
> C++ standard says.  Since STL was originally from HP/SGI, that page is old and
> might not reflect reality any more.

Sure.  But not everyone has a copy of the standard.  :)  Can we get a
ruling on this?


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35969


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/35969] GLIBCXX_DEBUG: list::merge triggers bad assert
  2008-04-18  3:12 [Bug libstdc++/35969] New: GLIBCXX_DEBUG: list::merge triggers bad assert greened at obbligato dot org
                   ` (3 preceding siblings ...)
  2008-04-18  3:27 ` greened at obbligato dot org
@ 2008-04-18  4:17 ` greened at obbligato dot org
  2008-04-21  0:46 ` pcarlini at suse dot de
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: greened at obbligato dot org @ 2008-04-18  4:17 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from greened at obbligato dot org  2008-04-18 04:16 -------
Ok, the closest thing I could find is the 1998 draft standard:

http://www.kuzbass.ru:8086/docs/isocpp/lib-containers.html#lib.sequences

It says that splice "invalidates only the iterators and references to the
spliced elements."  There is no statement about iterators for merge.

So it seems like the testcase is invalid not due to the merge but due to the
splices.  GLIBCXX_DEBUG mode doesn't catch the problem with the splices since
the iterator is still considered valid after the splice.  For example, the
second splce doesn't assert on an invalid iterator being passed to it.

Perhaps this was changed in the final standard.  It seems odd to me that splice
and merge would invalidate iterators as iterator stability is a prime reason
for using std::list and these operations don't destroy any sequence values.


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35969


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/35969] GLIBCXX_DEBUG: list::merge triggers bad assert
  2008-04-18  3:12 [Bug libstdc++/35969] New: GLIBCXX_DEBUG: list::merge triggers bad assert greened at obbligato dot org
                   ` (4 preceding siblings ...)
  2008-04-18  4:17 ` greened at obbligato dot org
@ 2008-04-21  0:46 ` pcarlini at suse dot de
  2008-04-24 17:04 ` paolo at gcc dot gnu dot org
  2008-04-24 17:06 ` pcarlini at suse dot de
  7 siblings, 0 replies; 9+ messages in thread
From: pcarlini at suse dot de @ 2008-04-21  0:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pcarlini at suse dot de  2008-04-21 00:46 -------
According to the resolution of DR 250,

  http://www.open-std.org/jtc1/sc22/wg21/docs/lwg-defects.html#250

indeed splicing doesn't really invalidate iterators. Therefore, the debug-mode
merge should be consistent with that behavior. The fix seems easy...


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         AssignedTo|unassigned at gcc dot gnu   |pcarlini at suse dot de
                   |dot org                     |
             Status|UNCONFIRMED                 |ASSIGNED
     Ever Confirmed|0                           |1
   Last reconfirmed|0000-00-00 00:00:00         |2008-04-21 00:46:07
               date|                            |


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35969


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/35969] GLIBCXX_DEBUG: list::merge triggers bad assert
  2008-04-18  3:12 [Bug libstdc++/35969] New: GLIBCXX_DEBUG: list::merge triggers bad assert greened at obbligato dot org
                   ` (5 preceding siblings ...)
  2008-04-21  0:46 ` pcarlini at suse dot de
@ 2008-04-24 17:04 ` paolo at gcc dot gnu dot org
  2008-04-24 17:06 ` pcarlini at suse dot de
  7 siblings, 0 replies; 9+ messages in thread
From: paolo at gcc dot gnu dot org @ 2008-04-24 17:04 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from paolo at gcc dot gnu dot org  2008-04-24 17:03 -------
Subject: Bug 35969

Author: paolo
Date: Thu Apr 24 17:03:13 2008
New Revision: 134642

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=134642
Log:
2008-04-24  Paolo Carlini  <pcarlini@suse.de>

        PR libstdc++/35969
        * include/debug/list (merge): Use _M_transfer_iter, consistently
        with the splice members.
        * testsuite/23_containers/list/operations/35969.cc: New.

        * testsuite/23_containers/list/operators: Rename to
        testsuite/23_containers/list/operations.

Added:
    trunk/libstdc++-v3/testsuite/23_containers/list/operations/
      - copied from r134503,
trunk/libstdc++-v3/testsuite/23_containers/list/operators/
    trunk/libstdc++-v3/testsuite/23_containers/list/operations/35969.cc
Removed:
    trunk/libstdc++-v3/testsuite/23_containers/list/operators/
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/debug/list


-- 


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35969


^ permalink raw reply	[flat|nested] 9+ messages in thread

* [Bug libstdc++/35969] GLIBCXX_DEBUG: list::merge triggers bad assert
  2008-04-18  3:12 [Bug libstdc++/35969] New: GLIBCXX_DEBUG: list::merge triggers bad assert greened at obbligato dot org
                   ` (6 preceding siblings ...)
  2008-04-24 17:04 ` paolo at gcc dot gnu dot org
@ 2008-04-24 17:06 ` pcarlini at suse dot de
  7 siblings, 0 replies; 9+ messages in thread
From: pcarlini at suse dot de @ 2008-04-24 17:06 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pcarlini at suse dot de  2008-04-24 17:05 -------
Fixed for 4.4.0.


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|ASSIGNED                    |RESOLVED
         Resolution|                            |FIXED
   Target Milestone|---                         |4.4.0


http://gcc.gnu.org/bugzilla/show_bug.cgi?id=35969


^ permalink raw reply	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2008-04-24 17:06 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-04-18  3:12 [Bug libstdc++/35969] New: GLIBCXX_DEBUG: list::merge triggers bad assert greened at obbligato dot org
2008-04-18  3:13 ` [Bug libstdc++/35969] " greened at obbligato dot org
2008-04-18  3:14 ` greened at obbligato dot org
2008-04-18  3:24 ` pinskia at gcc dot gnu dot org
2008-04-18  3:27 ` greened at obbligato dot org
2008-04-18  4:17 ` greened at obbligato dot org
2008-04-21  0:46 ` pcarlini at suse dot de
2008-04-24 17:04 ` paolo at gcc dot gnu dot org
2008-04-24 17:06 ` pcarlini at suse dot de

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).