Skip to content

Test: new failing test + fix #1365

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 19, 2022
Merged

Test: new failing test + fix #1365

merged 3 commits into from
Dec 19, 2022

Conversation

hhugo
Copy link
Member

@hhugo hhugo commented Dec 19, 2022

Example taken from
https://github.com/ocaml-multicore/effects-examples/blob/master/transaction.ml

There is suspicious stack overflow when runing in js.

$ dune runtest compiler/tests-jsoo/lib-effects/ --profile using-effects
Warning: overriding the purity of the primitive Base_am_testing: pure -> mutator
File "compiler/tests-jsoo/lib-effects/transaction.ml", line 1, characters 0-0:
------ compiler/tests-jsoo/lib-effects/transaction.ml
++++++ compiler/tests-jsoo/lib-effects/transaction.ml.corrected
File "compiler/tests-jsoo/lib-effects/transaction.ml", line 75, characters 0-1:
 |open Txn
 |
 |let%expect_test _ =
 |  atomically (fun () ->
 |      let r = ref 10 in
 |      printf "T0: %d\n" (!r);
 |      try atomically (fun () ->
 |          r := 20;
 |          r := 21;
 |          printf "T1: Before abort %d\n" (!r);
 |          raise (Res !r) |> ignore;
 |          printf "T1: After abort %d\n" (!r);
 |          r := 30)
 |      with
 |      | Res v -> printf "T0: T1 aborted with %d\n" v;
 |        printf "T0: %d\n" !r);
-|  [%expect {|
-|    T0: 10
-|    udpate
-|    restore
-|    udpate
-|    restore
-|    T1: Before abort 21
-|    before raise
-|    raise
-|    T0: T1 aborted with 21
-|    T0: 10 |}]
+|  [%expect.unreachable]
+|[@@expect.uncaught_exn {|
+|  ("Stack overflow")
+|  Trailing output
+|  ---------------
+|  T0: 10
+|  udpate
+|  restore
+|  udpate
+|  restore
+|  T1: Before abort 21
+|  before raise
+|  before raise |}]

@hhugo
Copy link
Member Author

hhugo commented Dec 19, 2022

@vouillon, can you take a look

@hhugo hhugo added the bug label Dec 19, 2022
@hhugo
Copy link
Member Author

hhugo commented Dec 19, 2022

Other failure

--- a/compiler/tests-jsoo/lib-effects/state.ml
+++ b/compiler/tests-jsoo/lib-effects/state.ml
@@ -262,9 +262,13 @@ let main () : unit =
 
 let%expect_test _ =
   ignore (IntCell.run ~init:0 (fun () -> StrCell.run ~init:"" main));
-  [%expect {|
-    0
-    42
-    21
-    Hello...
-    ...World! |}]
+  [%expect.unreachable]
+[@@expect.uncaught_exn {|
+  (Failure "TypeError: a is not a function")
+  Trailing output
+  ---------------
+  0
+  42
+  21
+  Hello...
+  ...World! |}]

@hhugo hhugo mentioned this pull request Dec 19, 2022
3 tasks
@vouillon vouillon changed the title Test: new failing test Test: new failing test + fix Dec 19, 2022
@vouillon
Copy link
Member

@hhugo I have pushed a fix.
Thanks for testing!

@hhugo
Copy link
Member Author

hhugo commented Dec 19, 2022

Thanks.

Is there any check we can do in the runtime to detect some of the situations that are definitely wrong and print an error to the user ?

@vouillon
Copy link
Member

Is there any check we can do in the runtime to detect some of the situations that are definitely wrong and print an error to the user ?

I don't see any simple test. We could check that caml_call_gen is only ever applied with a one-parameter function as last parameter. But we have to change caml_callback first, since the trampoline calls caml_call_gen without respecting this condition. And I think this would only catch internal errors, not errors from our users.

@hhugo hhugo merged commit 90d8240 into master Dec 19, 2022
@hhugo hhugo deleted the show-bug branch December 19, 2022 19:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants