[PATCH] Re: Who understands this code?

Greg Schafer gschafer at zip.com.au
Sun Mar 16 01:23:14 PST 2003


On Sat, Mar 15, 2003 at 09:49:07PM -0500, Donald Smith wrote:
> straces look good. I guess break was correct!
> 
> The correct fix would be an even more invasive and probably with a while 
> loop, but it's only a test program. The above patch could be submitted 
> to the gcc guys.

Ok, this is the final patch. Will kick off (yet another) round of builds
tonight to confirm all is well.

I'll submit this to the gcc guys and if it gets applied, you might even get
your name in the Changelog :-)  But it's not really a showstopper so it may
not even get looked at for quite a while..

Greg
-------------- next part --------------
diff -uNr gcc-3.2.2.orig/gcc/configure gcc-3.2.2/gcc/configure
--- gcc-3.2.2.orig/gcc/configure	2003-02-04 11:17:46.000000000 +1100
+++ gcc-3.2.2/gcc/configure	2003-03-16 20:10:03.000000000 +1100
@@ -4206,6 +4206,7 @@
 test_3 ()
 {
   char *x, *y, *z;
+  int i;
 
   x = anonmap (pg);
   if (x == (char *)MAP_FAILED)
@@ -4214,6 +4215,23 @@
   if (y == (char *)MAP_FAILED)
     perror_exit ("test 3 mmap 2", 15);
 
+/* A subtle race condition occurs when the ld.so.cache file is less than one
+   memory page in size. This causes the check to fail when normally it wouldn't.
+   Be sure to actually get the two adjacent 1-page regions.  */
+
+  for (i = 0; i < 8; i++) /* limit to 8 tries */
+    {
+      if (y != x + pg)
+	{
+	  x = y;
+	  y = anonmap(pg);
+	  if (y == (char *)MAP_FAILED)
+	    perror_exit ("test 3 mmap 3", 15);
+	}
+      else
+	  break; /* got one */
+    }
+
   if (y != x + pg)
     {
       if (y == x - pg)


More information about the lfs-dev mailing list