Skip to content

Commit

Permalink
Statically initialize caml_global_data with a valid value (#11788)
Browse files Browse the repository at this point in the history
The default initial value (0) is not a valid value in
no-naked-pointers mode, causing a segfault if a GC is triggered while
reading the global data from a bytecode executable.  Repro case:
```
let _ = "      "  (* 10 million spaces *)
```

Fixes: #11768
  • Loading branch information
xavierleroy authored Dec 5, 2022
1 parent 85a0817 commit 7b35ef7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
5 changes: 5 additions & 0 deletions Changes
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,11 @@ OCaml 4.14 maintenance branch
(this had stopped working in 4.14.0)
(Gabriel Scherer, review by Jacques Garrigue, report by Yaron Minsky)

- #11768, #11788: Fix crash at start-up of bytecode programs in
no-naked-pointers mode caused by wrong initialization of caml_global_data
(Xavier Leroy, report by Etienne Millon, review by Gabriel Scherer)


OCaml 4.14.0 (28 March 2022)
----------------------------

Expand Down
2 changes: 1 addition & 1 deletion runtime/stacks.c
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
#include "caml/mlvalues.h"
#include "caml/stacks.h"

value caml_global_data = 0;
value caml_global_data = Val_unit; /* must be a valid value (#11768) */

uintnat caml_max_stack_size; /* also used in gc_ctrl.c */

Expand Down

0 comments on commit 7b35ef7

Please sign in to comment.