[MLton-commit] r7529

Matthew Fluet fluet at mlton.org
Tue May 3 13:30:22 PDT 2011


Be less paranoid in emergency output functions.

In particular, when stderr is not accessible (e.g., killed pipe), an
uncaught exception that is printed by the top-level handler induces an
infinite loop.
----------------------------------------------------------------------

U   mlton/trunk/runtime/basis/MLton/bug.c
U   mlton/trunk/runtime/basis/Stdio.c

----------------------------------------------------------------------

Modified: mlton/trunk/runtime/basis/MLton/bug.c
===================================================================
--- mlton/trunk/runtime/basis/MLton/bug.c	2011-05-03 19:00:07 UTC (rev 7528)
+++ mlton/trunk/runtime/basis/MLton/bug.c	2011-05-03 20:30:21 UTC (rev 7529)
@@ -4,9 +4,7 @@
 void MLton_bug (String8_t msg) {
   uintmax_t size = GC_getArrayLength ((pointer)msg);
   fprintf (stderr, "MLton bug: ");
-  unless (0 == size)
-    while (1 != fwrite ((const void*)msg, (size_t)size, 1, stderr))
-      /* nothing */;
+  fwrite ((const void*)msg, (size_t)size, 1, stderr);
   fprintf (stderr, "\nPlease send a bug report to MLton at mlton.org.\n");
   exit (2);
 }

Modified: mlton/trunk/runtime/basis/Stdio.c
===================================================================
--- mlton/trunk/runtime/basis/Stdio.c	2011-05-03 19:00:07 UTC (rev 7528)
+++ mlton/trunk/runtime/basis/Stdio.c	2011-05-03 20:30:21 UTC (rev 7529)
@@ -2,18 +2,12 @@
 
 void Stdio_printStderr (String8_t s) {
   uintmax_t size = GC_getArrayLength ((pointer)s);
-  if (0 == size)
-    return;
-  while (1 != fwrite ((const void*)s, (size_t)size, 1, stderr))
-    /* nothing */;
+  fwrite ((const void*)s, (size_t)size, 1, stderr);
 }
 
 void Stdio_printStdout (String8_t s) {
   uintmax_t size = GC_getArrayLength ((pointer)s);
-  if (0 == size)
-    return;
-  while (1 != fwrite ((const void*)s, (size_t)size, 1, stdout))
-    /* nothing */;
+  fwrite ((const void*)s, (size_t)size, 1, stdout);
 }
 
 void Stdio_print (String8_t s) {




More information about the MLton-commit mailing list