[MLton-commit] r5705

Matthew Fluet fluet at mlton.org
Sun Jul 1 14:26:11 PDT 2007


Fix dereferences at wrong size.
These haven't hurt us on amd64, since it is a little-endian system and
the values can all be represented in 32-bits.


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

U   mlton/trunk/include/c-chunk.h
U   mlton/trunk/include/c-main.h

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

Modified: mlton/trunk/include/c-chunk.h
===================================================================
--- mlton/trunk/include/c-chunk.h	2007-07-01 16:53:41 UTC (rev 5704)
+++ mlton/trunk/include/c-chunk.h	2007-07-01 21:26:11 UTC (rev 5705)
@@ -31,7 +31,7 @@
 #endif
 
 #define GCState ((Pointer)&gcState)
-#define ExnStack *(Word32*)(GCState + ExnStackOffset)
+#define ExnStack *(size_t*)(GCState + ExnStackOffset)
 #define FrontierMem *(Pointer*)(GCState + FrontierOffset)
 #define Frontier frontier
 #define StackBottom *(Pointer*)(GCState + StackBottomOffset)
@@ -171,7 +171,7 @@
 
 #define Return()                                                                \
         do {                                                                    \
-                l_nextFun = *(Word32*)(StackTop - sizeof(void*));               \
+                l_nextFun = *(uintptr_t*)(StackTop - sizeof(void*));            \
                 if (DEBUG_CCODEGEN)                                             \
                         fprintf (stderr, "%s:%d: Return()  l_nextFun = %d\n",   \
                                         __FILE__, __LINE__, l_nextFun);         \

Modified: mlton/trunk/include/c-main.h
===================================================================
--- mlton/trunk/include/c-main.h	2007-07-01 16:53:41 UTC (rev 5704)
+++ mlton/trunk/include/c-main.h	2007-07-01 21:26:11 UTC (rev 5705)
@@ -31,7 +31,7 @@
         s->atomicState += 3;                                            \
         /* Switch to the C Handler thread. */                           \
         GC_switchToThread (s, s->callFromCHandlerThread, 0);            \
-        nextFun = *(Word32*)(s->stackTop - GC_RETURNADDRESS_SIZE);      \
+        nextFun = *(uintptr_t*)(s->stackTop - GC_RETURNADDRESS_SIZE);   \
         cont.nextChunk = nextChunks[nextFun];                           \
         returnToC = FALSE;                                              \
         do {                                                            \
@@ -50,7 +50,7 @@
                 PrepFarJump(mc, ml);                                    \
         } else {                                                        \
                 /* Return to the saved world */                         \
-                nextFun = *(Word32*)(gcState.stackTop - GC_RETURNADDRESS_SIZE); \
+                nextFun = *(uintptr_t*)(gcState.stackTop - GC_RETURNADDRESS_SIZE); \
                 cont.nextChunk = nextChunks[nextFun];                   \
         }                                                               \
         /* Trampoline */                                                \




More information about the MLton-commit mailing list