summaryrefslogtreecommitdiff
path: root/pp_hot.c
diff options
context:
space:
mode:
authorTony Cook <tony@develop-help.com>2017-08-31 14:33:17 +1000
committerTony Cook <tony@develop-help.com>2017-08-31 14:33:17 +1000
commitcfbdacd3fe159abe693ef1eb6fd7460850ef9312 (patch)
treed01a37eabb7ab650520455cdb62b95ba07062fac /pp_hot.c
parentcb87b182a5dce7fcec9a566d505ef08d0e85c813 (diff)
downloadperl-cfbdacd3fe159abe693ef1eb6fd7460850ef9312.tar.gz
add a stack extend check to pp_entersub for XS subs
This allows us to report the XSUB involved by name (or at least by filename if it's anonymous) in the likely case that it was an XSUB that failed to extend the stack.
Diffstat (limited to 'pp_hot.c')
-rw-r--r--pp_hot.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/pp_hot.c b/pp_hot.c
index ee6535ca75..b891d79519 100644
--- a/pp_hot.c
+++ b/pp_hot.c
@@ -4420,6 +4420,21 @@ PP(pp_entersub)
assert(CvXSUB(cv));
CvXSUB(cv)(aTHX_ cv);
+#if defined DEBUGGING && !defined DEBUGGING_RE_ONLY
+ /* This duplicates the check done in runops_debug(), but provides more
+ * information in the common case of the fault being with an XSUB.
+ *
+ * It should also catch an XSUB pushing more than it extends
+ * in scalar context.
+ */
+ if (PL_curstackinfo->si_stack_hwm < PL_stack_sp - PL_stack_base)
+ Perl_croak_nocontext(
+ "panic: XSUB %s::%s (%s) failed to extend arg stack: "
+ "base=%p, sp=%p, hwm=%p\n",
+ HvNAME(GvSTASH(CvGV(cv))), GvNAME(CvGV(cv)), CvFILE(cv),
+ PL_stack_base, PL_stack_sp,
+ PL_stack_base + PL_curstackinfo->si_stack_hwm);
+#endif
/* Enforce some sanity in scalar context. */
if (is_scalar) {
SV **svp = PL_stack_base + markix + 1;