public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/66742] New: abort on sorting list with custom compiler that is not stateless
@ 2015-07-02 14:46 mdiluzio at feralinteractive dot com
  2015-07-02 19:40 ` [Bug libstdc++/66742] " daniel.kruegler at googlemail dot com
                   ` (16 more replies)
  0 siblings, 17 replies; 18+ messages in thread
From: mdiluzio at feralinteractive dot com @ 2015-07-02 14:46 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66742

            Bug ID: 66742
           Summary: abort on sorting list with custom compiler that is not
                    stateless
           Product: gcc
           Version: 4.9.2
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: mdiluzio at feralinteractive dot com
  Target Milestone: ---

Created attachment 35899
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35899&action=edit
main.ii

When using a custom defined allocator that contains state, sorting a list will
cause an abort.

This seems to be due to the __carry list in sort having a null allocator, that
then gets compared to the main list's allocator within splice in
_M_check_equal_allocators.

GCC information:
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Ubuntu
4.9.2-10ubuntu13' --with-bugurl=file:///usr/share/doc/gcc-4.9/README.Bugs
--enable-languages=c,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr
--program-suffix=-4.9 --enable-shared --enable-linker-build-id
--libexecdir=/usr/lib --without-included-gettext --enable-threads=posix
--with-gxx-include-dir=/usr/include/c++/4.9 --libdir=/usr/lib --enable-nls
--with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug
--enable-libstdcxx-time=yes --enable-gnu-unique-object --disable-vtable-verify
--enable-plugin --with-system-zlib --disable-browser-plugin
--enable-java-awt=gtk --enable-gtk-cairo
--with-java-home=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64/jre --enable-java-home
--with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-4.9-amd64
--with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-4.9-amd64
--with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar
--enable-objc-gc --enable-multiarch --disable-werror --with-arch-32=i686
--with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib
--with-tune=generic --enable-checking=release --build=x86_64-linux-gnu
--host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 4.9.2 (Ubuntu 4.9.2-10ubuntu13) 
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-std=c++11' '-g'
'-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/4.9/cc1plus -E -quiet -v -imultiarch
x86_64-linux-gnu -D_GNU_SOURCE main.cpp -mtune=generic -march=x86-64 -std=c++11
-Wall -Wextra -g -fworking-directory -fpch-preprocess -fstack-protector-strong
-Wformat-security -o main.ii
ignoring duplicate directory "/usr/include/x86_64-linux-gnu/c++/4.9"
ignoring nonexistent directory "/usr/local/include/x86_64-linux-gnu"
ignoring nonexistent directory
"/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../x86_64-linux-gnu/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/include/c++/4.9
 /usr/include/x86_64-linux-gnu/c++/4.9
 /usr/include/c++/4.9/backward
 /usr/lib/gcc/x86_64-linux-gnu/4.9/include
 /usr/local/include
 /usr/lib/gcc/x86_64-linux-gnu/4.9/include-fixed
 /usr/include/x86_64-linux-gnu
 /usr/include
End of search list.
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-std=c++11' '-g'
'-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/4.9/cc1plus -fpreprocessed main.ii -quiet
-dumpbase main.cpp -mtune=generic -march=x86-64 -auxbase main -g -Wall -Wextra
-std=c++11 -version -fstack-protector-strong -Wformat-security -o main.s
GNU C++ (Ubuntu 4.9.2-10ubuntu13) version 4.9.2 (x86_64-linux-gnu)
        compiled by GNU C version 4.9.2, GMP version 6.0.0, MPFR version
3.1.2-p11, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
GNU C++ (Ubuntu 4.9.2-10ubuntu13) version 4.9.2 (x86_64-linux-gnu)
        compiled by GNU C version 4.9.2, GMP version 6.0.0, MPFR version
3.1.2-p11, MPC version 1.0.3
GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072
Compiler executable checksum: d311308152d93b993d290cf64f65ff6f
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-std=c++11' '-g'
'-shared-libgcc' '-mtune=generic' '-march=x86-64'
 as -v --64 -o main.o main.s
GNU assembler version 2.25 (x86_64-linux-gnu) using BFD version (GNU Binutils
for Ubuntu) 2.25
COMPILER_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.9/:/usr/lib/gcc/x86_64-linux-gnu/4.9/:/usr/lib/gcc/x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.9/:/usr/lib/gcc/x86_64-linux-gnu/
LIBRARY_PATH=/usr/lib/gcc/x86_64-linux-gnu/4.9/:/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/:/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../lib/:/lib/x86_64-linux-gnu/:/lib/../lib/:/usr/lib/x86_64-linux-gnu/:/usr/lib/../lib/:/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../:/lib/:/usr/lib/
COLLECT_GCC_OPTIONS='-v' '-save-temps' '-Wall' '-Wextra' '-std=c++11' '-g'
'-shared-libgcc' '-mtune=generic' '-march=x86-64'
 /usr/lib/gcc/x86_64-linux-gnu/4.9/collect2 -plugin
/usr/lib/gcc/x86_64-linux-gnu/4.9/liblto_plugin.so
-plugin-opt=/usr/lib/gcc/x86_64-linux-gnu/4.9/lto-wrapper
-plugin-opt=-fresolution=main.res -plugin-opt=-pass-through=-lgcc_s
-plugin-opt=-pass-through=-lgcc -plugin-opt=-pass-through=-lc
-plugin-opt=-pass-through=-lgcc_s -plugin-opt=-pass-through=-lgcc --sysroot=/
--build-id --eh-frame-hdr -m elf_x86_64 --hash-style=gnu --as-needed
-dynamic-linker /lib64/ld-linux-x86-64.so.2 -z relro
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crt1.o
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crti.o
/usr/lib/gcc/x86_64-linux-gnu/4.9/crtbegin.o
-L/usr/lib/gcc/x86_64-linux-gnu/4.9
-L/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu
-L/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../../lib -L/lib/x86_64-linux-gnu
-L/lib/../lib -L/usr/lib/x86_64-linux-gnu -L/usr/lib/../lib
-L/usr/lib/gcc/x86_64-linux-gnu/4.9/../../.. main.o -lstdc++ -lm -lgcc_s -lgcc
-lc -lgcc_s -lgcc /usr/lib/gcc/x86_64-linux-gnu/4.9/crtend.o
/usr/lib/gcc/x86_64-linux-gnu/4.9/../../../x86_64-linux-gnu/crtn.o


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

* [Bug libstdc++/66742] abort on sorting list with custom compiler that is not stateless
  2015-07-02 14:46 [Bug libstdc++/66742] New: abort on sorting list with custom compiler that is not stateless mdiluzio at feralinteractive dot com
@ 2015-07-02 19:40 ` daniel.kruegler at googlemail dot com
  2015-07-02 20:47 ` redi at gcc dot gnu.org
                   ` (15 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: daniel.kruegler at googlemail dot com @ 2015-07-02 19:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66742

Daniel Krügler <daniel.kruegler at googlemail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |daniel.kruegler@googlemail.
                   |                            |com

--- Comment #1 from Daniel Krügler <daniel.kruegler at googlemail dot com> ---
Your definition of operator!= for the allocator test_alloc violates the
allocator requirements, which impose that != behaves the same as the negation
of == (see Table 28 — Allocator requirements, [allocator.requirements]). This
violates causes undefined behaviour. Therefore it seems to me as if this is an
invalid bug report.
>From gcc-bugs-return-491304-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org Thu Jul 02 20:02:23 2015
Return-Path: <gcc-bugs-return-491304-listarch-gcc-bugs=gcc.gnu.org@gcc.gnu.org>
Delivered-To: listarch-gcc-bugs@gcc.gnu.org
Received: (qmail 23928 invoked by alias); 2 Jul 2015 20:02:23 -0000
Mailing-List: contact gcc-bugs-help@gcc.gnu.org; run by ezmlm
Precedence: bulk
List-Id: <gcc-bugs.gcc.gnu.org>
List-Archive: <http://gcc.gnu.org/ml/gcc-bugs/>
List-Post: <mailto:gcc-bugs@gcc.gnu.org>
List-Help: <mailto:gcc-bugs-help@gcc.gnu.org>
Sender: gcc-bugs-owner@gcc.gnu.org
Delivered-To: mailing list gcc-bugs@gcc.gnu.org
Received: (qmail 23905 invoked by uid 48); 2 Jul 2015 20:02:18 -0000
From: "gerhard.steinmetz.fortran@t-online.de" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug fortran/66725] Issue with silent conversion int to char, ICE if int too large
Date: Thu, 02 Jul 2015 20:02:00 -0000
X-Bugzilla-Reason: CC
X-Bugzilla-Type: changed
X-Bugzilla-Watch-Reason: None
X-Bugzilla-Product: gcc
X-Bugzilla-Component: fortran
X-Bugzilla-Version: 5.1.1
X-Bugzilla-Keywords:
X-Bugzilla-Severity: normal
X-Bugzilla-Who: gerhard.steinmetz.fortran@t-online.de
X-Bugzilla-Status: UNCONFIRMED
X-Bugzilla-Resolution:
X-Bugzilla-Priority: P3
X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org
X-Bugzilla-Target-Milestone: ---
X-Bugzilla-Flags:
X-Bugzilla-Changed-Fields:
Message-ID: <bug-66725-4-2B0pF0hUtB@http.gcc.gnu.org/bugzilla/>
In-Reply-To: <bug-66725-4@http.gcc.gnu.org/bugzilla/>
References: <bug-66725-4@http.gcc.gnu.org/bugzilla/>
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: 7bit
X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/
Auto-Submitted: auto-generated
MIME-Version: 1.0
X-SW-Source: 2015-07/txt/msg00194.txt.bz2
Content-length: 858

https://gcc.gnu.org/bugzilla/show_bug.cgi?idf725

--- Comment #2 from Gerhard Steinmetz <gerhard.steinmetz.fortran@t-online.de> ---
A more extensive list of different cases :

   close (1, status%7)
   open (1, access%7)
   open (1, action%7)
   open (1, asynchronous%7)
   open (1, blank%7)
   open (1, delim%7)
   open (1, decimal%7)
   open (1, encoding%7)
   open (1, form%7)
   open (1, pad%7)
   open (1, position%7)
   open (1, round%7)
   open (1, sign%7)
   open (1, status%7)
   read (1, asynchronous%7)
   read (1, blank%7)
   read (1, delim%7)
   read (1, decimal%7)
   read (1, pad%7)
   read (1, round%7)
   read (1, sign%7)
   write (1, asynchronous%7)
   write (1, blank%7)
   write (1, delim%7)
   write (1, decimal%7)
   write (1, pad%7)
   write (1, round%7)
   write (1, sign%7)


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

* [Bug libstdc++/66742] abort on sorting list with custom compiler that is not stateless
  2015-07-02 14:46 [Bug libstdc++/66742] New: abort on sorting list with custom compiler that is not stateless mdiluzio at feralinteractive dot com
  2015-07-02 19:40 ` [Bug libstdc++/66742] " daniel.kruegler at googlemail dot com
@ 2015-07-02 20:47 ` redi at gcc dot gnu.org
  2015-07-03  8:14 ` mdiluzio at feralinteractive dot com
                   ` (14 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2015-07-02 20:47 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66742

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |RESOLVED
         Resolution|---                         |INVALID

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Indeed. Splicing lists has a precondition that l1.get_allocator() ==
l2.get_allocator(), and so we check:

  if (l1.get_allocator() != l2.get_allocator())
    abort();

and obviously that fails for your invalid allocator type.


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

* [Bug libstdc++/66742] abort on sorting list with custom compiler that is not stateless
  2015-07-02 14:46 [Bug libstdc++/66742] New: abort on sorting list with custom compiler that is not stateless mdiluzio at feralinteractive dot com
  2015-07-02 19:40 ` [Bug libstdc++/66742] " daniel.kruegler at googlemail dot com
  2015-07-02 20:47 ` redi at gcc dot gnu.org
@ 2015-07-03  8:14 ` mdiluzio at feralinteractive dot com
  2015-07-03  8:20 ` mdiluzio at feralinteractive dot com
                   ` (13 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: mdiluzio at feralinteractive dot com @ 2015-07-03  8:14 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66742

--- Comment #3 from Marc Di Luzio <mdiluzio at feralinteractive dot com> ---
Created attachment 35901
  --> https://gcc.gnu.org/bugzilla/attachment.cgi?id=35901&action=edit
main.ii

Updating with a valid ==/!= operator pair and state handling, apologies for the
original bad test case.
gcc output is the same verbatim as above.

However, sort still aborts with any allocator that provides ==/!= operators
based on internal state that is non-default.


sort contains a default constructed list __carry, which will have a different
allocator instance to the parent list if an allocator was passed in on
construction -
list.tcc:402
        list __carry;

__carry is then spliced with the parent list -
list.tcc:409
            __carry.splice(__carry.begin(), *this, begin());


A check then occurs if the two allocators are equal -
stl_list.h:1374
        if (this != &__x)
          _M_check_equal_allocators(__x);

allocator.h:188
      static bool
      _S_do_it(const _Alloc& __one, const _Alloc& __two)
      { return __one != __two; }


This final check will fail if the != operator for the allocator is dependent on
internal state comparison, which has differs from the default.

This appears to be incorrect, unless I'm misunderstanding the purpose of the
==/!= operators for allocators?

If this is still considered an issue, I would suggest that __carry be copy
constructed.


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

* [Bug libstdc++/66742] abort on sorting list with custom compiler that is not stateless
  2015-07-02 14:46 [Bug libstdc++/66742] New: abort on sorting list with custom compiler that is not stateless mdiluzio at feralinteractive dot com
                   ` (2 preceding siblings ...)
  2015-07-03  8:14 ` mdiluzio at feralinteractive dot com
@ 2015-07-03  8:20 ` mdiluzio at feralinteractive dot com
  2015-07-03 10:20 ` redi at gcc dot gnu.org
                   ` (12 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: mdiluzio at feralinteractive dot com @ 2015-07-03  8:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66742

Marc Di Luzio <mdiluzio at feralinteractive dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |UNCONFIRMED
         Resolution|INVALID                     |---

--- Comment #4 from Marc Di Luzio <mdiluzio at feralinteractive dot com> ---
I've verified with 5.1 as well now, and the abort still occurs


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

* [Bug libstdc++/66742] abort on sorting list with custom compiler that is not stateless
  2015-07-02 14:46 [Bug libstdc++/66742] New: abort on sorting list with custom compiler that is not stateless mdiluzio at feralinteractive dot com
                   ` (3 preceding siblings ...)
  2015-07-03  8:20 ` mdiluzio at feralinteractive dot com
@ 2015-07-03 10:20 ` redi at gcc dot gnu.org
  2015-07-03 10:29 ` redi at gcc dot gnu.org
                   ` (11 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2015-07-03 10:20 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66742

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |ASSIGNED
   Last reconfirmed|                            |2015-07-03
     Ever confirmed|0                           |1

--- Comment #5 from Jonathan Wakely <redi at gcc dot gnu.org> ---
(In reply to Marc Di Luzio from comment #3)
> If this is still considered an issue, I would suggest that __carry be copy
> constructed.

No, it needs to be constructed empty, but with the same allocator:

    list __carry(get_allocator());

Unfortunately so does every element of the array __tmp:

    list __tmp[64] = { get_allocator(), get_allocator(), get_allocator(),...


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

* [Bug libstdc++/66742] abort on sorting list with custom compiler that is not stateless
  2015-07-02 14:46 [Bug libstdc++/66742] New: abort on sorting list with custom compiler that is not stateless mdiluzio at feralinteractive dot com
                   ` (4 preceding siblings ...)
  2015-07-03 10:20 ` redi at gcc dot gnu.org
@ 2015-07-03 10:29 ` redi at gcc dot gnu.org
  2021-04-10  0:53 ` [Bug libstdc++/66742] abort on sorting list with custom allocator " ahuszagh at gmail dot com
                   ` (10 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2015-07-03 10:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66742

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
So we need something ugly like this:

--- a/libstdc++-v3/include/bits/list.tcc
+++ b/libstdc++-v3/include/bits/list.tcc
@@ -398,6 +398,8 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
          }
       }

+#define _GLIBCXX_REPEAT_8(_X) _X, _X, _X, _X, _X, _X, _X, _X
+
   template<typename _Tp, typename _Alloc>
     void
     list<_Tp, _Alloc>::
@@ -407,8 +409,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
       if (this->_M_impl._M_node._M_next != &this->_M_impl._M_node
          && this->_M_impl._M_node._M_next->_M_next != &this->_M_impl._M_node)
       {
-        list __carry;
-        list __tmp[64];
+        list __carry(get_allocator());
+        list __tmp[64] = {
+           _GLIBCXX_REPEAT_8(_GLIBCXX_REPEAT_8(list(get_allocator())))
+       };
         list * __fill = &__tmp[0];
         list * __counter;

@@ -484,8 +488,10 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
        if (this->_M_impl._M_node._M_next != &this->_M_impl._M_node
            && this->_M_impl._M_node._M_next->_M_next !=
&this->_M_impl._M_node)
          {
-           list __carry;
-           list __tmp[64];
+           list __carry(get_allocator());
+           list __tmp[64] = {
+               _GLIBCXX_REPEAT_8(_GLIBCXX_REPEAT_8(list(get_allocator())))
+           };
            list * __fill = &__tmp[0];
            list * __counter;

@@ -511,6 +517,7 @@ _GLIBCXX_BEGIN_NAMESPACE_CONTAINER
            swap(*(__fill - 1));
          }
       }
+#undef _GLIBCXX_REPEAT_8

 _GLIBCXX_END_NAMESPACE_CONTAINER
 } // namespace std


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

* [Bug libstdc++/66742] abort on sorting list with custom allocator that is not stateless
  2015-07-02 14:46 [Bug libstdc++/66742] New: abort on sorting list with custom compiler that is not stateless mdiluzio at feralinteractive dot com
                   ` (5 preceding siblings ...)
  2015-07-03 10:29 ` redi at gcc dot gnu.org
@ 2021-04-10  0:53 ` ahuszagh at gmail dot com
  2021-04-19 10:40 ` redi at gcc dot gnu.org
                   ` (9 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: ahuszagh at gmail dot com @ 2021-04-10  0:53 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66742

Alexander Huszagh <ahuszagh at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ahuszagh at gmail dot com

--- Comment #13 from Alexander Huszagh <ahuszagh at gmail dot com> ---
Any chance we can merge the proposed patch on this? This still triggers in
GCC-10.2.1, and the proposed patch works if applied to both `sort()` and
`sort(cmp)` implementations in `include/bits/list.tcc`.

Version Info:
gcc (GCC) 10.2.1 20201125 (Red Hat 10.2.1-9)

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

* [Bug libstdc++/66742] abort on sorting list with custom allocator that is not stateless
  2015-07-02 14:46 [Bug libstdc++/66742] New: abort on sorting list with custom compiler that is not stateless mdiluzio at feralinteractive dot com
                   ` (6 preceding siblings ...)
  2021-04-10  0:53 ` [Bug libstdc++/66742] abort on sorting list with custom allocator " ahuszagh at gmail dot com
@ 2021-04-19 10:40 ` redi at gcc dot gnu.org
  2021-04-27 11:37 ` jakub at gcc dot gnu.org
                   ` (8 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2021-04-19 10:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66742

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Assignee|redi at gcc dot gnu.org            |unassigned at gcc dot gnu.org
             Status|ASSIGNED                    |NEW

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

* [Bug libstdc++/66742] abort on sorting list with custom allocator that is not stateless
  2015-07-02 14:46 [Bug libstdc++/66742] New: abort on sorting list with custom compiler that is not stateless mdiluzio at feralinteractive dot com
                   ` (7 preceding siblings ...)
  2021-04-19 10:40 ` redi at gcc dot gnu.org
@ 2021-04-27 11:37 ` jakub at gcc dot gnu.org
  2021-05-25 20:52 ` redi at gcc dot gnu.org
                   ` (7 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: jakub at gcc dot gnu.org @ 2021-04-27 11:37 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66742

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.0                        |11.2

--- Comment #14 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 11.1 has been released, retargeting bugs to GCC 11.2.

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

* [Bug libstdc++/66742] abort on sorting list with custom allocator that is not stateless
  2015-07-02 14:46 [Bug libstdc++/66742] New: abort on sorting list with custom compiler that is not stateless mdiluzio at feralinteractive dot com
                   ` (8 preceding siblings ...)
  2021-04-27 11:37 ` jakub at gcc dot gnu.org
@ 2021-05-25 20:52 ` redi at gcc dot gnu.org
  2021-07-28  7:04 ` rguenth at gcc dot gnu.org
                   ` (6 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2021-05-25 20:52 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66742

--- Comment #15 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed downstream in my fork:
https://gitlab.com/jonathan-wakely/gcc/-/commit/18d78721bf3afaed243252a01a4f4909c17531b2

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

* [Bug libstdc++/66742] abort on sorting list with custom allocator that is not stateless
  2015-07-02 14:46 [Bug libstdc++/66742] New: abort on sorting list with custom compiler that is not stateless mdiluzio at feralinteractive dot com
                   ` (9 preceding siblings ...)
  2021-05-25 20:52 ` redi at gcc dot gnu.org
@ 2021-07-28  7:04 ` rguenth at gcc dot gnu.org
  2021-10-01 19:40 ` cvs-commit at gcc dot gnu.org
                   ` (5 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: rguenth at gcc dot gnu.org @ 2021-07-28  7:04 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66742

Richard Biener <rguenth at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|11.2                        |---

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

* [Bug libstdc++/66742] abort on sorting list with custom allocator that is not stateless
  2015-07-02 14:46 [Bug libstdc++/66742] New: abort on sorting list with custom compiler that is not stateless mdiluzio at feralinteractive dot com
                   ` (10 preceding siblings ...)
  2021-07-28  7:04 ` rguenth at gcc dot gnu.org
@ 2021-10-01 19:40 ` cvs-commit at gcc dot gnu.org
  2021-10-01 19:56 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-10-01 19:40 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66742

--- Comment #16 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:ff7793bea465019683b3a07d7ffceb6eae22def5

commit r12-4082-gff7793bea465019683b3a07d7ffceb6eae22def5
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue May 25 14:33:15 2021 +0100

    libstdc++: Allow stateful allocators in std::list::sort [PR 66742]

    The temporary lists used by std::list::sort are default constructed,
    which means they use default constructed allocators. The sort operation
    is defined in terms of merge and splice operations, which have undefined
    behaviour (and abort) if the allocators do not compare equal. This means
    it is not possible to sort a list that uses an allocator that compares
    unequal to an default constructed allocator.

    The solution is to avoid using temporary std::list objects at all. We do
    not need to be able to allocate memory because no nodes are allocated,
    only spliced from one list to another. That means the temporary lists
    don't need an allocator at all, so whether it would compare equal
    doesn't matter.

    Instead of temporary std::list objects, we can just use a collection of
    _List_node_base objects that nodes can be spliced onto as needed. Those
    objects are wrapped in a _Scratch_list type that implements the splicing
    and merging operations used by list::sort.

    We also don't need to update the list size during the sort, because
    sorting doesn't alter the number of nodes. Although we move nodes in and
    out of the scratch lists, at the end of the function all nodes are back
    in the original std::list and the scratch lists are empty.  So for the
    cxx11 ABI we can avoid the _M_size modifications usually done when
    splicing nodes.

    Signed-off-by: Jonathan Wakely <jwakely@redhat.com>

    libstdc++-v3/ChangeLog:

            PR libstdc++/66742
            * include/bits/list.tcc (list::sort()): Use _Scratch_list
            objects for splicing and merging.
            (list::sort(StrictWeakOrdering)): Likewise.
            * include/bits/stl_list.h (__detail::_Scratch_list): New type.
            * src/c++98/list.cc (_List_node_base::_M_transfer): Add
            assertion for --enable-libstdcxx-debug library.
            * testsuite/23_containers/list/operations/66742.cc: New test.

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

* [Bug libstdc++/66742] abort on sorting list with custom allocator that is not stateless
  2015-07-02 14:46 [Bug libstdc++/66742] New: abort on sorting list with custom compiler that is not stateless mdiluzio at feralinteractive dot com
                   ` (11 preceding siblings ...)
  2021-10-01 19:40 ` cvs-commit at gcc dot gnu.org
@ 2021-10-01 19:56 ` redi at gcc dot gnu.org
  2021-11-02 10:16 ` redi at gcc dot gnu.org
                   ` (3 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2021-10-01 19:56 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66742

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|---                         |12.0
         Resolution|---                         |FIXED
             Status|NEW                         |RESOLVED

--- Comment #17 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Fixed for GCC 12.

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

* [Bug libstdc++/66742] abort on sorting list with custom allocator that is not stateless
  2015-07-02 14:46 [Bug libstdc++/66742] New: abort on sorting list with custom compiler that is not stateless mdiluzio at feralinteractive dot com
                   ` (12 preceding siblings ...)
  2021-10-01 19:56 ` redi at gcc dot gnu.org
@ 2021-11-02 10:16 ` redi at gcc dot gnu.org
  2021-11-03 16:51 ` cvs-commit at gcc dot gnu.org
                   ` (2 subsequent siblings)
  16 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2021-11-02 10:16 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66742

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |---

--- Comment #18 from Jonathan Wakely <redi at gcc dot gnu.org> ---
My fix caused a regression for this (IMHO dumb) case:

#include <list>
struct X {
  bool operator<(X&) /* non-const */ { return false; }
};
struct Cmp {
  bool operator()(X&, X&) /* non-const */ { return false; }
};
int main() {
  std::list<X> l;
  l.sort();
  Cmp c;
  l.sort(c);
}

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

* [Bug libstdc++/66742] abort on sorting list with custom allocator that is not stateless
  2015-07-02 14:46 [Bug libstdc++/66742] New: abort on sorting list with custom compiler that is not stateless mdiluzio at feralinteractive dot com
                   ` (13 preceding siblings ...)
  2021-11-02 10:16 ` redi at gcc dot gnu.org
@ 2021-11-03 16:51 ` cvs-commit at gcc dot gnu.org
  2022-05-06  8:29 ` jakub at gcc dot gnu.org
  2022-05-06 12:30 ` redi at gcc dot gnu.org
  16 siblings, 0 replies; 18+ messages in thread
From: cvs-commit at gcc dot gnu.org @ 2021-11-03 16:51 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66742

--- Comment #19 from CVS Commits <cvs-commit at gcc dot gnu.org> ---
The master branch has been updated by Jonathan Wakely <redi@gcc.gnu.org>:

https://gcc.gnu.org/g:1e7a269856fd67aff78ac874bec96d31a54b2fd9

commit r12-4873-g1e7a269856fd67aff78ac874bec96d31a54b2fd9
Author: Jonathan Wakely <jwakely@redhat.com>
Date:   Tue Nov 2 10:21:01 2021 +0000

    libstdc++: Fix regression in std::list::sort [PR66742]

    The standard does not require const-correct comparisons in list::sort.

    libstdc++-v3/ChangeLog:

            PR libstdc++/66742
            * include/bits/list.tcc (list::sort): Use mutable iterators for
            comparisons.
            * include/bits/stl_list.h (_Scratch_list::_Ptr_cmp): Likewise.
            * testsuite/23_containers/list/operations/66742.cc: Check
            non-const comparisons.

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

* [Bug libstdc++/66742] abort on sorting list with custom allocator that is not stateless
  2015-07-02 14:46 [Bug libstdc++/66742] New: abort on sorting list with custom compiler that is not stateless mdiluzio at feralinteractive dot com
                   ` (14 preceding siblings ...)
  2021-11-03 16:51 ` cvs-commit at gcc dot gnu.org
@ 2022-05-06  8:29 ` jakub at gcc dot gnu.org
  2022-05-06 12:30 ` redi at gcc dot gnu.org
  16 siblings, 0 replies; 18+ messages in thread
From: jakub at gcc dot gnu.org @ 2022-05-06  8:29 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66742

Jakub Jelinek <jakub at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
   Target Milestone|12.0                        |12.2

--- Comment #20 from Jakub Jelinek <jakub at gcc dot gnu.org> ---
GCC 12.1 is being released, retargeting bugs to GCC 12.2.

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

* [Bug libstdc++/66742] abort on sorting list with custom allocator that is not stateless
  2015-07-02 14:46 [Bug libstdc++/66742] New: abort on sorting list with custom compiler that is not stateless mdiluzio at feralinteractive dot com
                   ` (15 preceding siblings ...)
  2022-05-06  8:29 ` jakub at gcc dot gnu.org
@ 2022-05-06 12:30 ` redi at gcc dot gnu.org
  16 siblings, 0 replies; 18+ messages in thread
From: redi at gcc dot gnu.org @ 2022-05-06 12:30 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=66742

Jonathan Wakely <redi at gcc dot gnu.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|---                         |FIXED
   Target Milestone|12.2                        |12.0

--- Comment #21 from Jonathan Wakely <redi at gcc dot gnu.org> ---
This was fixed for 12.1

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

end of thread, other threads:[~2022-05-06 12:30 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2015-07-02 14:46 [Bug libstdc++/66742] New: abort on sorting list with custom compiler that is not stateless mdiluzio at feralinteractive dot com
2015-07-02 19:40 ` [Bug libstdc++/66742] " daniel.kruegler at googlemail dot com
2015-07-02 20:47 ` redi at gcc dot gnu.org
2015-07-03  8:14 ` mdiluzio at feralinteractive dot com
2015-07-03  8:20 ` mdiluzio at feralinteractive dot com
2015-07-03 10:20 ` redi at gcc dot gnu.org
2015-07-03 10:29 ` redi at gcc dot gnu.org
2021-04-10  0:53 ` [Bug libstdc++/66742] abort on sorting list with custom allocator " ahuszagh at gmail dot com
2021-04-19 10:40 ` redi at gcc dot gnu.org
2021-04-27 11:37 ` jakub at gcc dot gnu.org
2021-05-25 20:52 ` redi at gcc dot gnu.org
2021-07-28  7:04 ` rguenth at gcc dot gnu.org
2021-10-01 19:40 ` cvs-commit at gcc dot gnu.org
2021-10-01 19:56 ` redi at gcc dot gnu.org
2021-11-02 10:16 ` redi at gcc dot gnu.org
2021-11-03 16:51 ` cvs-commit at gcc dot gnu.org
2022-05-06  8:29 ` jakub at gcc dot gnu.org
2022-05-06 12:30 ` redi at gcc dot gnu.org

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).