Commit 9039555
authored
Fix data race in jl_new_module__ (JuliaLang#58880)
Use an atomic fetch and add to fix a data race in `Module()` identified
by tsan:
```
./usr/bin/julia -t4,0 --gcthreads=1 -e 'Threads.@threads for i=1:100 Module() end'
==================
WARNING: ThreadSanitizer: data race (pid=5575)
Write of size 4 at 0xffff9bf9bd28 by thread T9:
#0 jl_new_module__ /home/user/c/julia/src/module.c:487:22 (libjulia-internal.so.1.13+0x897d4)
#1 jl_new_module_ /home/user/c/julia/src/module.c:527:22 (libjulia-internal.so.1.13+0x897d4)
mmtk#2 jl_f_new_module /home/user/c/julia/src/module.c:649:22 (libjulia-internal.so.1.13+0x8a968)
mmtk#3 <null> <null> (0xffff76a21164)
mmtk#4 <null> <null> (0xffff76a1f074)
mmtk#5 <null> <null> (0xffff76a1f0c4)
mmtk#6 _jl_invoke /home/user/c/julia/src/gf.c (libjulia-internal.so.1.13+0x5ea04)
mmtk#7 ijl_apply_generic /home/user/c/julia/src/gf.c:3892:12 (libjulia-internal.so.1.13+0x5ea04)
mmtk#8 jl_apply /home/user/c/julia/src/julia.h:2343:12 (libjulia-internal.so.1.13+0x9e4c4)
mmtk#9 start_task /home/user/c/julia/src/task.c:1249:19 (libjulia-internal.so.1.13+0x9e4c4)
Previous write of size 4 at 0xffff9bf9bd28 by thread T10:
#0 jl_new_module__ /home/user/c/julia/src/module.c:487:22 (libjulia-internal.so.1.13+0x897d4)
#1 jl_new_module_ /home/user/c/julia/src/module.c:527:22 (libjulia-internal.so.1.13+0x897d4)
mmtk#2 jl_f_new_module /home/user/c/julia/src/module.c:649:22 (libjulia-internal.so.1.13+0x8a968)
mmtk#3 <null> <null> (0xffff76a21164)
mmtk#4 <null> <null> (0xffff76a1f074)
mmtk#5 <null> <null> (0xffff76a1f0c4)
mmtk#6 _jl_invoke /home/user/c/julia/src/gf.c (libjulia-internal.so.1.13+0x5ea04)
mmtk#7 ijl_apply_generic /home/user/c/julia/src/gf.c:3892:12 (libjulia-internal.so.1.13+0x5ea04)
mmtk#8 jl_apply /home/user/c/julia/src/julia.h:2343:12 (libjulia-internal.so.1.13+0x9e4c4)
mmtk#9 start_task /home/user/c/julia/src/task.c:1249:19 (libjulia-internal.so.1.13+0x9e4c4)
Location is global 'jl_new_module__.mcounter' of size 4 at 0xffff9bf9bd28 (libjulia-internal.so.1.13+0x3dbd28)
```1 parent 811150c commit 9039555
1 file changed
+3
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
482 | 482 | | |
483 | 483 | | |
484 | 484 | | |
485 | | - | |
| 485 | + | |
| 486 | + | |
486 | 487 | | |
487 | | - | |
| 488 | + | |
488 | 489 | | |
489 | 490 | | |
490 | 491 | | |
| |||
0 commit comments