summaryrefslogtreecommitdiff
path: root/op.c
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2021-10-21 13:51:17 +1100
committerTony Cook <tony@develop-help.com>2021-11-15 11:35:42 +1100
commit9bce496f83cb607054f21c015c5f377c24c86bfd (patch)
treeffdac5b82f1940e1fd60d46d5709c730e7d2b566 /op.c
parent0cdbe2162863542f45a5faa22e46c1aa76c029cb (diff)
downloadperl-9bce496f83cb607054f21c015c5f377c24c86bfd.tar.gz
don't try to clean up the COP pointer during global destruction
At this point there should be no further debugging code trying to use the COP pointer. On threaded builds the call to CopFILEAV() could cause a segmentation fault, since during late destruction gv_fetchfile() could return NULL, which the threaded version of CopFILEAV() would blindly call GvAV() on.
Diffstat (limited to 'op.c')
-rw-r--r--op.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/op.c b/op.c
index 8e50ee0df0..e1584cfde1 100644
--- a/op.c
+++ b/op.c
@@ -1316,7 +1316,11 @@ S_cop_free(pTHX_ COP* cop)
{
PERL_ARGS_ASSERT_COP_FREE;
- if (cop->op_type == OP_DBSTATE) {
+ /* If called during global destruction PL_defstash might be NULL and there
+ shouldn't be any code running that will trip over the bad cop address.
+ This also avoids uselessly creating the AV after it's been destroyed.
+ */
+ if (cop->op_type == OP_DBSTATE && PL_phase != PERL_PHASE_DESTRUCT) {
/* Remove the now invalid op from the line number information.
This could cause a freed memory overwrite if the debugger tried to
set a breakpoint on this line.