Skip to content

Commit 1c938c0

Browse files
committed
fix NULL derefs when printing errors during bootstrap
1 parent c726d2a commit 1c938c0

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

src/builtins.c

+2
Original file line numberDiff line numberDiff line change
@@ -890,13 +890,15 @@ void jl_flush_cstdio(void)
890890

891891
jl_value_t *jl_stdout_obj(void)
892892
{
893+
if (jl_base_module == NULL) return NULL;
893894
jl_value_t *stdout_obj = jl_get_global(jl_base_module, jl_symbol("STDOUT"));
894895
if (stdout_obj != NULL) return stdout_obj;
895896
return jl_get_global(jl_base_module, jl_symbol("OUTPUT_STREAM"));
896897
}
897898

898899
jl_value_t *jl_stderr_obj(void)
899900
{
901+
if (jl_base_module == NULL) return NULL;
900902
jl_value_t *stderr_obj = jl_get_global(jl_base_module, jl_symbol("STDERR"));
901903
if (stderr_obj != NULL) return stderr_obj;
902904
return jl_get_global(jl_base_module, jl_symbol("OUTPUT_STREAM"));

src/init.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -543,7 +543,7 @@ DLLEXPORT void jl_atexit_hook()
543543
}
544544
JL_CATCH {
545545
jl_printf(JL_STDERR, "\natexit hook threw an error: ");
546-
jl_show(jl_stderr_obj(),jl_exception_in_transit);
546+
jl_static_show(JL_STDERR, jl_exception_in_transit);
547547
}
548548
}
549549
}
@@ -1060,7 +1060,7 @@ void _julia_init(JL_IMAGE_SEARCH rel)
10601060
}
10611061
JL_CATCH {
10621062
jl_printf(JL_STDERR, "error during init:\n");
1063-
jl_show(jl_stderr_obj(), jl_exception_in_transit);
1063+
jl_static_show(JL_STDERR, jl_exception_in_transit);
10641064
jl_printf(JL_STDERR, "\n");
10651065
jl_exit(1);
10661066
}

0 commit comments

Comments
 (0)