diff options
author | David Mitchell <davem@iabyn.com> | 2019-02-18 09:29:29 +0000 |
---|---|---|
committer | David Mitchell <davem@iabyn.com> | 2019-02-19 13:28:12 +0000 |
commit | 04912be77a628a4643d16a99a332a73853926079 (patch) | |
tree | 78057c2aed6b7fb0a330616a8c235cd6c5e73346 /embedvar.h | |
parent | 61d4c87c940fea028f08f27addc275b469320fda (diff) | |
download | perl-04912be77a628a4643d16a99a332a73853926079.tar.gz |
fix thread issue with PERL_GLOBAL_STRUCT
The MY_CXT subsystem allows per-thread pseudo-static data storage.
Part of the implementation for this involves each XS module being
assigned a unique index in its my_cxt_index static var when first
loaded.
Because PERL_GLOBAL_STRUCT bans any static vars, under those builds
there is instead a table which maps the MY_CXT_KEY identifying string to
index.
Unfortunately, this table was allocated per-interpreter rather than
globally, meaning if multiple threads tried to load the same XS module,
crashes could ensue.
This manifested itself in failures in
ext/XS-APItest/t/keyword_plugin_threads.t
The fix is relatively straightforward: allocate PL_my_cxt_keys globally
rather than per-interpreter.
Also record the size of this struct in a new var, PL_my_cxt_keys_size,
rather than doing double duty on PL_my_cxt_size.
Diffstat (limited to 'embedvar.h')
-rw-r--r-- | embedvar.h | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/embedvar.h b/embedvar.h index 37e4ab1600..420664d68c 100644 --- a/embedvar.h +++ b/embedvar.h @@ -203,7 +203,6 @@ #define PL_modcount (vTHX->Imodcount) #define PL_modglobal (vTHX->Imodglobal) #define PL_multideref_pc (vTHX->Imultideref_pc) -#define PL_my_cxt_keys (vTHX->Imy_cxt_keys) #define PL_my_cxt_list (vTHX->Imy_cxt_list) #define PL_my_cxt_size (vTHX->Imy_cxt_size) #define PL_na (vTHX->Ina) @@ -426,6 +425,10 @@ #define PL_Gmy_ctx_mutex (my_vars->Gmy_ctx_mutex) #define PL_my_cxt_index (my_vars->Gmy_cxt_index) #define PL_Gmy_cxt_index (my_vars->Gmy_cxt_index) +#define PL_my_cxt_keys (my_vars->Gmy_cxt_keys) +#define PL_Gmy_cxt_keys (my_vars->Gmy_cxt_keys) +#define PL_my_cxt_keys_size (my_vars->Gmy_cxt_keys_size) +#define PL_Gmy_cxt_keys_size (my_vars->Gmy_cxt_keys_size) #define PL_op_mutex (my_vars->Gop_mutex) #define PL_Gop_mutex (my_vars->Gop_mutex) #define PL_op_seq (my_vars->Gop_seq) |