Bug 84589

Summary: gcc3 -pthread does not define -D_REENTRANT
Product: Red Hat Enterprise Linux 2.1 Reporter: Francois-Xavier 'FiX' KOWALSKI <francois-xavier.kowalski>
Component: gcc3Assignee: Jakub Jelinek <jakub>
Status: CLOSED UPSTREAM QA Contact:
Severity: medium Docs Contact:
Priority: medium    
Version: 2.1   
Target Milestone: ---   
Target Release: ---   
Hardware: ia64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2004-10-03 12:13:01 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Attachments:
Description Flags
C-code to reproduce the bug none

Description Francois-Xavier 'FiX' KOWALSKI 2003-02-19 10:27:00 UTC
Description of problem:

gcc3's "-pthread" option does not set the -D_REENTRANT compilation flag.

the link flag -lpthread is correctly set.


Version-Release number of selected component (if applicable):

gcc3 -v
Reading specs from /usr/lib/gcc-lib/ia64-redhat-linux/3.0.4/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --host=ia64-redhat-linux --with-system-zlib
Thread model: posix
gcc version 3.0.4 (Red Hat Linux 7.2 3.0.4-1)

How reproducible:


Steps to Reproduce:
1. get the attached program pthbug.c
2. compile it with gcc3 -v -pthread -Wall -Wstrict-prototypes pthbug.c
3. note that -D_REENTRANT is not defined

Actual results:

 gcc3 -v -pthread -Wall -Wstrict-prototypes pthbug.c
Reading specs from /usr/lib/gcc-lib/ia64-redhat-linux/3.0.4/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --host=ia64-redhat-linux --with-system-zlib
Thread model: posix
gcc version 3.0.4 (Red Hat Linux 7.2 3.0.4-1)
 /usr/lib/gcc-lib/ia64-redhat-linux/3.0.4/cc1 -lang-c -v -D__GNUC__=3
-D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=4 -D__ia64 -D__ia64__ -D__linux
-D__linux__ -D_LONGLONG -Dlinux -Dunix -D__LP64__ -D__ELF__ -D__ia64 -D__ia64__
-D__linux -D__linux__ -D_LONGLONG -D__linux__ -D__unix__ -D__LP64__ -D__ELF__
-D__linux -D__unix -Asystem=linux -Acpu=ia64 -Amachine=ia64 -D__NO_INLINE__
-D__STDC_HOSTED__=1 -Wall -Wstrict-prototypes
-D__LONG_MAX__=9223372036854775807L pthbug.c -quiet -dumpbase pthbug.c -Wall
-Wstrict-prototypes -version -o /var/tmp/fxk/ccOy4gQr.s
GNU CPP version 3.0.4 (Red Hat Linux 7.2 3.0.4-1) (cpplib) (IA-64) Linux
GNU C version 3.0.4 (Red Hat Linux 7.2 3.0.4-1) (ia64-redhat-linux)
	compiled by GNU C version 3.0.4 (Red Hat Linux 7.2 3.0.4-1).
ignoring nonexistent directory "/usr/ia64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/gcc-lib/ia64-redhat-linux/3.0.4/include
 /usr/include
End of search list.
pthbug.c:9:2: #error "_REENTRANT undefined"

Expected results:

gcc3 -v -pthread -Wall -Wstrict-prototypes pthbug.c
Reading specs from /usr/lib/gcc-lib/ia64-redhat-linux/3.0.4/specs
Configured with: ../configure --prefix=/usr --mandir=/usr/share/man
--infodir=/usr/share/info --enable-shared --enable-threads=posix
--disable-checking --host=ia64-redhat-linux --with-system-zlib
Thread model: posix
gcc version 3.0.4 (Red Hat Linux 7.2 3.0.4-1)
 /usr/lib/gcc-lib/ia64-redhat-linux/3.0.4/cc1 -lang-c -v -D__GNUC__=3
-D_REENTRANT -D__GNUC_MINOR__=0 -D__GNUC_PATCHLEVEL__=4 -D__ia64 -D__ia64__
-D__linux -D__linux__ -D_LONGLONG -Dlinux -Dunix -D__LP64__ -D__ELF__ -D__ia64
-D__ia64__ -D__linux -D__linux__ -D_LONGLONG -D__linux__ -D__unix__ -D__LP64__
-D__ELF__ -D__linux -D__unix -Asystem=linux -Acpu=ia64 -Amachine=ia64
-D__NO_INLINE__ -D__STDC_HOSTED__=1 -Wall -Wstrict-prototypes
-D__LONG_MAX__=9223372036854775807L pthbug.c -quiet -dumpbase pthbug.c -Wall
-Wstrict-prototypes -version -o /var/tmp/fxk/ccOy4gQr.s
GNU CPP version 3.0.4 (Red Hat Linux 7.2 3.0.4-1) (cpplib) (IA-64) Linux
GNU C version 3.0.4 (Red Hat Linux 7.2 3.0.4-1) (ia64-redhat-linux)
	compiled by GNU C version 3.0.4 (Red Hat Linux 7.2 3.0.4-1).
ignoring nonexistent directory "/usr/ia64-redhat-linux/include"
#include "..." search starts here:
#include <...> search starts here:
 /usr/local/include
 /usr/lib/gcc-lib/ia64-redhat-linux/3.0.4/include
 /usr/include
End of search list.

Additional info:

1) The following distributions+compilers are not affected by this problem.

- ia32 + RedHat 2.1AS + gcc-2.96
- ia64 + RedHat 2.1AS + gcc-2.96
- ia32 + RedHat 7.3 + gcc-2.96
- ia32 + RedHat 7.2 + gcc-2.96
- ia64 + RedHat 7.2 + gcc-2.96
    
2) An application core-dump occurs when a C++ library is unloaded (call _fini),
because the libpthread destruction invokes application destructors that are not
compiled to support multi-thread.

Comment 1 Francois-Xavier 'FiX' KOWALSKI 2003-02-19 10:27:50 UTC
Created attachment 90180 [details]
C-code to reproduce the bug

Comment 2 Richard Henderson 2004-10-03 12:13:01 UTC
Still not fixed in gcc 4.0.  Upstream PR already exists:
http://gcc.gnu.org/bugzilla/show_bug.cgi?id=10865