This is the mail archive of the gcc-help@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Help needed with GCC 2.95.3 on Redhat 8 -- segfault


I have a really irritating problem with GCC 2.95.3 on Redhat 8.

I have compiled and installed binutils 2.12 and GCC 2.95.3 on a Redhat 
6.2 (default compiler egcs2.91.66) and a Redhat 8 (default compiler
gcc3.2) box.

I would like to run this simple program:

// phil.cc
#include <stdio.h>
int main(void) {
    FILE *fr=freopen("blib","r",stdin);
    printf("Success\n");
    return 1;
}

On Redhat 6.2, this happens:
% g++ phil.cc -o phil
% phil
Success
      (good!)

On Redhat 8, this happens:
% g++ phil.cc -o phil
% phil
Segmentation fault

Why does it segfault with the GCC I've built on RH8, but work fine with
RH6.2?

Ldd reveals this...

% ldd phil
	libstdc++-libc6.3-2.so.3 =>
/usr/installed/gcc2.95.3/lib/libstdc++-libc6.3-2.so.3 (0x40013000)
	libm.so.6 => /lib/i686/libm.so.6 (0x40070000)
	libc.so.6 => /lib/i686/libc.so.6 (0x42000000)
	/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)

(
 On the RH 6.2 box, on which it runs successfully, I get...
	libstdc++-libc6.1-2.so.3 =>
/installed/gcc-2.95.3/lib/libstdc++-libc6.1-2.so.3 (0x40015000)
	libm.so.6 => /lib/libm.so.6 (0x40068000)
	libc.so.6 => /lib/libc.so.6 (0x40085000)
	/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
)

If I instead try to build it as a C program, ie.
% gcc phil.cc -o phil
...  then it works fine.

What on earth could be going wrong?  I'd thought that perhaps the
libraries might be out of sync but I can't think how or why that would be
the case.

On the Redhat 8 box we also have a GCC 3.2 compiler installed.  But I've
made sure that the GCC2.95.3 installation directory appears at the
beginning of my $PATH and $LD_LIBRARY_PATH to make sure it's picking up
the correct one.

(FYI, ldd on the working 'gcc'-compiled version gives...
	libc.so.6 => /lib/i686/libc.so.6 (0x42000000)
	/lib/ld-linux.so.2 => /lib/ld-linux.so.2 (0x40000000)
)

Can anyone help?  (please!)

phil

-- 
Phil George, Anvil Software Ltd.
email: philg@anvil.com
phone: 020 7749 7922


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]