Fix soundness bug by using currying information from typing#850
Merged
lpw25 merged 6 commits intooxcaml:mainfrom Sep 28, 2022
Merged
Fix soundness bug by using currying information from typing#850lpw25 merged 6 commits intooxcaml:mainfrom
lpw25 merged 6 commits intooxcaml:mainfrom
Conversation
lpw25
reviewed
Sep 26, 2022
Collaborator
lpw25
left a comment
There was a problem hiding this comment.
Mostly looks good. One place that looks suspicious.
1da1a1b to
533d51c
Compare
lpw25
reviewed
Sep 28, 2022
Collaborator
lpw25
left a comment
There was a problem hiding this comment.
This now looks safe, but I think it's too strict and doesn't always allocate things locally when it could.
Previously, transl_curried_function in Translcore redetected function currying, which is difficult with locals as modes may make it invalid to merge two lambdas into a single n-ary function. The mode logic here was wrong, leading to a soundness bug. Rather than fix it (which would continue the duplication of mode-checking between typing and transl), the fix here is to add the relevant information to Typedtree, so that Translcore follows the decisions made by typing instead of redetecting currying on its own.
a36c755 to
974d745
Compare
mshinwell
added a commit
to mshinwell/oxcaml
that referenced
this pull request
Oct 24, 2022
25188da flambda-backend: Missed comment from PR802 (oxcaml#887) 9469765 flambda-backend: Improve the semantics of asynchronous exceptions (new simpler version) (oxcaml#802) d9e4dd0 flambda-backend: Fix `make runtest` on NixOS (oxcaml#874) 4bbde7a flambda-backend: Simpler symbols (oxcaml#753) ef37262 flambda-backend: Add opaqueness to Obj.magic under Flambda 2 (oxcaml#862) a9616e9 flambda-backend: Add build system hooks for ocaml-jst (oxcaml#869) 045ef67 flambda-backend: Allow the compiler to build with stock Dune (oxcaml#868) 3cac5be flambda-backend: Simplify Makefile logic for natdynlinkops (oxcaml#866) c5b12bf flambda-backend: Remove unnecessary install lines (oxcaml#860) ff12bbe flambda-backend: Fix unused variable warning in st_stubs.c (oxcaml#861) c84976c flambda-backend: Static check for noalloc: attributes (oxcaml#825) ca56052 flambda-backend: Build system refactoring for ocaml-jst (oxcaml#857) 39eb7f9 flambda-backend: Remove integer comparison involving nonconstant polymorphic variants (oxcaml#854) c102688 flambda-backend: Fix soundness bug by using currying information from typing (oxcaml#850) 6a96b61 flambda-backend: Add a primitive to enable/disable the tick thread (oxcaml#852) f64370b flambda-backend: Make Obj.dup use a new primitive, %obj_dup (oxcaml#843) 9b78eb2 flambda-backend: Add test for oxcaml#820 (include functor soundness bug) (oxcaml#841) 8f24346 flambda-backend: Add `-dtimings-precision` flag (oxcaml#833) 65c2f22 flambda-backend: Add test for oxcaml#829 (oxcaml#831) 7b27a49 flambda-backend: Follow-up PR#829 (comballoc fixes for locals) (oxcaml#830) ad7ec10 flambda-backend: Use a custom condition variable implementation (oxcaml#787) 3ee650c flambda-backend: Fix soundness bug in include functor (oxcaml#820) 2f57378 flambda-backend: Static check noalloc (oxcaml#778) aaad625 flambda-backend: Emit begin/end region only when stack allocation is enabled (oxcaml#812) 17c7173 flambda-backend: Fix .cmt for included signatures (oxcaml#803) e119669 flambda-backend: Increase delays in tests/lib-threads/beat.ml (oxcaml#800) ccc356d flambda-backend: Prevent dynamic loading of the same .cmxs twice in private mode, etc. (oxcaml#784) 14eb572 flambda-backend: Make local extension point equivalent to local_ expression (oxcaml#790) 487d11b flambda-backend: Fix tast_iterator and tast_mapper for include functor. (oxcaml#795) a50a818 flambda-backend: Reduce closure allocation in List (oxcaml#792) 96c9c60 flambda-backend: Merge ocaml-jst a775b88 flambda-backend: Fix ocaml/otherlibs/unix 32-bit build (oxcaml#767) f7c2679 flambda-backend: Create object files internally to avoid invoking GAS (oxcaml#757) c7a46bb flambda-backend: Bugfix for Cmmgen.expr_size with locals (oxcaml#756) b337cb6 flambda-backend: Fix build_upstream for PR749 (oxcaml#750) 8e7e81c flambda-backend: Differentiate is_int primitive between generic and variant-only versions (oxcaml#749) git-subtree-dir: ocaml git-subtree-split: 25188da
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, transl_curried_function in Translcore redetected function currying, which is difficult with locals as modes may make it invalid to merge two lambdas into a single n-ary function.
The mode logic here was wrong, leading to a soundness bug. Rather than fix it (which would continue the duplication of mode-checking between typing and transl), the fix here is to add the relevant information to Typedtree, so that Translcore follows the decisions made by typing instead of redetecting currying on its own.
This causes a slight change in closure allocation /
caml_applybehaviour, as the currying decisions made by Typedtree do not always exactly match those made by Lambda. For instance, the following is now detected as a two-argument function as the typechecker (unlike Lambda) does not see through the unboxed record: