Skip to content

Commit

Permalink
Initialize local roots with Val_unit instead of 0 to prevent GC crash
Browse files Browse the repository at this point in the history
  • Loading branch information
sim642 committed Jun 27, 2024
1 parent 236d59e commit 800c175
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion compiler/funct.ml
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ let emit_function oc fundecl ins outs locals emit_call =
output_variable_declarations oc;
fprintf oc " value _vresult;\n";
fprintf oc " value _vres[%d] = { " num_outs;
for i = 1 to num_outs do fprintf oc "0, " done;
for i = 1 to num_outs do fprintf oc "Val_unit, " done;
fprintf oc "};\n\n"
end;
end_diversion oc;
Expand Down
2 changes: 1 addition & 1 deletion compiler/intf.ml
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ let emit_callback_wrapper oc intf meth =
(* Declare locals to hold ML arguments and result, and C result if any *)
let num_ins = List.length ins in
fprintf oc " value _varg[%d] = { " (num_ins + 1);
for i = 0 to num_ins do fprintf oc "0, " done;
for i = 0 to num_ins do fprintf oc "Val_unit, " done;
fprintf oc "};\n";
fprintf oc " value _vres;\n";
if meth.fun_res <> Type_void then
Expand Down
4 changes: 2 additions & 2 deletions compiler/variables.ml
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ let init_value_block oc blk numvals =
for i = 0 to numvals - 1 do
fprintf oc "%s[%d] = " blk i
done;
fprintf oc "0;\n"
fprintf oc "Val_unit;\n"
end else begin
iprintf oc "memset(%s, 0, %d * sizeof(value));\n" blk numvals
iprintf oc "memset(%s, Val_unit, %d * sizeof(value));\n" blk numvals
end

(* Copy an array of values into the fields of a newly-allocated block *)
Expand Down

0 comments on commit 800c175

Please sign in to comment.