public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "bruno at clisp dot org" <gcc-bugzilla@gcc.gnu.org>
To: gcc-bugs@gcc.gnu.org
Subject: [Bug libgomp/28468]  New: OpenMP-parallelized program crashes when OMP_NUM_THREADS > 1
Date: Mon, 24 Jul 2006 14:19:00 -0000	[thread overview]
Message-ID: <bug-28468-128@http.gcc.gnu.org/bugzilla/> (raw)

Versions:
* gcc: gcc (GCC) 4.2.0 20060715 (experimental)
* cpu: AMD-K7 (i686)
* kernel: Linux 2.4.21-99 (SuSE 9.0)
* glibc: glibc-2.3.6 built with LinuxThreads, _not_ NPTL

Test program:
============================== omp-test1.c =======================
#include <stdlib.h>
#include <stdio.h>

/* A computational task whose duration depends on x.  */
int job (int x)
{
  int j = rand() % (100 + 10 * x);
  int i;

  for (i = j - 1; i > 0; i--)
    if (j % i == 0)
      break;

  return i;
}

int main (int argc, char *argv[])
{
  int n = 10000;

  int *mem = malloc (n * sizeof (int));
  int i;

  /* Because the tasks don't have all the same duration, a dynamic
     schedule is best.  */
  #pragma omp parallel for schedule(dynamic)
  for (i = 0; i < n; i++)
    mem[i] = job (i);

  for (i = 0; i < n; i++)
    printf ("mem[%d] = %d\n", i, mem[i]);

  return 0;
}
=====================================================================

$ gcc -fopenmp -Wall -O omp-test1.c

The single-threaded program runs fine:
$ unset OMP_NUM_THREADS; ./a.out
or
$ export OMP_NUM_THREADS=1; ./a.out

But with more than one thread it crashes:

$ export OMP_NUM_THREADS=2; ./a.out
Segmentation fault (core dumped)
$ gdb a.out core.26661
GNU gdb 6.4
Copyright 2005 Free Software Foundation, Inc.
GDB is free software, covered by the GNU General Public License, and you are
welcome to change it and/or distribute copies of it under certain conditions.
Type "show copying" to see the conditions.
There is absolutely no warranty for GDB.  Type "show warranty" for details.
This GDB was configured as "i686-pc-linux-gnu"...Using host libthread_db
library "/lib/libthread_db.so.1".

Core was generated by `./a.out'.
Program terminated with signal 11, Segmentation fault.
Reading symbols from
/gfs/ibook/Volumes/ExtData/bin.x86-linux/gnu-inst-gcc/4.2-20060715/lib/gcc/i686-pc-linux-gnu/4.2.0/libgomp.so.1...done.
Loaded symbols for
/packages/gnu-inst-gcc/4.2-20060715/lib/gcc/i686-pc-linux-gnu/4.2.0/libgomp.so.1
Reading symbols from /lib/libpthread.so.0...done.
Loaded symbols for /lib/libpthread.so.0
Reading symbols from /lib/libc.so.6...done.
Loaded symbols for /lib/libc.so.6
Reading symbols from /lib/librt.so.1...done.
Loaded symbols for /lib/librt.so.1
Reading symbols from /lib/ld-linux.so.2...done.
Loaded symbols for /lib/ld-linux.so.2
#0  gomp_iter_dynamic_next (pstart=0xbfffe9c4, pend=0xbfffe9c8)
    at ../../../gcc-4.2-20060715/libgomp/iter.c:189
189       start = ws->next;
(gdb) where
#0  gomp_iter_dynamic_next (pstart=0xbfffe9c4, pend=0xbfffe9c8)
    at ../../../gcc-4.2-20060715/libgomp/iter.c:189
#1  0x4001c8e8 in gomp_loop_dynamic_next (istart=0xbfffe9c4, iend=0xbfffe9c8)
    at ../../../gcc-4.2-20060715/libgomp/loop.c:248
#2  0x080486ed in main.omp_fn.0 ()
#3  0x0804861e in main ()
(gdb) print ws
$1 = (struct gomp_work_share *) 0x0


-- 
           Summary: OpenMP-parallelized program crashes when OMP_NUM_THREADS
                    > 1
           Product: gcc
           Version: 4.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: libgomp
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: bruno at clisp dot org
 GCC build triplet: i686-suse-linux-gnu
  GCC host triplet: i686-suse-linux-gnu
GCC target triplet: i686-suse-linux-gnu


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


             reply	other threads:[~2006-07-24 14:19 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-24 14:19 bruno at clisp dot org [this message]
2006-11-07 14:36 ` [Bug libgomp/28468] " bruno at clisp dot org
2006-11-15  9:45 ` jakub at gcc dot gnu dot org
2006-11-15 13:39 ` bruno at clisp dot org
2007-02-07 13:35 ` jakub at gcc dot gnu dot org
2007-02-07 13:39 ` jakub at gcc dot gnu dot org
2007-10-23 15:41 ` rth at gcc dot gnu dot org
2008-03-10 16:10 ` jakub at gcc dot gnu dot org

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-28468-128@http.gcc.gnu.org/bugzilla/ \
    --to=gcc-bugzilla@gcc.gnu.org \
    --cc=gcc-bugs@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).