summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Mitchell <davem@iabyn.com>2020-03-20 09:06:57 +0000
committerDavid Mitchell <davem@iabyn.com>2020-03-20 09:06:57 +0000
commit1943af6140f72047c5028b50f947b52f8998bebd (patch)
treea02ab1e3de087e1e3bc503d0da81238ad9e9c197
parentb33ac5557cb0255702946345f30e9a5ef0e8d88f (diff)
downloadperl-1943af6140f72047c5028b50f947b52f8998bebd.tar.gz
fixup to free_and_set_cop_warnings()
v5.31.9-156-g94c8b9c1f0 introduced the free_and_set_cop_warnings() macro. It's first argument expects a COP rather than a COP*. Its usage in S_restore_cop_warnings(() is to modify PL_cucop, but in order to pass a COP rather than a COP*, the original commit made a local copy of PL_curcop and ended up inadvertently updating the copy instead. This commit changes the maco so it expects a COP*, and updates the bulk of its callers to use &PL_compiling rather than PL_compiling, and fixes up S_restore_cop_warnings(). The symptoms were ASAN failures in a few test scripts including uni/parser.t and ext/XS-APItest/t/handy0*.t. (The S_restore_cop_warnings() function was only used by Perl__force_out_malformed_utf8_message(), so didn't cause many issues outside of test scripts which forced such "malformed "errors).
-rw-r--r--mg.c6
-rw-r--r--perl.c6
-rw-r--r--regen/warnings.pl4
-rw-r--r--scope.c2
-rw-r--r--utf8.c3
-rw-r--r--warnings.h4
6 files changed, 12 insertions, 13 deletions
diff --git a/mg.c b/mg.c
index b21f4d3c2b..e603b60989 100644
--- a/mg.c
+++ b/mg.c
@@ -2966,7 +2966,7 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
else if (strEQ(mg->mg_ptr+1, "ARNING_BITS")) {
if ( ! (PL_dowarn & G_WARN_ALL_MASK)) {
if (!SvPOK(sv)) {
- free_and_set_cop_warnings(PL_compiling, pWARN_STD);
+ free_and_set_cop_warnings(&PL_compiling, pWARN_STD);
break;
}
{
@@ -2978,9 +2978,9 @@ Perl_magic_set(pTHX_ SV *sv, MAGIC *mg)
not_all |= ptr[i] ^ 0x55;
}
if (!not_none) {
- free_and_set_cop_warnings(PL_compiling, pWARN_NONE);
+ free_and_set_cop_warnings(&PL_compiling, pWARN_NONE);
} else if (len >= WARNsize && !not_all) {
- free_and_set_cop_warnings(PL_compiling, pWARN_ALL);
+ free_and_set_cop_warnings(&PL_compiling, pWARN_ALL);
PL_dowarn |= G_WARN_ONCE ;
}
else {
diff --git a/perl.c b/perl.c
index fdfd1cd8d8..9d1faf44da 100644
--- a/perl.c
+++ b/perl.c
@@ -1245,7 +1245,7 @@ perl_destruct(pTHXx)
}
}
- free_and_set_cop_warnings(PL_compiling, NULL);
+ free_and_set_cop_warnings(&PL_compiling, NULL);
cophh_free(CopHINTHASH_get(&PL_compiling));
CopHINTHASH_set(&PL_compiling, cophh_new_empty());
CopFILE_free(&PL_compiling);
@@ -3738,12 +3738,12 @@ Perl_moreswitches(pTHX_ const char *s)
return s;
case 'W':
PL_dowarn = G_WARN_ALL_ON|G_WARN_ON;
- free_and_set_cop_warnings(PL_compiling, pWARN_ALL);
+ free_and_set_cop_warnings(&PL_compiling, pWARN_ALL);
s++;
return s;
case 'X':
PL_dowarn = G_WARN_ALL_OFF;
- free_and_set_cop_warnings(PL_compiling, pWARN_NONE);
+ free_and_set_cop_warnings(&PL_compiling, pWARN_NONE);
s++;
return s;
case '*':
diff --git a/regen/warnings.pl b/regen/warnings.pl
index a73ca9e3bb..6000c759ef 100644
--- a/regen/warnings.pl
+++ b/regen/warnings.pl
@@ -393,8 +393,8 @@ EOM
#define DUP_WARNINGS(p) Perl_dup_warnings(aTHX_ p)
#define free_and_set_cop_warnings(cmp,w) STMT_START { \
- if (!specialWARN(cmp.cop_warnings)) PerlMemShared_free(cmp.cop_warnings); \
- cmp.cop_warnings = w; \
+ if (!specialWARN((cmp)->cop_warnings)) PerlMemShared_free((cmp)->cop_warnings); \
+ (cmp)->cop_warnings = w; \
} STMT_END
/*
diff --git a/scope.c b/scope.c
index ad8f8e764b..a948a7b4f2 100644
--- a/scope.c
+++ b/scope.c
@@ -1448,7 +1448,7 @@ Perl_leave_scope(pTHX_ I32 base)
case SAVEt_COMPILE_WARNINGS:
a0 = ap[0];
- free_and_set_cop_warnings(PL_compiling, (STRLEN*) a0.any_ptr);
+ free_and_set_cop_warnings(&PL_compiling, (STRLEN*) a0.any_ptr);
break;
case SAVEt_PARSER:
diff --git a/utf8.c b/utf8.c
index ac075077b4..2b30cad117 100644
--- a/utf8.c
+++ b/utf8.c
@@ -55,8 +55,7 @@ within non-zero characters.
static void
S_restore_cop_warnings(pTHX_ void *p)
{
- COP curcop = *PL_curcop;
- free_and_set_cop_warnings(curcop, (STRLEN*) p);
+ free_and_set_cop_warnings(PL_curcop, (STRLEN*) p);
}
diff --git a/warnings.h b/warnings.h
index 37ab2055fc..f02edea0fa 100644
--- a/warnings.h
+++ b/warnings.h
@@ -226,8 +226,8 @@
#define DUP_WARNINGS(p) Perl_dup_warnings(aTHX_ p)
#define free_and_set_cop_warnings(cmp,w) STMT_START { \
- if (!specialWARN(cmp.cop_warnings)) PerlMemShared_free(cmp.cop_warnings); \
- cmp.cop_warnings = w; \
+ if (!specialWARN((cmp)->cop_warnings)) PerlMemShared_free((cmp)->cop_warnings); \
+ (cmp)->cop_warnings = w; \
} STMT_END
/*