Skip to content

Extra args for continuations should be computed after restore_continuation_context#2848

Merged
mshinwell merged 3 commits intooxcaml:mainfrom
Ekdohibs:lambda-to-flambda-extra-params
Aug 7, 2024
Merged

Extra args for continuations should be computed after restore_continuation_context#2848
mshinwell merged 3 commits intooxcaml:mainfrom
Ekdohibs:lambda-to-flambda-extra-params

Conversation

@Ekdohibs
Copy link
Copy Markdown
Contributor

IMPORTANT: I think this PR fixes an error in lambda_to_flambda, but I am not sure about that and it needs a careful review.

Currently when generating an apply_cont in lambda_to_flambda, we first compute the extra args before calling restore_continuation_context, which can change the continuation being called and thus the extra args that are needed. It seems to me it should be the other way around, but there could be subtleties I'm missing.

Unfortunately, the only way I know to trigger the bug is to use a WIP version of unboxed products, in which the strange treatment we currently have of those (passing them to every continuation like mutable variables) has not been undone, which is available here: Ekdohibs@0abdaa8 .

With that commit and -extension layouts_beta options, this program (found by @ccasin) crashes flambda due to continuations with incorrect number of arguments, while it works with this commit on top:

let rec f6_2 n (tup : #(int * int)) =
  if (Sys.opaque_identity fst) n = 0 then tup
  else tup

I tried to produce a similar version with mutable variables, but have not succeeded yet.

@Ekdohibs Ekdohibs force-pushed the lambda-to-flambda-extra-params branch from 0a07f6e to f947bff Compare July 25, 2024 08:59
@mshinwell mshinwell added the flambda2 Prerequisite for, or part of, flambda2 label Aug 6, 2024
@mshinwell mshinwell force-pushed the lambda-to-flambda-extra-params branch from f947bff to ad3117b Compare August 7, 2024 11:44
@mshinwell mshinwell added the bug Something isn't working label Aug 7, 2024
@mshinwell mshinwell merged commit a2ab73f into oxcaml:main Aug 7, 2024
lukemaurer pushed a commit that referenced this pull request Oct 23, 2024
…r restore_continuation_context (#2848)

Co-authored-by: Mark Shinwell <mshinwell@pm.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working flambda2 Prerequisite for, or part of, flambda2

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants