Skip to content

Commit

Permalink
Missing initialization in caml_obj_reachable_words
Browse files Browse the repository at this point in the history
A marshaling operation can leave `extern_flags` with the `NO_SHARING`
bit set.  In this context, `caml_obj_reachable_words` calls
`extern_init_position_table`, which does nothing, then proceeds to
access the position table, causing a crash.

The solution is trivial: initialize `extern_flags` before calling
`extern_init_position_table`.

First reported at ocaml-multicore/ocaml-multicore#824
  • Loading branch information
xavierleroy committed Jan 6, 2022
1 parent a5d2c6f commit 9476fbb
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions runtime/extern.c
Original file line number Diff line number Diff line change
Expand Up @@ -1136,6 +1136,7 @@ CAMLprim value caml_obj_reachable_words(value v)
uintnat pos;

obj_counter = 0;
extern_flags = 0;
extern_init_position_table();
sp = extern_stack;
size = 0;
Expand Down

0 comments on commit 9476fbb

Please sign in to comment.