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

Avoid infinite method error on bootstrap error #18438

Merged
merged 1 commit into from
Sep 12, 2016
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
47 changes: 29 additions & 18 deletions ui/repl.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,30 +44,41 @@ __attribute__((constructor)) void jl_register_ptls_states_getter(void)
static int exec_program(char *program)
{
jl_ptls_t ptls = jl_get_ptls_states();
int err = 0;
again: ;
JL_TRY {
if (err) {
jl_value_t *errs = jl_stderr_obj();
jl_value_t *e = ptls->exception_in_transit;
if (errs != NULL) {
jl_load(program);
}
JL_CATCH {
jl_value_t *errs = jl_stderr_obj();
jl_value_t *e = ptls->exception_in_transit;
// Manually save and restore the backtrace so that we print the original
// one instead of the one caused by `jl_show`.
// We can't use safe_restore since that will cause any error
// (including the ones that would have been caught) to abort.
uintptr_t *volatile bt_data = NULL;
size_t bt_size = ptls->bt_size;
JL_TRY {
if (errs) {
bt_data = (uintptr_t*)malloc(bt_size * sizeof(void*));
memcpy(bt_data, ptls->bt_data, bt_size * sizeof(void*));
jl_show(errs, e);
}
else {
jl_printf(JL_STDERR, "error during bootstrap:\n");
jl_static_show(JL_STDERR, e);
jl_printf(JL_STDERR, "\n");
jlbacktrace();
free(bt_data);
}
}
JL_CATCH {
ptls->bt_size = bt_size;
memcpy(ptls->bt_data, bt_data, bt_size * sizeof(void*));
free(bt_data);
errs = NULL;
}
if (!errs) {
jl_printf(JL_STDERR, "error during bootstrap:\n");
jl_static_show(JL_STDERR, e);
jl_printf(JL_STDERR, "\n");
jlbacktrace();
jl_printf(JL_STDERR, "\n");
JL_EH_POP();
return 1;
}
jl_load(program);
}
JL_CATCH {
err = 1;
goto again;
return 1;
}
return 0;
}
Expand Down