[MLton-commit] r6013

Matthew Fluet fluet at mlton.org
Tue Sep 11 20:57:30 PDT 2007


Fixed bug in interaction of _export-ed functions and signal handlers
----------------------------------------------------------------------

U   mlton/trunk/doc/changelog
U   mlton/trunk/include/amd64-main.h
U   mlton/trunk/include/bytecode-main.h
U   mlton/trunk/include/c-main.h
U   mlton/trunk/include/x86-main.h

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

Modified: mlton/trunk/doc/changelog
===================================================================
--- mlton/trunk/doc/changelog	2007-09-12 00:37:19 UTC (rev 6012)
+++ mlton/trunk/doc/changelog	2007-09-12 03:57:29 UTC (rev 6013)
@@ -1,5 +1,9 @@
 Here are the changes from version 20070826 to version YYYYMMDD.
 
+* 2007-09-11
+   - Fixed bug in interaction of _export-ed functions and signal
+     handlers.  Thanks to Sean McLaughlin for the bug report.
+
 * 2007-09-03
    - Fixed bug in implementation of _export of functions using 'char'
      type.  Thanks to Katsuhiro Ueno for the bug report.

Modified: mlton/trunk/include/amd64-main.h
===================================================================
--- mlton/trunk/include/amd64-main.h	2007-09-12 00:37:19 UTC (rev 6012)
+++ mlton/trunk/include/amd64-main.h	2007-09-12 03:57:29 UTC (rev 6013)
@@ -44,14 +44,19 @@
         if (DEBUG_AMD64CODEGEN)                                         \
                 fprintf (stderr, "MLton_callFromC() starting\n");       \
         s = &gcState;                                                   \
-        s->savedThread = s->currentThread;                              \
+        GC_setSavedThread (s, GC_getCurrentThread (s));                 \
         s->atomicState += 3;                                            \
+        if (s->signalsInfo.signalIsPending)                             \
+                s->limit = s->limitPlusSlop - GC_HEAP_LIMIT_SLOP;       \
         /* Return to the C Handler thread. */                           \
         GC_switchToThread (s, s->callFromCHandlerThread, 0);            \
         jump = *(pointer*)(s->stackTop - GC_RETURNADDRESS_SIZE);        \
         MLton_jumpToSML(jump);                                          \
-        GC_switchToThread (s, s->savedThread, 0);                       \
-        s->savedThread = BOGUS_OBJPTR;                                  \
+        s->atomicState += 1;                                            \
+        GC_switchToThread (s, GC_getSavedThread (s), 0);                \
+        s->atomicState -= 1;                                            \
+        if (0 == s->atomicState && s->signalsInfo.signalIsPending)      \
+                s->limit = 0;                                           \
         if (DEBUG_AMD64CODEGEN)                                         \
                 fprintf (stderr, "MLton_callFromC() done\n");           \
         return;                                                         \

Modified: mlton/trunk/include/bytecode-main.h
===================================================================
--- mlton/trunk/include/bytecode-main.h	2007-09-12 00:37:19 UTC (rev 6012)
+++ mlton/trunk/include/bytecode-main.h	2007-09-12 03:57:29 UTC (rev 6013)
@@ -29,14 +29,20 @@
         if (DEBUG_CODEGEN)                                              \
                 fprintf (stderr, "MLton_callFromC() starting\n");       \
         s = &gcState;                                                   \
-        s->savedThread = s->currentThread;                              \
+        GC_setSavedThread (s, GC_getCurrentThread (s));                 \
         s->atomicState += 3;                                            \
+        if (s->signalsInfo.signalIsPending)                             \
+                s->limit = s->limitPlusSlop - GC_HEAP_LIMIT_SLOP;       \
         /* Switch to the C Handler thread. */                           \
         GC_switchToThread (s, s->callFromCHandlerThread, 0);            \
         nextFun = *(uintptr_t*)(s->stackTop - GC_RETURNADDRESS_SIZE);   \
         MLton_Bytecode_interpret (&MLton_bytecode, nextFun);            \
-        GC_switchToThread (s, s->savedThread, 0);                       \
-        s->savedThread = BOGUS_OBJPTR;                                  \
+        s->atomicState += 1;                                            \
+        GC_switchToThread (s, GC_getSavedThread (s), 0);                \
+        s->atomicState -= 1;                                            \
+        if (0 == s->atomicState                                         \
+            && s->signalsInfo.signalIsPending)                          \
+                s->limit = 0;                                           \
         if (DEBUG_CODEGEN)                                              \
                 fprintf (stderr, "MLton_callFromC done\n");             \
 }                                                                       \

Modified: mlton/trunk/include/c-main.h
===================================================================
--- mlton/trunk/include/c-main.h	2007-09-12 00:37:19 UTC (rev 6012)
+++ mlton/trunk/include/c-main.h	2007-09-12 03:57:29 UTC (rev 6013)
@@ -27,8 +27,10 @@
         if (DEBUG_CCODEGEN)                                             \
                 fprintf (stderr, "MLton_callFromC() starting\n");       \
         s = &gcState;                                                   \
-        s->savedThread = s->currentThread;                              \
+        GC_setSavedThread (s, GC_getCurrentThread (s));                 \
         s->atomicState += 3;                                            \
+        if (s->signalsInfo.signalIsPending)                             \
+                s->limit = s->limitPlusSlop - GC_HEAP_LIMIT_SLOP;       \
         /* Switch to the C Handler thread. */                           \
         GC_switchToThread (s, s->callFromCHandlerThread, 0);            \
         nextFun = *(uintptr_t*)(s->stackTop - GC_RETURNADDRESS_SIZE);   \
@@ -37,8 +39,12 @@
         do {                                                            \
                 cont=(*(struct cont(*)(void))cont.nextChunk)();         \
         } while (not returnToC);                                        \
-        GC_switchToThread (s, s->savedThread, 0);                       \
-        s->savedThread = BOGUS_OBJPTR;                                  \
+        s->atomicState += 1;                                            \
+        GC_switchToThread (s, GC_getSavedThread (s), 0);                \
+        s->atomicState -= 1;                                            \
+        if (0 == s->atomicState                                         \
+            && s->signalsInfo.signalIsPending)                          \
+                s->limit = 0;                                           \
         if (DEBUG_CCODEGEN)                                             \
                 fprintf (stderr, "MLton_callFromC done\n");             \
 }                                                                       \

Modified: mlton/trunk/include/x86-main.h
===================================================================
--- mlton/trunk/include/x86-main.h	2007-09-12 00:37:19 UTC (rev 6012)
+++ mlton/trunk/include/x86-main.h	2007-09-12 03:57:29 UTC (rev 6013)
@@ -51,14 +51,20 @@
         if (DEBUG_X86CODEGEN)                                           \
                 fprintf (stderr, "MLton_callFromC() starting\n");       \
         s = &gcState;                                                   \
-        s->savedThread = s->currentThread;                              \
+        GC_setSavedThread (s, GC_getCurrentThread (s));                 \
         s->atomicState += 3;                                            \
+        if (s->signalsInfo.signalIsPending)                             \
+                s->limit = s->limitPlusSlop - GC_HEAP_LIMIT_SLOP;       \
         /* Return to the C Handler thread. */                           \
         GC_switchToThread (s, s->callFromCHandlerThread, 0);            \
         jump = *(pointer*)(s->stackTop - GC_RETURNADDRESS_SIZE);        \
         MLton_jumpToSML(jump);                                          \
-        GC_switchToThread (s, s->savedThread, 0);                       \
-        s->savedThread = BOGUS_OBJPTR;                                  \
+        s->atomicState += 1;                                            \
+        GC_switchToThread (s, GC_getSavedThread (s), 0);                \
+        s->atomicState -= 1;                                            \
+        if (0 == s->atomicState                                         \
+            && s->signalsInfo.signalIsPending)                          \
+                s->limit = 0;                                           \
         if (DEBUG_X86CODEGEN)                                           \
                 fprintf (stderr, "MLton_callFromC() done\n");           \
         return;                                                         \




More information about the MLton-commit mailing list