[MLton-commit] r6919
Matthew Fluet
fluet at mlton.org
Thu Oct 9 19:22:15 PDT 2008
Fix bug in nested _export/_import functions.
In the C codegen, the trampoline for MLton_callFromC terminates when
the 'returnToC' is set to 'TRUE' in the SML/ChunkN code. However, if
an _export-ed function returned to an _import-ed function returned to
an _export-ed function, then the outer _export-ed function is
executing the trampoline for MLton_callFromC with the 'returnToC'
global set to 'TRUE'. If the outer _export-ed function terminates
quickly, then it will itself set 'returnToC' to 'TRUE' and exit the
SML/ChunkN code. However, if continuing the execution of the outer
_export-ed function requires an inter-chunk transfer, then it would
(erroneously) terminate the trampoline (without properly returning
values).
Similarly, when executing as a library, the 'lib_open' trampoline
could erroneously be terminated with 'returnToC' is set to 'TRUE' when
an _export-ed function returns to an _import-ed function returns to
top-level SML code.
----------------------------------------------------------------------
U mlton/trunk/include/c-main.h
----------------------------------------------------------------------
Modified: mlton/trunk/include/c-main.h
===================================================================
--- mlton/trunk/include/c-main.h 2008-10-09 21:35:20 UTC (rev 6918)
+++ mlton/trunk/include/c-main.h 2008-10-10 02:22:13 UTC (rev 6919)
@@ -39,6 +39,7 @@
do { \
cont=(*(struct cont(*)(void))cont.nextChunk)(); \
} while (not returnToC); \
+ returnToC = FALSE; \
s->atomicState += 1; \
GC_switchToThread (s, GC_getSavedThread (s), 0); \
s->atomicState -= 1; \
More information about the MLton-commit
mailing list