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

Wrong unmarshaling of function pointers in debugger mode #10709

Merged
merged 4 commits into from
Oct 19, 2021
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion debugger/main.ml
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ let speclist = [
]

let function_placeholder () =
raise Not_found
failwith "custom printer tried to invoke a function from the debuggee"

let report report_error error =
eprintf "Debugger [version %s] environment error:@ @[@;%a@]@.;"
Expand Down
3 changes: 2 additions & 1 deletion runtime/intern.c
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,8 @@ static void intern_rec(value *dest)
const value * function_placeholder =
caml_named_value ("Debugger.function_placeholder");
if (function_placeholder != NULL) {
v = *function_placeholder;
/* Use the code pointer from the "placeholder" function */
v = Field(*function_placeholder, 0);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small question: I would have expected the Code_val macro instead of Field. If I read the code correctly this would require an additional cast to value, but it would make it clear that we're reading the code pointer.
Does that make sense ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, the intent is clearer with (value) Code_val(*function_placeholder). Done in aab79fd .

} else {
intern_cleanup();
intern_bad_code_pointer(digest);
Expand Down