public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/58562] New: std::sort fails with -D_GLIBCXX_DEBUG enabled, whose bug?
@ 2013-09-28 17:41 jpritikin at pobox dot com
  2013-09-28 18:35 ` [Bug libstdc++/58562] " paolo.carlini at oracle dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: jpritikin at pobox dot com @ 2013-09-28 17:41 UTC (permalink / raw)
  To: gcc-bugs

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

            Bug ID: 58562
           Summary: std::sort fails with -D_GLIBCXX_DEBUG enabled, whose
                    bug?
           Product: gcc
           Version: 4.7.3
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
          Assignee: unassigned at gcc dot gnu.org
          Reporter: jpritikin at pobox dot com
              Host: x86_64-linux-gnu
            Target: x86_64-linux-gnu
             Build: x86_64-linux-gnu

Objects involved in the operation:
iterator "__first" @ 0x0x7fffffffa370 {
type =
N11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIP20matrixVectorProdTermNSt9__cxx19986vectorIS3_SaIS3_EEEEENSt7__debug6vectorIS3_S7_EEEE
(mutable iterator);
  state = dereferenceable (start-of-sequence);
  references sequence with type
`NSt7__debug6vectorI20matrixVectorProdTermSaIS1_EEE' @ 0x0x7fffffffa370
}
iterator "__last" @ 0x0x7fffffffa3a0 {
type =
N11__gnu_debug14_Safe_iteratorIN9__gnu_cxx17__normal_iteratorIP20matrixVectorProdTermNSt9__cxx19986vectorIS3_SaIS3_EEEEENSt7__debug6vectorIS3_S7_EEEE
(mutable iterator);
  state = dereferenceable;
  references sequence with type
`NSt7__debug6vectorI20matrixVectorProdTermSaIS1_EEE' @ 0x0x7fffffffa3a0
}

Program received signal SIGABRT, Aborted.
0x00007ffff732a037 in __GI_raise (sig=sig@entry=6)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
56    ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) where
#0  0x00007ffff732a037 in __GI_raise (sig=sig@entry=6)
    at ../nptl/sysdeps/unix/sysv/linux/raise.c:56
#1  0x00007ffff732d698 in __GI_abort () at abort.c:90
#2  0x00007ffff1cbf5cd in __gnu_debug::_Error_formatter::_M_error() const ()
   from /usr/lib/x86_64-linux-gnu/libstdc++.so.6
#3  0x00007ffff1f7addd in
std::sort_heap<__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<matrixVectorProdTerm*,
std::__cxx1998::vector<matrixVectorProdTerm,
std::allocator<matrixVectorProdTerm> > >,
std::__debug::vector<matrixVectorProdTerm, std::allocator<matrixVectorProdTerm>
> > > (__first=..., __last=...)
    at /usr/include/c++/4.7/bits/stl_heap.h:468
#4  0x00007ffff1f7936f in
std::partial_sort<__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<matrixVectorProdTerm*,
std::__cxx1998::vector<matrixVectorProdTerm,
std::allocator<matrixVectorProdTerm> > >,
std::__debug::vector<matrixVectorProdTerm, std::allocator<matrixVectorProdTerm>
> > > (__first=..., 
    __middle=..., __last=...) at /usr/include/c++/4.7/bits/stl_algo.h:5325
#5  0x00007ffff1f77a74 in
std::__introsort_loop<__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<matrixVectorProdTerm*,
std::__cxx1998::vector<matrixVectorProdTerm,
std::allocator<matrixVectorProdTerm> > >,
std::__debug::vector<matrixVectorProdTerm, std::allocator<matrixVectorProdTerm>
> >, long> (
    __first=..., __last=..., __depth_limit=0)
    at /usr/include/c++/4.7/bits/stl_algo.h:2335
#6  0x00007ffff1f76772 in
std::sort<__gnu_debug::_Safe_iterator<__gnu_cxx::__normal_iterator<matrixVectorProdTerm*,
std::__cxx1998::vector<matrixVectorProdTerm,
std::allocator<matrixVectorProdTerm> > >,
std::__debug::vector<matrixVectorProdTerm, std::allocator<matrixVectorProdTerm>
> > > (__first=..., __last=...)
    at /usr/include/c++/4.7/bits/stl_algo.h:5476
#7  0x00007ffff1fb9194 in buildItemParamMap (oo=0x20a72d0, fc=0x1dd8240)
    at omxFitFunctionBA81.cpp:211

The code at omxFitFunctionBA81.cpp:211 is:

    std::sort(state->hgProd.begin(), state->hgProd.end());

If I turn off -D_GLIBCXX_DEBUG then the code works fine.


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

* [Bug libstdc++/58562] std::sort fails with -D_GLIBCXX_DEBUG enabled, whose bug?
  2013-09-28 17:41 [Bug libstdc++/58562] New: std::sort fails with -D_GLIBCXX_DEBUG enabled, whose bug? jpritikin at pobox dot com
@ 2013-09-28 18:35 ` paolo.carlini at oracle dot com
  2013-09-28 23:55 ` redi at gcc dot gnu.org
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: paolo.carlini at oracle dot com @ 2013-09-28 18:35 UTC (permalink / raw)
  To: gcc-bugs

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

Paolo Carlini <paolo.carlini at oracle dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|UNCONFIRMED                 |WAITING
   Last reconfirmed|                            |2013-09-28
     Ever confirmed|0                           |1

--- Comment #1 from Paolo Carlini <paolo.carlini at oracle dot com> ---
For sure we need a (minimized, please) self-contained testcase to tell.


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

* [Bug libstdc++/58562] std::sort fails with -D_GLIBCXX_DEBUG enabled, whose bug?
  2013-09-28 17:41 [Bug libstdc++/58562] New: std::sort fails with -D_GLIBCXX_DEBUG enabled, whose bug? jpritikin at pobox dot com
  2013-09-28 18:35 ` [Bug libstdc++/58562] " paolo.carlini at oracle dot com
@ 2013-09-28 23:55 ` redi at gcc dot gnu.org
  2013-09-29  1:16 ` jpritikin at pobox dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2013-09-28 23:55 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> ---
> If I turn off -D_GLIBCXX_DEBUG then the code works fine.

That usually means "your code is buggy"

That's the point of debug mode, it will abort instead of silently ignoring your
buggy code.

Please provide testcase code to reproduce the problem if you think the bug is
in GCC not your code.


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

* [Bug libstdc++/58562] std::sort fails with -D_GLIBCXX_DEBUG enabled, whose bug?
  2013-09-28 17:41 [Bug libstdc++/58562] New: std::sort fails with -D_GLIBCXX_DEBUG enabled, whose bug? jpritikin at pobox dot com
  2013-09-28 18:35 ` [Bug libstdc++/58562] " paolo.carlini at oracle dot com
  2013-09-28 23:55 ` redi at gcc dot gnu.org
@ 2013-09-29  1:16 ` jpritikin at pobox dot com
  2013-09-29  1:18 ` jpritikin at pobox dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: jpritikin at pobox dot com @ 2013-09-29  1:16 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #3 from Joshua N Pritikin <jpritikin at pobox dot com> ---
Created attachment 30925
  --> http://gcc.gnu.org/bugzilla/attachment.cgi?id=30925&action=edit
C++ source code to reproduce problem

With -D_GLIBCXX_DEBUG, fails with:

/usr/include/c++/4.7/bits/stl_heap.h:468:error: elements in iterator range [
    __first, __last) do not form a heap.


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

* [Bug libstdc++/58562] std::sort fails with -D_GLIBCXX_DEBUG enabled, whose bug?
  2013-09-28 17:41 [Bug libstdc++/58562] New: std::sort fails with -D_GLIBCXX_DEBUG enabled, whose bug? jpritikin at pobox dot com
                   ` (2 preceding siblings ...)
  2013-09-29  1:16 ` jpritikin at pobox dot com
@ 2013-09-29  1:18 ` jpritikin at pobox dot com
  2013-09-29 14:59 ` redi at gcc dot gnu.org
  2013-09-29 15:08 ` jpritikin at pobox dot com
  5 siblings, 0 replies; 7+ messages in thread
From: jpritikin at pobox dot com @ 2013-09-29  1:18 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #4 from Joshua N Pritikin <jpritikin at pobox dot com> ---
(In reply to Jonathan Wakely from comment #2)
> That usually means "your code is buggy"
> 
> That's the point of debug mode, it will abort instead of silently ignoring
> your buggy code.

Rockstar programmers assume that the bug is in the compiler/stdlib/kernel/etc.
The bug is never in code that I wrote. ;-)


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

* [Bug libstdc++/58562] std::sort fails with -D_GLIBCXX_DEBUG enabled, whose bug?
  2013-09-28 17:41 [Bug libstdc++/58562] New: std::sort fails with -D_GLIBCXX_DEBUG enabled, whose bug? jpritikin at pobox dot com
                   ` (3 preceding siblings ...)
  2013-09-29  1:18 ` jpritikin at pobox dot com
@ 2013-09-29 14:59 ` redi at gcc dot gnu.org
  2013-09-29 15:08 ` jpritikin at pobox dot com
  5 siblings, 0 replies; 7+ messages in thread
From: redi at gcc dot gnu.org @ 2013-09-29 14:59 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #6 from Jonathan Wakely <redi at gcc dot gnu.org> ---
Specifically it fails this requirement:

matrixVectorProdTerm a(1, 0, 0);
matrixVectorProdTerm b(0, 1, 0);

assert( !(a<b && b<a) );

i.e. with your definition of ordering two objects can both be less than each
other, which makes the ordering unsuitable for std::sort (or pretty much
anything else in the standard library that cares about sorting.)


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

* [Bug libstdc++/58562] std::sort fails with -D_GLIBCXX_DEBUG enabled, whose bug?
  2013-09-28 17:41 [Bug libstdc++/58562] New: std::sort fails with -D_GLIBCXX_DEBUG enabled, whose bug? jpritikin at pobox dot com
                   ` (4 preceding siblings ...)
  2013-09-29 14:59 ` redi at gcc dot gnu.org
@ 2013-09-29 15:08 ` jpritikin at pobox dot com
  5 siblings, 0 replies; 7+ messages in thread
From: jpritikin at pobox dot com @ 2013-09-29 15:08 UTC (permalink / raw)
  To: gcc-bugs

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

--- Comment #7 from Joshua N Pritikin <jpritikin at pobox dot com> ---
Ah, I see. Thanks for pointing out my stupidity. :-)


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

end of thread, other threads:[~2013-09-29 15:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-09-28 17:41 [Bug libstdc++/58562] New: std::sort fails with -D_GLIBCXX_DEBUG enabled, whose bug? jpritikin at pobox dot com
2013-09-28 18:35 ` [Bug libstdc++/58562] " paolo.carlini at oracle dot com
2013-09-28 23:55 ` redi at gcc dot gnu.org
2013-09-29  1:16 ` jpritikin at pobox dot com
2013-09-29  1:18 ` jpritikin at pobox dot com
2013-09-29 14:59 ` redi at gcc dot gnu.org
2013-09-29 15:08 ` jpritikin at pobox dot com

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