Skip to content

Fix Risc-V code gen problem causing Python interpreter crash. #10301

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

Merged
merged 3 commits into from
May 5, 2025
Merged
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
5 changes: 4 additions & 1 deletion shared/runtime/pyexec.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,9 @@ static int parse_compile_execute(const void *source, mp_parse_input_kind_t input
nlr_buf_t nlr;
nlr.ret_val = NULL;
if (nlr_push(&nlr) == 0) {
mp_obj_t module_fun = mp_const_none;
// CIRCUITPY-CHANGE: Made volatile to prevent gcc from re-ordering store of function pointer into stack frame
// after call to gc_collect. For RISC-V this was causing free of the compiled function before execution.
volatile mp_obj_t module_fun = mp_const_none;
// CIRCUITPY-CHANGE
#if CIRCUITPY_ATEXIT
if (!(exec_flags & EXEC_FLAG_SOURCE_IS_ATEXIT))
Expand Down Expand Up @@ -157,6 +159,7 @@ static int parse_compile_execute(const void *source, mp_parse_input_kind_t input
mp_call_function_n_kw(callback->func, callback->n_pos, callback->n_kw, callback->args);
} else
#endif
// CIRCUITPY-CHANGE
if (module_fun != mp_const_none) {
mp_call_function_0(module_fun);
}
Expand Down
Loading