Skip to content

Commit 52fc796

Browse files
authored
Add missing GC_POP() in emit_cfunction (#53809)
~~Apparently somewhere in codegen inside `emit_codeinst`some piece of code is relying on the implicit try catch gcstack restoring. I haven't got the analyzer working on that file yet (it has hundreds of issues and it doesn't like C++ code that much + the file is tens of thousands of lines after includes so it struggles).~~ This fixes the compileall segfault in apple-aarch64 ci. #53811
1 parent 09400e4 commit 52fc796

File tree

2 files changed

+2
-0
lines changed

2 files changed

+2
-0
lines changed

src/codegen.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7379,6 +7379,7 @@ static jl_cgval_t emit_cfunction(jl_codectx_t &ctx, jl_value_t *output_type, con
73797379
if (ctx.emission_context.TargetTriple.isAArch64() || ctx.emission_context.TargetTriple.isARM() || ctx.emission_context.TargetTriple.isPPC64()) {
73807380
if (nest) {
73817381
emit_error(ctx, "cfunction: closures are not supported on this platform");
7382+
JL_GC_POP();
73827383
return jl_cgval_t();
73837384
}
73847385
}

src/rtutils.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,7 @@ JL_DLLEXPORT void jl_eh_restore_state(jl_task_t *ct, jl_handler_t *eh)
297297

298298
JL_DLLEXPORT void jl_eh_restore_state_noexcept(jl_task_t *ct, jl_handler_t *eh)
299299
{
300+
assert(ct->gcstack == eh->gcstack && "Incorrect GC usage under try catch");
300301
ct->eh = eh->prev;
301302
ct->ptls->defer_signal = eh->defer_signal; // optional, but certain try-finally (in stream.jl) may be slightly harder to write without this
302303
}

0 commit comments

Comments
 (0)