Bug 33581 - OpenMP segmentation fault
Summary: OpenMP segmentation fault
Status: RESOLVED INVALID
Alias: None
Product: gcc
Classification: Unclassified
Component: middle-end (show other bugs)
Version: 4.2.1
: P3 normal
Target Milestone: ---
Assignee: Not yet assigned to anyone
URL:
Keywords: openmp
Depends on:
Blocks:
 
Reported: 2007-09-28 08:15 UTC by Steven Pollmann
Modified: 2007-10-26 06:49 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Steven Pollmann 2007-09-28 08:15:22 UTC
The following code (a general case) generates a segmentation fault when compiled with the -m32 and -fopenmp switch in gcc 4.2.1.  With the -m32 switch removed, the program executes correctly.

#include <iostream>

int main()
{
  int x;

#pragma omp parallel for
  for (x = 0; x < 100; x++)
    {
      std::cout << x << std::endl;
    }
  return 0;
}

compile command line: /usr/local/gcc-4.2.1/bin/g++ --static -fopenmp -m32 -o openMPTestProgram openMPTest.cpp

System:  SUSE 10 x64 linux distribution, 
(Dual-core Intel(R) Pentium(R) D CPU 2.80GHz system), 4GB ram

GCC configuration option: ../gcc-4.2.1/configure --prefix=/usr/local/gcc-4.2.1
Comment 1 Steven Pollmann 2007-09-28 08:22:31 UTC
to clarify; the resultant executable of the test case above generates the segmentation fault, not the compiler during compilation.
Comment 2 Andrew Pinski 2007-09-28 09:36:18 UTC
-static is not really supported for glibc and pthreads/openmp.
Comment 3 Andrew Pinski 2007-09-28 09:36:43 UTC
What happens if you don't use -static?
Comment 4 Steven Pollmann 2007-09-29 07:04:41 UTC
(In reply to comment #3)
> What happens if you don't use -static?

if static is not used (and the LD_LIBRARY_PATH points to the correct location ;)
the program seems to execute correctly.
Comment 5 Steven Pollmann 2007-09-29 07:10:23 UTC
(In reply to comment #4)
> (In reply to comment #3)
> > What happens if you don't use -static?
> if static is not used (and the LD_LIBRARY_PATH points to the correct location
> ;)
> the program seems to execute correctly.

I didn't think that -static was causing the problem since the application seems to execute correctly with the -m32 option removed, and with the -static remaining.

Comment 6 Andrew Pinski 2007-09-29 08:50:02 UTC
(In reply to comment #5)
> I didn't think that -static was causing the problem since the application seems
> to execute correctly with the -m32 option removed, and with the -static
> remaining.

glibc is slightly different between the 32bit version and the 64bit version.
Comment 7 Jakub Jelinek 2007-10-26 06:49:33 UTC
Using -static for threaded programs is highly discouraged in glibc, for many reasons.  If you want to do it anyway for whatever weird reason, you usually need
to use -Wl,--whole-archive -lnptl -Wl,--no-whole-archive.