Skip to content

Fix marshalling causing crashes with using the -fork flag. - #27

Open
WINSDK wants to merge 1 commit into
janestreet:masterfrom
WINSDK:master
Open

Fix marshalling causing crashes with using the -fork flag.#27
WINSDK wants to merge 1 commit into
janestreet:masterfrom
WINSDK:master

Conversation

@WINSDK

@WINSDK WINSDK commented Jan 13, 2025

Copy link
Copy Markdown

When testing on MacOS I was running my benchmarks with the -fork flag.
This causes every benchmark to throw an exception with:

Uncaught exception:
  
  (Invalid_argument "output_value: functional value")

Raised by primitive operation at Stdlib__Marshal.(partial) in file "marshal.ml" (inlined), lines 28-29, characters 0-93
Called from Core_bench__Benchmark.measure_all.(fun) in file "src/benchmark.ml", line 232, characters 12-38
Called from Stdlib__List.iter2 in file "list.ml" (inlined), line 160, characters 24-31``

It appears that when using -fork, each measurement is marshalled over a pipe.
However measurements have samples and their samples include an extra field which can't be marshalled.

match Caml_unix.fork () with
| 0 ->
  let x = measure run_config test in
  let open Stdlib in
  let oc = Caml_unix.out_channel_of_descr fdw in
  Marshal.to_channel oc x []; (* This fails to marshall. *)
  exit 0
| pid -> ignore (Caml_unix.waitpid [] pid : int * Caml_unix.process_status))

I've changed the samples using a Map to just using an association list which fixes the issue.

Signed-off-by: Nicolas Mazzon <nicolasmazzon549@gmail.com>
@github-iron github-iron added the forwarded-to-js-devs This report has been forwarded to Jane Street's internal review system. label Jan 14, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

forwarded-to-js-devs This report has been forwarded to Jane Street's internal review system.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants