[MLton] Re: [MLton-commit] r6978

Matthew Fluet fluet at tti-c.org
Wed Nov 12 08:59:22 PST 2008


On Mon, 10 Nov 2008, Wesley W. Terpstra wrote:
> On Mon, Nov 10, 2008 at 5:59 AM, Matthew Fluet <fluet at tti-c.org> wrote:
>> Please test more thoroughly, and ensure that the
>> <>/regression/size.sml (and related) regression tests pass.
>
> Sorry about that! I got my patches crossed while trying to commit only
> the change affecting MLton.size. I still would've messed up the
> -type-check true, though; I didn't know I had to set writesStackTop
> and modifiesFrontier. Fixed in r6981.

Thanks.  BTW, it occurs to me that MLton.share suffers from a similar 
issue.  It traces an object, so would be confused if it encounters the 
current stack in the heap without the used field being up-to-date.  As 
with MLton.size, it isn't likely to come up in practice, but one can 
trigger it with:

-----
val rt : MLton.Thread.Runnable.t option ref = ref NONE
val r1 : int ref = ref 0
val r2 : int ref = ref 0

fun stats () =
    let
       (* val () = r1 := MLton.size rt *)
       val () = MLton.share rt
       val () = r2 := MLton.size rt
    in
       ()
    end

fun switcheroo () =
    MLton.Thread.switch
    (fn t => let
                val () = rt := SOME (MLton.Thread.prepare (t, ()))
                val () = stats ()
             in
                valOf (!rt)
             end)

val () = switcheroo ()
val _ = print (concat ["!r1 = ", Int.toString (!r1), "\n"])
val _ = print (concat ["!r2 = ", Int.toString (!r2), "\n"])
-----

The indirection through rt is necessary so that MLton doesn't optimize the 
representation of the object passed to MLton.size and MLton.share down to 
a unit object.

MLton 20070826 will also bus error if "val () = r := MLton.size rt" is 
uncommented, demonstrating that MLton.size does crash without establishing 
the GC invariants.  MLton SVN HEAD doesn't bus error if it is uncommented, 
because MLton.size establishes the GC invariants which are not yet 
violated at MLton.share.



More information about the MLton mailing list