Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix bad precompile statements via an output lock #44252

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/gf.c
Original file line number Diff line number Diff line change
Expand Up @@ -1970,6 +1970,8 @@ jl_code_instance_t *jl_method_compiled(jl_method_instance_t *mi, size_t world)
return NULL;
}

jl_mutex_t precomp_statement_out_lock;

static void record_precompile_statement(jl_method_instance_t *mi)
{
static ios_t f_precompile;
Expand All @@ -1980,6 +1982,8 @@ static void record_precompile_statement(jl_method_instance_t *mi)
if (!jl_is_method(def))
return;

if (jl_n_threads > 1)
JL_LOCK(&precomp_statement_out_lock);
if (s_precompile == NULL) {
const char *t = jl_options.trace_compile;
if (!strncmp(t, "stderr", 6)) {
Expand All @@ -1998,6 +2002,8 @@ static void record_precompile_statement(jl_method_instance_t *mi)
if (s_precompile != JL_STDERR)
ios_flush(&f_precompile);
}
if (jl_n_threads > 1)
JL_UNLOCK(&precomp_statement_out_lock);
}

jl_code_instance_t *jl_compile_method_internal(jl_method_instance_t *mi, size_t world)
Expand Down