This is the mail archive of the gcc@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]

Re: A Linux/libc 5 patch for egcs 1.1.2


HJ wrote:
> > > Here is a libio patch for libc 5 using __attribute__ instead of pragma.
> > > It is totally untested since I no longer have libc 5 machine. Someone
> > > should check if it compiles and runs on libc 5.

I replied:
> > I volunteer to test it, but I won't have time until this weekend.

HJ writes:
> I don't remember exactly how to trigger the bug. You may want to
> try to use both fclose and iostream in C++ code linked with -static.

I built egcs, using the CVS egcs_1_1_branch as of Friday about 10PM PST,
on my Red Hat 4.2 box (using 2.9.1.0.19a binutils for as and ld, rather
than the Red Hat version, so that exceptions will work correctly).  This
is without HJ's patch.  I used --enable-shared.

All the g++ tests pass (except of course for the expected failures).
I sent the report to egcs-testresults.

To try to duplicate the problem HJ has been talking about, I tried
the following test program:

------------------------------------------------
#include <stdio.h>
#include <fstream.h>
#include <string>

// write a file with stdio, read it with streams
int main(int argc, char** argv)
{
  if (argc != 2) {
    fprintf(stderr, "usage: %s file\n", argv[0]);
    return 1;
  }
  FILE * fd = fopen(argv[1], "w");
  fprintf (fd, "hello\n");
  fclose(fd);
  ifstream str(argv[1]);
  string s;
  str >> s;
  cout << s << endl;
}
------------------------------------------------

This program successfully runs without HJ's patch when built with
g++ -O2 -static iotest.cxx -o iotest

I tried other combinations, eg using the static libstdc++ and the
dynamic libc.  I couldn't make it fail.

Note that Red Hat 4.2 has libc 5.3.12 plus many Red Hat patches,
not libc 5.4.x.  Is it possible that the bug HJ is referring to
only shows up on libc 5.4.x systems?  (If so, do we have anyone
on egcs who has such a system who can try the test?).
Or is it possible that my test program isn't the correct test to
tweak the bug?

I don't think we should put the patch in unless we have a test
case that fails without the patch and passes with the patch.
If someone has a 5.4.x libc, could you try my test program
above?

Joe


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