Skip to content

Commit

Permalink
avoid segfault in jl_show during bootstrap
Browse files Browse the repository at this point in the history
rename ios_printf => JL_PRINTF etc.
  • Loading branch information
JeffBezanson committed Jul 30, 2012
1 parent 08b34f6 commit aa029e3
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/ast.c
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ value_t fl_invoke_julia_macro(value_t *args, uint32_t nargs)
JL_CATCH {
JL_GC_POP();
jl_show(jl_stderr_obj(), jl_exception_in_transit);
ios_putc('\n', ios_stderr);
JL_PUTC('\n', JL_STDERR);
return fl_cons(symbol("error"), FL_NIL);
}
// protect result from GC, otherwise it could be freed during future
Expand Down
6 changes: 6 additions & 0 deletions src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -551,6 +551,12 @@ void jl_show(jl_value_t *stream, jl_value_t *v)
if (jl_show_gf == NULL) {
jl_show_gf = (jl_function_t*)jl_get_global(jl_base_module, jl_symbol("show"));
}
if (jl_show_gf==NULL || stream==NULL) {
JL_PRINTF(JL_STDERR, "could not show value of type %s",
jl_is_tuple(v) ? "Tuple" :
((jl_tag_type_t*)jl_typeof(v))->name->name->name);
return;
}
jl_value_t *args[2] = {stream,v};
jl_apply(jl_show_gf, args, 2);
}
Expand Down
4 changes: 2 additions & 2 deletions src/codegen.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -221,8 +221,8 @@ const jl_value_t *jl_dump_function(jl_function_t *f, jl_tuple_t *types)
sf = jl_method_lookup_by_type(jl_gf_mtable(f), types, 0);
if (sf == jl_bottom_func)
return jl_cstr_to_string((char*)"");
ios_printf(ios_stderr,
"Warning: Returned code may not match what actually runs.\n");
JL_PRINTF(JL_STDERR,
"Warning: Returned code may not match what actually runs.\n");
}
std::string code;
llvm::raw_string_ostream stream(code);
Expand Down
2 changes: 1 addition & 1 deletion src/task.c
Original file line number Diff line number Diff line change
Expand Up @@ -540,7 +540,7 @@ void jl_raise(jl_value_t *e)
else {
if (eh->done==jl_true || eh->state.eh_ctx==NULL) {
// our handler is not available, use root task
ios_printf(ios_stderr, "warning: exception handler exited\n");
JL_PRINTF(JL_STDERR, "warning: exception handler exited\n");
eh = jl_root_task;
}
// for now, exit the task
Expand Down

0 comments on commit aa029e3

Please sign in to comment.