Skip to content
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

Initialize local roots with Val_unit to fix segfault #29

Merged
merged 1 commit into from
Jul 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
sim642 marked this conversation as resolved.
Show resolved Hide resolved
end

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