Skip to content

Commit

Permalink
Catch fatal errors during domain creation
Browse files Browse the repository at this point in the history
  • Loading branch information
stedolan committed Jul 14, 2015
1 parent a1a22c6 commit 577c831
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 0 deletions.
2 changes: 2 additions & 0 deletions byterun/domain.c
Expand Up @@ -149,6 +149,7 @@ static void create_domain(uintnat initial_minor_heap_size, int is_main) {
if (d) {
d->running = 1;
d->state.is_main = 0;
d->state.vm_inited = 0;
d->state.internals = d;
/* FIXME: shutdown RPC? */
atomic_store_rel(&d->rpc_request, RPC_IDLE);
Expand Down Expand Up @@ -183,6 +184,7 @@ static void create_domain(uintnat initial_minor_heap_size, int is_main) {
d->state.state = caml_domain_state;
d->state.mark_stack = &caml_mark_stack;
d->state.mark_stack_count = &caml_mark_stack_count;
d->state.vm_inited = 1;
}
caml_plat_unlock(&all_domains_lock);
}
Expand Down
1 change: 1 addition & 0 deletions byterun/domain.h
Expand Up @@ -7,6 +7,7 @@
struct domain {
int id;
int is_main;
int vm_inited;

struct dom_internal* internals;
struct caml_runqueue* runqueue;
Expand Down
4 changes: 4 additions & 0 deletions byterun/fail.c
Expand Up @@ -95,6 +95,10 @@ static value get_exception(int exn, const char* exn_name)
fprintf(stderr, "Fatal error %s during initialisation\n", exn_name);
exit(2);
}
if (caml_domain_self() == 0 || !caml_domain_self()->vm_inited) {
fprintf(stderr, "Fatal error %s during domain creation\n", exn_name);
exit(2);
}
return Field(caml_read_root(caml_global_data), exn);
}

Expand Down

0 comments on commit 577c831

Please sign in to comment.