Skip to content

Commit c5bc69c

Browse files
Fix bad precompile statements via an output lock (#44252)
1 parent ac922b0 commit c5bc69c

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/gf.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1970,6 +1970,8 @@ jl_code_instance_t *jl_method_compiled(jl_method_instance_t *mi, size_t world)
19701970
return NULL;
19711971
}
19721972

1973+
jl_mutex_t precomp_statement_out_lock;
1974+
19731975
static void record_precompile_statement(jl_method_instance_t *mi)
19741976
{
19751977
static ios_t f_precompile;
@@ -1980,6 +1982,8 @@ static void record_precompile_statement(jl_method_instance_t *mi)
19801982
if (!jl_is_method(def))
19811983
return;
19821984

1985+
if (jl_n_threads > 1)
1986+
JL_LOCK(&precomp_statement_out_lock);
19831987
if (s_precompile == NULL) {
19841988
const char *t = jl_options.trace_compile;
19851989
if (!strncmp(t, "stderr", 6)) {
@@ -1998,6 +2002,8 @@ static void record_precompile_statement(jl_method_instance_t *mi)
19982002
if (s_precompile != JL_STDERR)
19992003
ios_flush(&f_precompile);
20002004
}
2005+
if (jl_n_threads > 1)
2006+
JL_UNLOCK(&precomp_statement_out_lock);
20012007
}
20022008

20032009
jl_code_instance_t *jl_compile_method_internal(jl_method_instance_t *mi, size_t world)

0 commit comments

Comments
 (0)