Skip to content

Commit

Permalink
fix JL_GC_PUSH calls in the new BoundsError calls. should fix those p…
Browse files Browse the repository at this point in the history
…esky intermittent CI errors that have occurred recently.
  • Loading branch information
vtjnash committed Jan 4, 2015
1 parent eeef618 commit 3b350f1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
14 changes: 9 additions & 5 deletions src/builtins.c
Original file line number Diff line number Diff line change
Expand Up @@ -102,27 +102,31 @@ DLLEXPORT void NORETURN jl_undefined_var_error(jl_sym_t *var)

DLLEXPORT void NORETURN jl_bounds_error(jl_value_t *v, jl_value_t *t)
{
JL_GC_PUSH2(v, t); // root arguments so the caller doesn't need to
JL_GC_PUSH2(&v, &t); // root arguments so the caller doesn't need to
jl_throw(jl_new_struct((jl_datatype_t*)jl_boundserror_type, v, t));
}

DLLEXPORT void NORETURN jl_bounds_error_v(jl_value_t *v, jl_value_t **idxs, size_t nidxs)
{
jl_tuple_t *t = NULL;
JL_GC_PUSH2(v, t); // root arguments so the caller doesn't need to
// items in idxs are assumed to already be rooted
JL_GC_PUSH2(&v, &t); // root v so the caller doesn't need to
t = jl_tuplev(nidxs, idxs);
jl_throw(jl_new_struct((jl_datatype_t*)jl_boundserror_type, v, t));
}

DLLEXPORT void NORETURN jl_bounds_error_tuple_int(jl_value_t **v, size_t nv, size_t i)
{
// values in v are expected to already be gc-rooted
jl_bounds_error_int((jl_value_t*)jl_tuplev(nv, v), i);
}

DLLEXPORT void NORETURN jl_bounds_error_unboxed_int(void *data, jl_value_t *vt, size_t i)
{
jl_value_t *t = NULL, *v = NULL;
JL_GC_PUSH2(v, t);
// data is expected to be gc-safe (either gc-rooted, or alloca)
// vt is expected to be gc-rooted (in a linfo-root probably)
JL_GC_PUSH2(&v, &t);
v = jl_new_bits(vt, data);
t = jl_box_long(i);
jl_throw(jl_new_struct((jl_datatype_t*)jl_boundserror_type, v, t));
Expand All @@ -131,7 +135,7 @@ DLLEXPORT void NORETURN jl_bounds_error_unboxed_int(void *data, jl_value_t *vt,
DLLEXPORT void NORETURN jl_bounds_error_int(jl_value_t *v, size_t i)
{
jl_value_t *t = NULL;
JL_GC_PUSH2(v, t); // root arguments so the caller doesn't need to
JL_GC_PUSH2(&v, &t); // root arguments so the caller doesn't need to
t = jl_box_long(i);
jl_throw(jl_new_struct((jl_datatype_t*)jl_boundserror_type, v, t));
}
Expand All @@ -140,7 +144,7 @@ DLLEXPORT void NORETURN jl_bounds_error_ints(jl_value_t *v, size_t *idxs, size_t
{
size_t i;
jl_tuple_t *t = NULL;
JL_GC_PUSH2(v, t); // root arguments so the caller doesn't need to
JL_GC_PUSH2(&v, &t); // root arguments so the caller doesn't need to
t = jl_alloc_tuple(nidxs);
for (i = 0; i < nidxs; i++) {
jl_tupleset(t, i, jl_box_long(idxs[i]));
Expand Down
8 changes: 3 additions & 5 deletions test/core.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2022,11 +2022,9 @@ let x = [1,2,3]
end

# sig 2 is SIGINT per the POSIX.1-1990 standard
if Base.is_unix(OS_NAME)
ccall(:jl_exit_on_sigint, Void, (Cint,), 0)
@test_throws InterruptException ccall(:raise, Void, (Cint,), 2)
ccall(:jl_exit_on_sigint, Void, (Cint,), 1)
end
ccall(:jl_exit_on_sigint, Void, (Cint,), 0)
@test_throws InterruptException ccall(:raise, Void, (Cint,), 2)
ccall(:jl_exit_on_sigint, Void, (Cint,), 1)

# pull request #9534
@test try; a,b,c = 1,2; catch ex; (ex::BoundsError).a === (1,2) && ex.i == 3; end
Expand Down

5 comments on commit 3b350f1

@tkelman
Copy link
Contributor

@tkelman tkelman commented on 3b350f1 Jan 4, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@tkelman
Copy link
Contributor

@tkelman tkelman commented on 3b350f1 Jan 4, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah i'm pretty sure this test should still be @unix_only for now, we didn't resolve the undefined behavior from msdn right?

@vtjnash
Copy link
Member Author

@vtjnash vtjnash commented on 3b350f1 Jan 4, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so it would seem (for win32 anyways). i don't see anything particular in the implementation of msvcrt!raise. but looking at the backtrace of the error it appears to be corrupting some state in the windows kernel (ntdll!KiUserExceptionDispatcher) which causes issues with a gmp SIGFPE later.

@tkelman
Copy link
Contributor

@tkelman tkelman commented on 3b350f1 Jan 4, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay yeah that makes sense, in gdb it was going nuts right at that sigfpe

@tkelman
Copy link
Contributor

@tkelman tkelman commented on 3b350f1 Jan 4, 2015

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ouch, win64 still segfaulting even with this fix and the test disabled: https://ci.appveyor.com/project/StefanKarpinski/julia/build/1.0.1161/job/cwtb2fxvgnf1400s

Please sign in to comment.