diff --git a/src/ast.c b/src/ast.c index 17977f6f0e9de..024956122fe07 100644 --- a/src/ast.c +++ b/src/ast.c @@ -299,7 +299,7 @@ static jl_ast_context_t *jl_ast_ctx_enter(void) JL_GLOBALLY_ROOTED JL_NOTSAFEPOI return ctx; } -static void jl_ast_ctx_leave(jl_ast_context_t *ctx) JL_NOTSAFEPOINT +static void jl_ast_ctx_leave(jl_ast_context_t *ctx) { JL_SIGATOMIC_END(); if (--ctx->ref) @@ -850,8 +850,10 @@ jl_value_t *jl_call_scm_on_ast(const char *funcname, jl_value_t *expr, jl_module value_t arg = julia_to_scm(fl_ctx, expr); value_t e = fl_applyn(fl_ctx, 1, symbol_value(symbol(fl_ctx, funcname)), arg); jl_value_t *result = scm_to_julia(fl_ctx, e, inmodule); + JL_GC_PUSH1(&result); JL_AST_PRESERVE_POP(ctx, old_roots); jl_ast_ctx_leave(ctx); + JL_GC_POP(); return result; } @@ -865,8 +867,10 @@ jl_value_t *jl_call_scm_on_ast_and_loc(const char *funcname, jl_value_t *expr, j value_t e = fl_applyn(fl_ctx, 3, symbol_value(symbol(fl_ctx, funcname)), arg, symbol(fl_ctx, file), fixnum(line)); jl_value_t *result = scm_to_julia(fl_ctx, e, inmodule); + JL_GC_PUSH1(&result); JL_AST_PRESERVE_POP(ctx, old_roots); jl_ast_ctx_leave(ctx); + JL_GC_POP(); return result; } diff --git a/src/julia_threads.h b/src/julia_threads.h index c3d9424a629c6..918a6b25d6c72 100644 --- a/src/julia_threads.h +++ b/src/julia_threads.h @@ -274,6 +274,11 @@ extern "C" { JL_DLLEXPORT void (jl_cpu_pause)(void); JL_DLLEXPORT void (jl_cpu_wake)(void); +#ifdef __clang_analyzer__ +// Note that the sigint safepoint can also trigger GC, albeit less likely +void jl_gc_safepoint_(jl_ptls_t tls); +void jl_sigint_safepoint(jl_ptls_t tls); +#else // gc safepoint and gc states // This triggers a SegFault when we are in GC // Assign it to a variable to make sure the compiler emit the load @@ -284,11 +289,6 @@ JL_DLLEXPORT void (jl_cpu_wake)(void); jl_signal_fence(); \ (void)safepoint_load; \ } while (0) -#ifdef __clang_analyzer__ -// This is a sigint safepoint, not a GC safepoint (which -// JL_NOTSAFEPOINT refers to) -void jl_sigint_safepoint(jl_ptls_t tls) JL_NOTSAFEPOINT; -#else #define jl_sigint_safepoint(ptls) do { \ jl_signal_fence(); \ size_t safepoint_load = ptls->safepoint[-1]; \