Skip to content

Commit

Permalink
Reset bt_size if we saved the bt in an array
Browse files Browse the repository at this point in the history
  • Loading branch information
Keno committed Oct 9, 2017
1 parent 7993011 commit 4476c1b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions src/gc.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,15 +196,17 @@ static void jl_gc_run_finalizers_in_list(jl_ptls_t ptls, arraylist_t *list)
jl_array_t *bt = NULL;
jl_array_t *bt2 = NULL;
JL_GC_PUSH3(&exc, &bt, &bt2);
if (ptls->bt_size > 0)
if (ptls->bt_size > 0) {
jl_get_backtrace(&bt, &bt2);
ptls->bt_size = 0;
}
for (size_t i = 2;i < len;i += 2)
run_finalizer(ptls, items[i], items[i + 1]);
ptls->exception_in_transit = exc;
if (bt != NULL) {
// This is sufficient because bt2 roots the managed values
ptls->bt_size = jl_array_len(bt);
memcpy(ptls->bt_data, bt->data, ptls->bt_size * sizeof(void*));
ptls->bt_size = jl_array_len(bt);
}
JL_GC_POP();
// matches the jl_gc_push_arraylist above
Expand Down
6 changes: 4 additions & 2 deletions src/rtutils.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,10 @@ JL_DLLEXPORT jl_value_t *jl_apply_with_saved_exception_state(jl_value_t **args,
jl_array_t *bt = NULL;
jl_array_t *bt2 = NULL;
JL_GC_PUSH3(&exc, &bt, &bt2);
if (ptls->bt_size > 0)
if (ptls->bt_size > 0) {
jl_get_backtrace(&bt, &bt2);
ptls->bt_size = 0;
}
jl_value_t *v;
JL_TRY {
v = jl_apply(args, nargs);
Expand All @@ -261,8 +263,8 @@ JL_DLLEXPORT jl_value_t *jl_apply_with_saved_exception_state(jl_value_t **args,
ptls->exception_in_transit = exc;
if (bt != NULL) {
// This is sufficient because bt2 roots the gc-managed values
ptls->bt_size = jl_array_len(bt);
memcpy(ptls->bt_data, bt->data, ptls->bt_size * sizeof(void*));
ptls->bt_size = jl_array_len(bt);
}
JL_GC_POP();
return v;
Expand Down

0 comments on commit 4476c1b

Please sign in to comment.