Skip to content

Commit 2623abb

Browse files
gbaraldiKristofferC
authored andcommitted
Enable analyzegc checks for try catch and fix found issues (#53527)
This PR also makes a successful `JL_TRY` not do so much work + fixes clang not finding the sdk when running those tests in macos. Fixes https://github.com/JuliaLang/julia/issues/ Co-authored-by: Cody Tapscott <[email protected]> Co-authored-by: Jameson Nash <[email protected]> (cherry picked from commit 67cdb9b)
1 parent 2e45f8f commit 2623abb

31 files changed

+241
-166
lines changed

Make.inc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1487,7 +1487,7 @@ endif
14871487
CLANGSA_FLAGS :=
14881488
CLANGSA_CXXFLAGS :=
14891489
ifeq ($(OS), Darwin) # on new XCode, the files are hidden
1490-
CLANGSA_FLAGS += -isysroot $(shell xcode-select -p)/Platforms/MacOSX.platform/Developer/SDKs/MacOSX.sdk
1490+
CLANGSA_FLAGS += -isysroot $(shell xcrun --show-sdk-path -sdk macosx)
14911491
endif
14921492
ifeq ($(USEGCC),1)
14931493
# try to help clang find the c++ files for CC by guessing the value for --prefix

base/stream.jl

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,11 @@ function closewrite(s::LibuvStream)
453453
sigatomic_begin()
454454
uv_req_set_data(req, ct)
455455
iolock_end()
456-
status = try
456+
local status
457+
try
457458
sigatomic_end()
458-
wait()::Cint
459+
status = wait()::Cint
460+
sigatomic_begin()
459461
finally
460462
# try-finally unwinds the sigatomic level, so need to repeat sigatomic_end
461463
sigatomic_end()
@@ -1061,12 +1063,14 @@ function uv_write(s::LibuvStream, p::Ptr{UInt8}, n::UInt)
10611063
sigatomic_begin()
10621064
uv_req_set_data(uvw, ct)
10631065
iolock_end()
1064-
status = try
1066+
local status
1067+
try
10651068
sigatomic_end()
10661069
# wait for the last chunk to complete (or error)
10671070
# assume that any errors would be sticky,
10681071
# (so we don't need to monitor the error status of the intermediate writes)
1069-
wait()::Cint
1072+
status = wait()::Cint
1073+
sigatomic_begin()
10701074
finally
10711075
# try-finally unwinds the sigatomic level, so need to repeat sigatomic_end
10721076
sigatomic_end()

doc/src/devdocs/ast.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ These symbols appear in the `head` field of [`Expr`](@ref)s in lowered form.
431431

432432
* `the_exception`
433433

434-
Yields the caught exception inside a `catch` block, as returned by `jl_current_exception()`.
434+
Yields the caught exception inside a `catch` block, as returned by `jl_current_exception(ct)`.
435435

436436
* `enter`
437437

src/ast.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -475,7 +475,7 @@ static jl_value_t *scm_to_julia(fl_context_t *fl_ctx, value_t e, jl_module_t *mo
475475
}
476476
JL_CATCH {
477477
// if expression cannot be converted, replace with error expr
478-
//jl_(jl_current_exception());
478+
//jl_(jl_current_exception(ct));
479479
//jlbacktrace();
480480
jl_expr_t *ex = jl_exprn(jl_error_sym, 1);
481481
v = (jl_value_t*)ex;
@@ -1151,7 +1151,7 @@ static jl_value_t *jl_invoke_julia_macro(jl_array_t *args, jl_module_t *inmodule
11511151
margs[0] = jl_cstr_to_string("<macrocall>");
11521152
margs[1] = jl_fieldref(lno, 0); // extract and allocate line number
11531153
jl_rethrow_other(jl_new_struct(jl_loaderror_type, margs[0], margs[1],
1154-
jl_current_exception()));
1154+
jl_current_exception(ct)));
11551155
}
11561156
}
11571157
ct->world_age = last_age;

src/ccall.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1613,7 +1613,7 @@ static jl_cgval_t emit_ccall(jl_codectx_t &ctx, jl_value_t **args, size_t nargs)
16131613
assert(lrt == ctx.types().T_prjlvalue);
16141614
assert(!isVa && !llvmcall && nccallargs == 0);
16151615
JL_GC_POP();
1616-
auto ct = track_pjlvalue(ctx, emit_bitcast(ctx, get_current_task(ctx), ctx.types().T_pjlvalue));
1616+
auto ct = track_pjlvalue(ctx, get_current_task(ctx));
16171617
return mark_or_box_ccall_result(ctx, ct, retboxed, rt, unionall, static_rt);
16181618
}
16191619
else if (is_libjulia_func(jl_set_next_task)) {

src/codegen.cpp

Lines changed: 67 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1048,30 +1048,64 @@ static const auto jlunlockfield_func = new JuliaFunction<>{
10481048
};
10491049
static const auto jlenter_func = new JuliaFunction<>{
10501050
XSTR(jl_enter_handler),
1051-
[](LLVMContext &C) { return FunctionType::get(getVoidTy(C),
1052-
{getInt8PtrTy(C)}, false); },
1051+
[](LLVMContext &C) {
1052+
auto T_pjlvalue = JuliaType::get_pjlvalue_ty(C);
1053+
return FunctionType::get(getVoidTy(C),
1054+
{T_pjlvalue, getInt8PtrTy(C)}, false); },
10531055
nullptr,
10541056
};
10551057
static const auto jl_current_exception_func = new JuliaFunction<>{
10561058
XSTR(jl_current_exception),
1057-
[](LLVMContext &C) { return FunctionType::get(JuliaType::get_prjlvalue_ty(C), false); },
1059+
[](LLVMContext &C) { return FunctionType::get(JuliaType::get_prjlvalue_ty(C), {JuliaType::get_pjlvalue_ty(C)}, false); },
10581060
nullptr,
10591061
};
10601062
static const auto jlleave_func = new JuliaFunction<>{
10611063
XSTR(jl_pop_handler),
1062-
[](LLVMContext &C) { return FunctionType::get(getVoidTy(C),
1063-
{getInt32Ty(C)}, false); },
1064-
nullptr,
1064+
[](LLVMContext &C) {
1065+
auto T_pjlvalue = JuliaType::get_pjlvalue_ty(C);
1066+
return FunctionType::get(getVoidTy(C),
1067+
{T_pjlvalue, getInt32Ty(C)}, false); },
1068+
[](LLVMContext &C) {
1069+
auto FnAttrs = AttrBuilder(C);
1070+
FnAttrs.addAttribute(Attribute::WillReturn);
1071+
FnAttrs.addAttribute(Attribute::NoUnwind);
1072+
auto RetAttrs = AttrBuilder(C);
1073+
return AttributeList::get(C,
1074+
AttributeSet::get(C, FnAttrs),
1075+
AttributeSet(),
1076+
None);
1077+
},
1078+
};
1079+
static const auto jlleave_noexcept_func = new JuliaFunction<>{
1080+
XSTR(jl_pop_handler_noexcept),
1081+
[](LLVMContext &C) {
1082+
auto T_pjlvalue = JuliaType::get_pjlvalue_ty(C);
1083+
return FunctionType::get(getVoidTy(C),
1084+
{T_pjlvalue, getInt32Ty(C)}, false); },
1085+
[](LLVMContext &C) {
1086+
auto FnAttrs = AttrBuilder(C);
1087+
FnAttrs.addAttribute(Attribute::WillReturn);
1088+
FnAttrs.addAttribute(Attribute::NoUnwind);
1089+
auto RetAttrs = AttrBuilder(C);
1090+
return AttributeList::get(C,
1091+
AttributeSet::get(C, FnAttrs),
1092+
AttributeSet(),
1093+
None);
1094+
},
10651095
};
10661096
static const auto jl_restore_excstack_func = new JuliaFunction<TypeFnContextAndSizeT>{
10671097
XSTR(jl_restore_excstack),
1068-
[](LLVMContext &C, Type *T_size) { return FunctionType::get(getVoidTy(C),
1069-
{T_size}, false); },
1098+
[](LLVMContext &C, Type *T_size) {
1099+
auto T_pjlvalue = JuliaType::get_pjlvalue_ty(C);
1100+
return FunctionType::get(getVoidTy(C),
1101+
{T_pjlvalue, T_size}, false); },
10701102
nullptr,
10711103
};
10721104
static const auto jl_excstack_state_func = new JuliaFunction<TypeFnContextAndSizeT>{
10731105
XSTR(jl_excstack_state),
1074-
[](LLVMContext &C, Type *T_size) { return FunctionType::get(T_size, false); },
1106+
[](LLVMContext &C, Type *T_size) {
1107+
auto T_pjlvalue = JuliaType::get_pjlvalue_ty(C);
1108+
return FunctionType::get(T_size, {T_pjlvalue}, false); },
10751109
nullptr,
10761110
};
10771111
static const auto jlegalx_func = new JuliaFunction<TypeFnContextAndSizeT>{
@@ -1098,9 +1132,9 @@ static const auto jl_alloc_obj_func = new JuliaFunction<TypeFnContextAndSizeT>{
10981132
[](LLVMContext &C, Type *T_size) {
10991133
auto T_jlvalue = JuliaType::get_jlvalue_ty(C);
11001134
auto T_prjlvalue = PointerType::get(T_jlvalue, AddressSpace::Tracked);
1101-
auto T_ppjlvalue = PointerType::get(PointerType::get(T_jlvalue, 0), 0);
1135+
auto T_pjlvalue = PointerType::get(T_jlvalue, 0);
11021136
return FunctionType::get(T_prjlvalue,
1103-
{T_ppjlvalue, T_size, T_prjlvalue}, false);
1137+
{T_pjlvalue, T_size, T_prjlvalue}, false);
11041138
},
11051139
[](LLVMContext &C) {
11061140
auto FnAttrs = AttrBuilder(C);
@@ -1442,7 +1476,9 @@ static const auto gc_preserve_end_func = new JuliaFunction<> {
14421476
};
14431477
static const auto except_enter_func = new JuliaFunction<>{
14441478
"julia.except_enter",
1445-
[](LLVMContext &C) { return FunctionType::get(getInt32Ty(C), false); },
1479+
[](LLVMContext &C) {
1480+
auto T_pjlvalue = JuliaType::get_pjlvalue_ty(C);
1481+
return FunctionType::get(getInt32Ty(C), {T_pjlvalue}, false); },
14461482
[](LLVMContext &C) { return AttributeList::get(C,
14471483
Attributes(C, {Attribute::ReturnsTwice}),
14481484
AttributeSet(),
@@ -5957,8 +5993,7 @@ static void emit_stmtpos(jl_codectx_t &ctx, jl_value_t *expr, int ssaval_result)
59575993
hand_n_leave += 1;
59585994
}
59595995
}
5960-
ctx.builder.CreateCall(prepare_call(jlleave_func),
5961-
ConstantInt::get(getInt32Ty(ctx.builder.getContext()), hand_n_leave));
5996+
ctx.builder.CreateCall(prepare_call(jlleave_noexcept_func), {get_current_task(ctx), ConstantInt::get(getInt32Ty(ctx.builder.getContext()), hand_n_leave)});
59625997
if (scope_to_restore) {
59635998
jl_aliasinfo_t scope_ai = jl_aliasinfo_t::fromTBAA(ctx, ctx.tbaa().tbaa_gcframe);
59645999
scope_ai.decorateInst(
@@ -5968,7 +6003,7 @@ static void emit_stmtpos(jl_codectx_t &ctx, jl_value_t *expr, int ssaval_result)
59686003
else if (head == jl_pop_exception_sym) {
59696004
jl_cgval_t excstack_state = emit_expr(ctx, jl_exprarg(expr, 0));
59706005
assert(excstack_state.V && excstack_state.V->getType() == ctx.types().T_size);
5971-
ctx.builder.CreateCall(prepare_call(jl_restore_excstack_func), excstack_state.V);
6006+
ctx.builder.CreateCall(prepare_call(jl_restore_excstack_func), {get_current_task(ctx), excstack_state.V});
59726007
return;
59736008
}
59746009
else {
@@ -6199,7 +6234,7 @@ static jl_cgval_t emit_expr(jl_codectx_t &ctx, jl_value_t *expr, ssize_t ssaidx_
61996234
bnd = jl_get_binding_for_method_def(mod, (jl_sym_t*)mn);
62006235
}
62016236
JL_CATCH {
6202-
jl_value_t *e = jl_current_exception();
6237+
jl_value_t *e = jl_current_exception(jl_current_task);
62036238
// errors. boo. :(
62046239
JL_GC_PUSH1(&e);
62056240
e = jl_as_global_root(e, 1);
@@ -6375,7 +6410,7 @@ static jl_cgval_t emit_expr(jl_codectx_t &ctx, jl_value_t *expr, ssize_t ssaidx_
63756410
else if (head == jl_exc_sym) {
63766411
assert(nargs == 0);
63776412
return mark_julia_type(ctx,
6378-
ctx.builder.CreateCall(prepare_call(jl_current_exception_func)),
6413+
ctx.builder.CreateCall(prepare_call(jl_current_exception_func), {get_current_task(ctx)}),
63796414
true, jl_any_type);
63806415
}
63816416
else if (head == jl_copyast_sym) {
@@ -6479,9 +6514,14 @@ static void allocate_gc_frame(jl_codectx_t &ctx, BasicBlock *b0, bool or_new=fal
64796514
ctx.pgcstack->setName("pgcstack");
64806515
}
64816516

6517+
static Value *get_current_task(jl_codectx_t &ctx, Type *T)
6518+
{
6519+
return emit_bitcast(ctx, get_current_task_from_pgcstack(ctx.builder, ctx.types().T_size, ctx.pgcstack), T);
6520+
}
6521+
64826522
static Value *get_current_task(jl_codectx_t &ctx)
64836523
{
6484-
return get_current_task_from_pgcstack(ctx.builder, ctx.types().T_size, ctx.pgcstack);
6524+
return get_current_task(ctx, ctx.types().T_pjlvalue);
64856525
}
64866526

64876527
// Get PTLS through current task.
@@ -6493,20 +6533,20 @@ static Value *get_current_ptls(jl_codectx_t &ctx)
64936533
// Get the address of the world age of the current task
64946534
static Value *get_last_age_field(jl_codectx_t &ctx)
64956535
{
6496-
Value *ct = get_current_task(ctx);
6536+
Value *ct = get_current_task(ctx, ctx.types().T_size->getPointerTo());
64976537
return ctx.builder.CreateInBoundsGEP(
64986538
ctx.types().T_size,
6499-
ctx.builder.CreateBitCast(ct, ctx.types().T_size->getPointerTo()),
6539+
ct,
65006540
ConstantInt::get(ctx.types().T_size, offsetof(jl_task_t, world_age) / ctx.types().sizeof_ptr),
65016541
"world_age");
65026542
}
65036543

65046544
static Value *get_scope_field(jl_codectx_t &ctx)
65056545
{
6506-
Value *ct = get_current_task(ctx);
6546+
Value *ct = get_current_task(ctx, ctx.types().T_prjlvalue->getPointerTo());
65076547
return ctx.builder.CreateInBoundsGEP(
65086548
ctx.types().T_prjlvalue,
6509-
ctx.builder.CreateBitCast(ct, ctx.types().T_prjlvalue->getPointerTo()),
6549+
ct,
65106550
ConstantInt::get(ctx.types().T_size, offsetof(jl_task_t, scope) / ctx.types().sizeof_ptr),
65116551
"current_scope");
65126552
}
@@ -9119,12 +9159,12 @@ static jl_llvm_functions_t
91199159
if (lname) {
91209160
// Save exception stack depth at enter for use in pop_exception
91219161
Value *excstack_state =
9122-
ctx.builder.CreateCall(prepare_call(jl_excstack_state_func));
9162+
ctx.builder.CreateCall(prepare_call(jl_excstack_state_func), {get_current_task(ctx)});
91239163
assert(!ctx.ssavalue_assigned[cursor]);
91249164
ctx.SAvalues[cursor] = jl_cgval_t(excstack_state, (jl_value_t*)jl_ulong_type, NULL);
91259165
ctx.ssavalue_assigned[cursor] = true;
91269166
// Actually enter the exception frame
9127-
CallInst *sj = ctx.builder.CreateCall(prepare_call(except_enter_func));
9167+
CallInst *sj = ctx.builder.CreateCall(prepare_call(except_enter_func), {get_current_task(ctx)});
91289168
// We need to mark this on the call site as well. See issue #6757
91299169
sj->setCanReturnTwice();
91309170
Value *isz = ctx.builder.CreateICmpEQ(sj, ConstantInt::get(getInt32Ty(ctx.builder.getContext()), 0));
@@ -9137,8 +9177,7 @@ static jl_llvm_functions_t
91379177
ctx.builder.CreateCondBr(isz, tryblk, catchpop);
91389178
ctx.builder.SetInsertPoint(catchpop);
91399179
{
9140-
ctx.builder.CreateCall(prepare_call(jlleave_func),
9141-
ConstantInt::get(getInt32Ty(ctx.builder.getContext()), 1));
9180+
ctx.builder.CreateCall(prepare_call(jlleave_func), {get_current_task(ctx), ConstantInt::get(getInt32Ty(ctx.builder.getContext()), 1)});
91429181
if (old_scope) {
91439182
scope_ai.decorateInst(
91449183
ctx.builder.CreateAlignedStore(old_scope, scope_ptr, ctx.types().alignof_ptr));
@@ -9504,7 +9543,7 @@ jl_llvm_functions_t jl_emit_code(
95049543
decls.functionObject = "";
95059544
decls.specFunctionObject = "";
95069545
jl_printf((JL_STREAM*)STDERR_FILENO, "Internal error: encountered unexpected error during compilation of %s:\n", mname.c_str());
9507-
jl_static_show((JL_STREAM*)STDERR_FILENO, jl_current_exception());
9546+
jl_static_show((JL_STREAM*)STDERR_FILENO, jl_current_exception(jl_current_task));
95089547
jl_printf((JL_STREAM*)STDERR_FILENO, "\n");
95099548
jlbacktrace(); // written to STDERR_FILENO
95109549
#ifndef JL_NDEBUG
@@ -9816,6 +9855,7 @@ static void init_jit_functions(void)
98169855
add_named_global(jlgenericfunction_func, &jl_generic_function_def);
98179856
add_named_global(jlenter_func, &jl_enter_handler);
98189857
add_named_global(jl_current_exception_func, &jl_current_exception);
9858+
add_named_global(jlleave_noexcept_func, &jl_pop_handler_noexcept);
98199859
add_named_global(jlleave_func, &jl_pop_handler);
98209860
add_named_global(jl_restore_excstack_func, &jl_restore_excstack);
98219861
add_named_global(jl_excstack_state_func, &jl_excstack_state);

src/gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -301,7 +301,7 @@ static void run_finalizer(jl_task_t *ct, void *o, void *ff)
301301
}
302302
JL_CATCH {
303303
jl_printf((JL_STREAM*)STDERR_FILENO, "error in running finalizer: ");
304-
jl_static_show((JL_STREAM*)STDERR_FILENO, jl_current_exception());
304+
jl_static_show((JL_STREAM*)STDERR_FILENO, jl_current_exception(ct));
305305
jl_printf((JL_STREAM*)STDERR_FILENO, "\n");
306306
jlbacktrace(); // written to STDERR_FILENO
307307
}

src/gf.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ void jl_call_tracer(tracer_cb callback, jl_value_t *tracee)
9595
JL_CATCH {
9696
ct->ptls->in_pure_callback = last_in;
9797
jl_printf((JL_STREAM*)STDERR_FILENO, "WARNING: tracer callback function threw an error:\n");
98-
jl_static_show((JL_STREAM*)STDERR_FILENO, jl_current_exception());
98+
jl_static_show((JL_STREAM*)STDERR_FILENO, jl_current_exception(ct));
9999
jl_printf((JL_STREAM*)STDERR_FILENO, "\n");
100100
jlbacktrace(); // written to STDERR_FILENO
101101
}
@@ -390,7 +390,7 @@ jl_code_info_t *jl_type_infer(jl_method_instance_t *mi, size_t world, int force)
390390
src = (jl_code_info_t*)jl_apply(fargs, 3);
391391
}
392392
JL_CATCH {
393-
jl_value_t *e = jl_current_exception();
393+
jl_value_t *e = jl_current_exception(ct);
394394
jl_printf((JL_STREAM*)STDERR_FILENO, "Internal error: during type inference of\n");
395395
jl_static_show_func_sig((JL_STREAM*)STDERR_FILENO, (jl_value_t*)mi->specTypes);
396396
jl_printf((JL_STREAM*)STDERR_FILENO, "\nEncountered ");

src/init.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ JL_DLLEXPORT void jl_atexit_hook(int exitcode) JL_NOTSAFEPOINT_ENTER
273273
}
274274
JL_CATCH {
275275
jl_printf((JL_STREAM*)STDERR_FILENO, "\natexit hook threw an error: ");
276-
jl_static_show((JL_STREAM*)STDERR_FILENO, jl_current_exception());
276+
jl_static_show((JL_STREAM*)STDERR_FILENO, jl_current_exception(ct));
277277
jl_printf((JL_STREAM*)STDERR_FILENO, "\n");
278278
jlbacktrace(); // written to STDERR_FILENO
279279
}
@@ -317,7 +317,7 @@ JL_DLLEXPORT void jl_atexit_hook(int exitcode) JL_NOTSAFEPOINT_ENTER
317317
assert(item);
318318
uv_unref(item->h);
319319
jl_printf((JL_STREAM*)STDERR_FILENO, "error during exit cleanup: close: ");
320-
jl_static_show((JL_STREAM*)STDERR_FILENO, jl_current_exception());
320+
jl_static_show((JL_STREAM*)STDERR_FILENO, jl_current_exception(ct));
321321
jl_printf((JL_STREAM*)STDERR_FILENO, "\n");
322322
jlbacktrace(); // written to STDERR_FILENO
323323
item = next_shutdown_queue_item(item);
@@ -372,7 +372,7 @@ JL_DLLEXPORT void jl_postoutput_hook(void)
372372
}
373373
JL_CATCH {
374374
jl_printf((JL_STREAM*)STDERR_FILENO, "\npostoutput hook threw an error: ");
375-
jl_static_show((JL_STREAM*)STDERR_FILENO, jl_current_exception());
375+
jl_static_show((JL_STREAM*)STDERR_FILENO, jl_current_exception(ct));
376376
jl_printf((JL_STREAM*)STDERR_FILENO, "\n");
377377
jlbacktrace(); // written to STDERR_FILENO
378378
}

src/interpreter.c

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@ static jl_value_t *eval_value(jl_value_t *e, interpreter_state *s)
317317
return jl_copy_ast(eval_value(args[0], s));
318318
}
319319
else if (head == jl_exc_sym) {
320-
return jl_current_exception();
320+
return jl_current_exception(jl_current_task);
321321
}
322322
else if (head == jl_boundscheck_sym) {
323323
return jl_true;
@@ -490,7 +490,7 @@ static jl_value_t *eval_body(jl_array_t *stmts, interpreter_state *s, size_t ip,
490490
s->locals[jl_source_nslots(s->src) + id] = val;
491491
}
492492
else if (jl_is_enternode(stmt)) {
493-
jl_enter_handler(&__eh);
493+
jl_enter_handler(ct, &__eh);
494494
// This is a bit tricky, but supports the implementation of PhiC nodes.
495495
// They are conceptually slots, but the slot to store to doesn't get explicitly
496496
// mentioned in the store (aka the "UpsilonNode") (this makes them integrate more
@@ -521,7 +521,7 @@ static jl_value_t *eval_body(jl_array_t *stmts, interpreter_state *s, size_t ip,
521521
}
522522
// store current top of exception stack for restore in pop_exception.
523523
}
524-
s->locals[jl_source_nslots(s->src) + ip] = jl_box_ulong(jl_excstack_state());
524+
s->locals[jl_source_nslots(s->src) + ip] = jl_box_ulong(jl_excstack_state(ct));
525525
if (jl_enternode_scope(stmt)) {
526526
jl_value_t *old_scope = ct->scope;
527527
JL_GC_PUSH1(&old_scope);
@@ -540,13 +540,15 @@ static jl_value_t *eval_body(jl_array_t *stmts, interpreter_state *s, size_t ip,
540540
jl_unreachable();
541541
}
542542
}
543-
jl_eh_restore_state(&__eh);
543+
544544
if (s->continue_at) { // means we reached a :leave expression
545+
jl_eh_restore_state_noexcept(ct, &__eh);
545546
ip = s->continue_at;
546547
s->continue_at = 0;
547548
continue;
548549
}
549550
else { // a real exception
551+
jl_eh_restore_state(ct, &__eh);
550552
ip = catch_ip;
551553
assert(jl_enternode_catch_dest(stmt) != 0);
552554
continue;
@@ -609,7 +611,7 @@ static jl_value_t *eval_body(jl_array_t *stmts, interpreter_state *s, size_t ip,
609611
}
610612
else if (head == jl_pop_exception_sym) {
611613
size_t prev_state = jl_unbox_ulong(eval_value(jl_exprarg(stmt, 0), s));
612-
jl_restore_excstack(prev_state);
614+
jl_restore_excstack(ct, prev_state);
613615
}
614616
else if (toplevel) {
615617
if (head == jl_method_sym && jl_expr_nargs(stmt) > 1) {

0 commit comments

Comments
 (0)