summaryrefslogtreecommitdiff
path: root/embed.h
diff options
context:
space:
mode:
authorKarl Williamson <khw@cpan.org>2020-03-06 14:18:45 -0700
committerKarl Williamson <khw@cpan.org>2020-03-11 09:52:12 -0600
commit24f3e849b5ce9f3bf6b6be5d3e730562e927aa79 (patch)
tree2aeee9a5124aea2f9617971dc2f3421fd8a0e858 /embed.h
parent2bc5f86adf5f1c0feb76d83e1a627e5649e6beab (diff)
downloadperl-24f3e849b5ce9f3bf6b6be5d3e730562e927aa79.tar.gz
Add thread safety to some environment accesses
The previous commit added a mutex specifically for protecting against simultaneous accesses of the environment. This commit changes the normal getenv, putenv, and clearenv functions to use it, to avoid races. This makes the code simpler in places where we've gotten burned and added stuff to avoid races. Other places where we haven't known we were getting burned could have existed until now. Now that comes automatically, and we can remove the special cases we earlier stumbled over. getenv() returns a pointer to static memory, which can be overwritten at any moment from another thread, or even another getenv from the same thread. This commit changes the accesses to be under control of a mutex, and in the case of getenv, a mortalized copy is created so that there is no possible race.
Diffstat (limited to 'embed.h')
-rw-r--r--embed.h1
1 files changed, 1 insertions, 0 deletions
diff --git a/embed.h b/embed.h
index c550f88af4..064309803c 100644
--- a/embed.h
+++ b/embed.h
@@ -313,6 +313,7 @@
#define mg_size(a) Perl_mg_size(aTHX_ a)
#define mini_mktime Perl_mini_mktime
#define moreswitches(a) Perl_moreswitches(aTHX_ a)
+#define mortal_getenv Perl_mortal_getenv
#define mro_get_linear_isa(a) Perl_mro_get_linear_isa(aTHX_ a)
#define mro_method_changed_in(a) Perl_mro_method_changed_in(aTHX_ a)
#define my_atof(a) Perl_my_atof(aTHX_ a)