Skip to content

Commit 2964312

Browse files
authored
fix #21360, make global bindings thread safe (#32370)
1 parent 59ee493 commit 2964312

File tree

3 files changed

+97
-36
lines changed

3 files changed

+97
-36
lines changed

doc/src/devdocs/locks.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ The following is a leaf lock (level 2), and only acquires level 1 locks (safepoi
3434

3535
> * typecache
3636
37+
The following is a level 2 lock:
38+
39+
> * Module->lock
40+
3741
The following is a level 3 lock, which can only acquire level 1 or level 2 locks internally:
3842

3943
> * Method->writelock
@@ -102,6 +106,8 @@ Type declarations : toplevel lock
102106

103107
Type application : typecache lock
104108

109+
Global variable tables : Module->lock
110+
105111
Module serializer : toplevel lock
106112

107113
JIT & type-inference : codegen lock

src/julia.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -462,7 +462,7 @@ typedef struct {
462462
jl_value_t *value;
463463
jl_value_t *globalref; // cached GlobalRef for this binding
464464
struct _jl_module_t *owner; // for individual imported bindings
465-
uint8_t constp:1;
465+
uint8_t constp;
466466
uint8_t exportp:1;
467467
uint8_t imported:1;
468468
uint8_t deprecated:2; // 0=not deprecated, 1=renamed, 2=moved to another package
@@ -486,6 +486,7 @@ typedef struct _jl_module_t {
486486
uint32_t counter;
487487
int32_t nospecialize; // global bit flags: initialization for new methods
488488
uint8_t istopmod;
489+
jl_mutex_t lock;
489490
} jl_module_t;
490491

491492
// one Type-to-Value entry

0 commit comments

Comments
 (0)