Fix MPR 7301 (Flambda versus lazy)#713
Conversation
|
I was concerned that only setting the What about generating a call to the opaque identity around the creation of the forward block? This should be a bit safer than the current solution ( (I was also concerned that there might be other cases of blocks whose tag change, but this does not seem to be the case for now: |
|
I was going to say the same thing as @alainfrisch, Popaque is the only way to prevent the tag information from being used. |
|
Also we might not want to hide the setfield argument inside an opaque to be able to see other potential missing cases |
|
I confirm that the patch avoids the segfault in our failing tests. |
|
@alainfrisch You mean setting the @chambart Maybe in fact that is a better idea, at least for the moment. I'll revert that part. |
Yes, sorry. |
|
I'm not sure what should be the semantics of such a lazy makeblock to fit well with the Pforce code. Maybe that suggest that Plazyforce lowering should apply later in native code to handle that well. |
|
@alainfrisch @chambart Can one of you please approve this if you are certain of the fix? |
|
Yes, I'm rather confident this patch addresses the root cause of the problem. (Don't forget to add an entry to Changes!) |
* Repair build broken by mirage-kv 6.0.0 In mirage-kv 5.0.0 the function last_modified returned a result of type: (int * int64, error) result Lwt.t This was changed in 6.0.0, where it returns a result of type: (Ptime.t, error) result Lwt.t This caused a typing error. Removing the call to function Ptime.v : int * int64 -> Ptime.t solved the issue. * Formatting Co-authored-by: Cuihtlauac ALVARADO <cuihtmlauac@tarides.com>
Currently,
Forward_tagvalues are marked asImmutableinTranslcore, which means that Flambda deduces approximations for them and may use such approximations during simplification. Unfortunately this loses the information that the value may be replaced during GC by the value pointed to by the forwarding pointer, which can cause wrong code (MPR 7301).This patch marks
Forward_tagblocks asMutablein all cases where they may be updated by the GC. As noted in the comment, this isn't entirely satisfactory, since in fact these blocks may be replaced by immediates or updated in other ways that are not just simple field mutation. We should fix this in the future, but there should not be any correctness issue at the moment, since Flambda doesn't try to do anything with mutable values.Application of
lazyto some kinds of values (e.g. a manifest closure) can translate to a no-op, which as shown by MPR 7292, can cause warning messages complaining about writes to immutable values when functions such asLazy.forceare inlined. The specific example in MPR 7292 arises partially because there is a deficiency in the simplification of "switch" statements in Flambda (see OCamlPro/flambda-task-force#159), but that aside, I think we should include the changes toCamlinternallazygiven here in case the same problem arises in some other context. We may need to consider a better approach to suppressing warning 59 in future.