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

[tree-ssa libmudflap] realloc fix


Hi -

This patch fixes the gethostbyname-related crash Eyal noticed.


+2003-05-23  Frank Ch. Eigler  <fche@redhat.com>
+
+	* mf-hooks.c (realloc): Correct reentrancy logic.
+	* testsuite/libmudflap.c/hook-allocstuff.c: New test case.
+

Index: mf-hooks.c
===================================================================
RCS file: /cvs/gcc/gcc/libmudflap/Attic/mf-hooks.c,v
retrieving revision 1.1.2.34
diff -u -r1.1.2.34 mf-hooks.c
--- mf-hooks.c	20 May 2003 19:09:47 -0000	1.1.2.34
+++ mf-hooks.c	23 May 2003 16:39:16 -0000
@@ -180,7 +180,7 @@
   /* Ensure heap wiping doesn't occur during this peculiar
      unregister/reregister pair.  */
   LOCKTH ();
-  /* XXX: reentrancy! */
+  __mf_state = reentrant;
   saved_wipe_heap = __mf_opts.wipe_heap;
   __mf_opts.wipe_heap = 0;
 
@@ -196,6 +196,8 @@
 
   /* Restore previous setting.  */
   __mf_opts.wipe_heap = saved_wipe_heap;
+
+  __mf_state = active;
   UNLOCKTH ();
 
   return result;
Index: testsuite/libmudflap.c/hook-allocstuff.c
===================================================================
RCS file: testsuite/libmudflap.c/hook-allocstuff.c
diff -N testsuite/libmudflap.c/hook-allocstuff.c
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ testsuite/libmudflap.c/hook-allocstuff.c	23 May 2003 16:39:16 -0000
@@ -0,0 +1,16 @@
+#include <stdio.h>
+#include <stdlib.h>
+
+int main ()
+{
+  char *foo = (char *) malloc (10);
+  strcpy (foo, "hello");
+  foo = (char *) realloc (foo, 20);
+  printf ("%s", foo);
+  if (strcmp (foo, "hello"))
+    abort ();
+  free (foo);
+  printf (" world\n");
+  return 0;
+}
+/* { dg-output "hello world" } */


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