Arguments for omp_set_num_threads/OMP_NUM_THREADS are used without checking for
validity, i.e. 

$> cat omp_set_num_threads.f90
PROGRAM main
  USE OMP_LIB
  CALL omp_set_num_threads(-3)
  !$OMP PARALLEL
WRITE(*,*) "thread:", omp_get_thread_num()
  !$OMP END PARALLEL
END PROGRAM

$> gfortran-4.3 -g -Wall -fbounds-check omp_set_num_threads.f90
$> ./a.out
          -3

libgomp: Out of memory allocating 4294967288 bytes
Segmentation Fault

The specifications v2.5, section 3.2.1, state:
"If the number of threads requested exceeds the number the implementation can
support, or is not a positive integer, the behavior of this routine is
implementation defined."

Although crashing is a form of "implementation", it is not very user friendly.


-- 
           Summary: implement argument checking for user accessable runtime
                    routines
           Product: gcc
           Version: 4.3.0
            Status: UNCONFIRMED
          Severity: enhancement
          Priority: P3
         Component: libgomp
        AssignedTo: unassigned at gcc dot gnu dot org
        ReportedBy: franke dot daniel at gmail dot com
  GCC host triplet: i686-pc-linux-gnu


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

Reply via email to