public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libstdc++/34095]  New: parallel mode: segfault in std::sort
@ 2007-11-14 20:23 bangerth at dealii dot org
  2007-12-11 19:15 ` [Bug libstdc++/34095] " bkoz at gcc dot gnu dot org
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: bangerth at dealii dot org @ 2007-11-14 20:23 UTC (permalink / raw)
  To: gcc-bugs

I tried to figure out what is going on here, but it's getting
to complicated in the libstdc++ innards for me to spot the problem.
In any case, this little program
-------------------
#include <vector>
#include <algorithm>

struct S
{
    unsigned int line;
    std::vector<double> entries;

    bool operator < (const S &a) const
      {
        return line < a.line;
      }      
};


int main () 
{
  std::vector<S> lines(20000);  
  std::sort (lines.begin(), lines.end());
}
------------------------
produces a segfault for me when compiled with parallel mode.

A backtrace is here:
(gdb) bt
#0  0x0805cf59 in ~vector (this=0xb6439ffc)
    at
/tmp/bangerth/bin/gcc-mainline/lib/gcc/i686-pc-linux-gnu/4.3.0/../../../../include/c++/4.3.0/bits/stl_vector.h:304
#1  0x0805cf9d in ~S (this=0xb6439ff8) at step-14.cc:5
#2  0x0806d1b9 in
__gnu_parallel::parallel_sort_mwms_pu<__gnu_cxx::__normal_iterator<S*,
std::__cxx1998::vector<S, std::allocator<S> > >, std::less<S> > (
    d=0x807722c, comp=@0xbfffd498)
    at
/tmp/bangerth/bin/gcc-mainline/lib/gcc/i686-pc-linux-gnu/4.3.0/../../../../include/c++/4.3.0/parallel/multiway_mergesort.h:312
#3  0x08057c73 in
__gnu_parallel::parallel_sort_mwms<__gnu_cxx::__normal_iterator<S*,
std::__cxx1998::vector<S, std::allocator<S> > >, std::less<S> > (
    .omp_data_i=0xbfffd450)
    at
/tmp/bangerth/bin/gcc-mainline/lib/gcc/i686-pc-linux-gnu/4.3.0/../../../../include/c++/4.3.0/parallel/multiway_mergesort.h:391
#4  0xb6dd03e0 in gomp_thread_start (xdata=0xbfffd330)
    at ../../../svn/libgomp/team.c:108
#5  0xb6db2aa7 in start_thread () from /lib/tls/libpthread.so.0

This is in the worker thread, not the main thread from which it was spawned.

Hope this helps, cheers
 W.


-- 
           Summary: parallel mode: segfault in std::sort
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libstdc++
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bangerth at dealii dot org


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


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

* [Bug libstdc++/34095] parallel mode: segfault in std::sort
  2007-11-14 20:23 [Bug libstdc++/34095] New: parallel mode: segfault in std::sort bangerth at dealii dot org
@ 2007-12-11 19:15 ` bkoz at gcc dot gnu dot org
  2007-12-11 20:55 ` bangerth at dealii dot org
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bkoz at gcc dot gnu dot org @ 2007-12-11 19:15 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #1 from bkoz at gcc dot gnu dot org  2007-12-11 19:15 -------

Hey Wolfgang, I cannot reproduce this:

g++ -g -O2 -march=native -fopenmp -D_GLIBCXX_PARALLEL 34059.cc

Seems to run fine for me. I'm using 


g++ (GCC) 4.3.0 20071209 (experimental)

-benjamin


-- 


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


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

* [Bug libstdc++/34095] parallel mode: segfault in std::sort
  2007-11-14 20:23 [Bug libstdc++/34095] New: parallel mode: segfault in std::sort bangerth at dealii dot org
  2007-12-11 19:15 ` [Bug libstdc++/34095] " bkoz at gcc dot gnu dot org
@ 2007-12-11 20:55 ` bangerth at dealii dot org
  2007-12-12 22:44 ` bangerth at dealii dot org
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bangerth at dealii dot org @ 2007-12-11 20:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #2 from bangerth at dealii dot org  2007-12-11 20:55 -------
(In reply to comment #1)
> Hey Wolfgang, I cannot reproduce this:
> 
> g++ -g -O2 -march=native -fopenmp -D_GLIBCXX_PARALLEL 34059.cc
> 
> Seems to run fine for me. I'm using 
> 
> 
> g++ (GCC) 4.3.0 20071209 (experimental)

The machine I used to use for mainline went down and with it gcc repo along
with all the tools (mpfr, etc) necessary for it. It'll take me a few hours
to reproduce this, which I'm not sure I will be able before leaving for 
Europe next weekend.

Let's just close it if you can't reproduce now. I'll just try to run everything
again some time from now and if I have the same problem again I'll re-open.

Best
 W.


-- 

bangerth at dealii dot org changed:

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


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


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

* [Bug libstdc++/34095] parallel mode: segfault in std::sort
  2007-11-14 20:23 [Bug libstdc++/34095] New: parallel mode: segfault in std::sort bangerth at dealii dot org
  2007-12-11 19:15 ` [Bug libstdc++/34095] " bkoz at gcc dot gnu dot org
  2007-12-11 20:55 ` bangerth at dealii dot org
@ 2007-12-12 22:44 ` bangerth at dealii dot org
  2007-12-13 22:55 ` bangerth at dealii dot org
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bangerth at dealii dot org @ 2007-12-12 22:44 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #3 from bangerth at dealii dot org  2007-12-12 22:44 -------
(In reply to comment #2)
> Let's just close it if you can't reproduce now. I'll just try to run everything
> again some time from now and if I have the same problem again I'll re-open.

Hm, so I got around to check this out again and in fact the same happens
with today's svn version:

examples/step-14> c++ -v
Using built-in specs.
Target: i686-pc-linux-gnu
Configured with: ../gcc/configure --prefix=/tmp/bangerth/bin/gcc-mainline
--with-mpfr=/tmp/bangerth/bin --with-gmp=/tmp/bangerth/bin --disable-multilib
--enable-languages=c,c++
Thread model: posix
gcc version 4.3.0 20071212 (experimental) (GCC) 

examples/step-14> c++ -D_GLIBCXX_PARALLEL -fopenmp -march=native -mtune=native
a.cc -g -O2

examples/step-14> ./a.out 
Segmentation fault

examples/step-14> uname -a
Linux bloc640b 2.6.22.9-0.4-default #1 SMP 2007/10/05 21:32:04 UTC i686 i686
i386 GNU/Linux

This is with the program posted before, with pretty much the same backtrace. 
Johannes, does the program work for you?

Best
 Wolfgang


-- 

bangerth at dealii dot org changed:

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


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


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

* [Bug libstdc++/34095] parallel mode: segfault in std::sort
  2007-11-14 20:23 [Bug libstdc++/34095] New: parallel mode: segfault in std::sort bangerth at dealii dot org
                   ` (2 preceding siblings ...)
  2007-12-12 22:44 ` bangerth at dealii dot org
@ 2007-12-13 22:55 ` bangerth at dealii dot org
  2008-01-01 16:46 ` pcarlini at suse dot de
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: bangerth at dealii dot org @ 2007-12-13 22:55 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #4 from bangerth at dealii dot org  2007-12-13 22:54 -------
By the way, the size of the vector affects whether the testcase fails or
not. Apparently the algorithms decide that if the vector is too small
then it's not worth subdividing the work. On my 2-processor machine, 20,000
is enough to trigger the error, but for example 100 is not. YMMV.

W.


-- 


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


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

* [Bug libstdc++/34095] parallel mode: segfault in std::sort
  2007-11-14 20:23 [Bug libstdc++/34095] New: parallel mode: segfault in std::sort bangerth at dealii dot org
                   ` (3 preceding siblings ...)
  2007-12-13 22:55 ` bangerth at dealii dot org
@ 2008-01-01 16:46 ` pcarlini at suse dot de
  2008-01-01 18:10 ` pcarlini at suse dot de
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: pcarlini at suse dot de @ 2008-01-01 16:46 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #5 from pcarlini at suse dot de  2008-01-01 16:46 -------
*** Bug 34636 has been marked as a duplicate of this bug. ***


-- 

pcarlini at suse dot de changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |chris at bubblescope dot net


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


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

* [Bug libstdc++/34095] parallel mode: segfault in std::sort
  2007-11-14 20:23 [Bug libstdc++/34095] New: parallel mode: segfault in std::sort bangerth at dealii dot org
                   ` (4 preceding siblings ...)
  2008-01-01 16:46 ` pcarlini at suse dot de
@ 2008-01-01 18:10 ` pcarlini at suse dot de
  2008-01-01 19:07 ` paolo at gcc dot gnu dot org
  2008-01-01 19:08 ` pcarlini at suse dot de
  7 siblings, 0 replies; 9+ messages in thread
From: pcarlini at suse dot de @ 2008-01-01 18:10 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #6 from pcarlini at suse dot de  2008-01-01 18:10 -------
Seems just a trivial thing: a delete[] in place of ::operator delete


-- 

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-01-01 18:10:14
               date|                            |


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


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

* [Bug libstdc++/34095] parallel mode: segfault in std::sort
  2007-11-14 20:23 [Bug libstdc++/34095] New: parallel mode: segfault in std::sort bangerth at dealii dot org
                   ` (5 preceding siblings ...)
  2008-01-01 18:10 ` pcarlini at suse dot de
@ 2008-01-01 19:07 ` paolo at gcc dot gnu dot org
  2008-01-01 19:08 ` pcarlini at suse dot de
  7 siblings, 0 replies; 9+ messages in thread
From: paolo at gcc dot gnu dot org @ 2008-01-01 19:07 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #7 from paolo at gcc dot gnu dot org  2008-01-01 19:06 -------
Subject: Bug 34095

Author: paolo
Date: Tue Jan  1 19:05:41 2008
New Revision: 131247

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

        PR libstdc++/34095
        * include/parallel/multiway_merge.h (multiway_merge_bubble,
        parallel_multiway_merge): Together with ::operator new use
        ::operator delete.
        * include/parallel/losertree.h (LoserTree<>::~LoserTree): Likewise.
        * include/parallel/quicksort.h (parallel_sort_qs_divide): Likewise.
        * include/parallel/random_shuffle.h (parallel_random_shuffle_drs_pu,
        sequential_random_shuffle): Likewise.
        * include/parallel/tree.h (_M_not_sorted_bulk_insertion_construction):
        Likewise.
        * include/parallel/multiway_mergesort.h (parallel_sort_mwms_pu,
        parallel_sort_mwms): Likewise.
        * include/parallel/partial_sum.h (parallel_partial_sum_linear):
        Likewise. 
        * testsuite/25_algorithms/sort/34095.cc: New.

Added:
    trunk/libstdc++-v3/testsuite/25_algorithms/sort/34095.cc
Modified:
    trunk/libstdc++-v3/ChangeLog
    trunk/libstdc++-v3/include/parallel/losertree.h
    trunk/libstdc++-v3/include/parallel/multiway_merge.h
    trunk/libstdc++-v3/include/parallel/multiway_mergesort.h
    trunk/libstdc++-v3/include/parallel/partial_sum.h
    trunk/libstdc++-v3/include/parallel/quicksort.h
    trunk/libstdc++-v3/include/parallel/random_shuffle.h
    trunk/libstdc++-v3/include/parallel/tree.h


-- 


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


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

* [Bug libstdc++/34095] parallel mode: segfault in std::sort
  2007-11-14 20:23 [Bug libstdc++/34095] New: parallel mode: segfault in std::sort bangerth at dealii dot org
                   ` (6 preceding siblings ...)
  2008-01-01 19:07 ` paolo at gcc dot gnu dot org
@ 2008-01-01 19:08 ` pcarlini at suse dot de
  7 siblings, 0 replies; 9+ messages in thread
From: pcarlini at suse dot de @ 2008-01-01 19:08 UTC (permalink / raw)
  To: gcc-bugs



------- Comment #8 from pcarlini at suse dot de  2008-01-01 19:08 -------
Fixed.


-- 

pcarlini at suse dot de changed:

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


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


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

end of thread, other threads:[~2008-01-01 19:08 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-11-14 20:23 [Bug libstdc++/34095] New: parallel mode: segfault in std::sort bangerth at dealii dot org
2007-12-11 19:15 ` [Bug libstdc++/34095] " bkoz at gcc dot gnu dot org
2007-12-11 20:55 ` bangerth at dealii dot org
2007-12-12 22:44 ` bangerth at dealii dot org
2007-12-13 22:55 ` bangerth at dealii dot org
2008-01-01 16:46 ` pcarlini at suse dot de
2008-01-01 18:10 ` pcarlini at suse dot de
2008-01-01 19:07 ` paolo at gcc dot gnu dot org
2008-01-01 19:08 ` 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).