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 via email to