Get perl to build under STRESS_REALLOC once more
authorFather Chrysostomos <sprout@cpan.org>
Thu, 21 Nov 2013 04:38:27 +0000 (20:38 -0800)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 23 Nov 2013 05:20:37 +0000 (21:20 -0800)
It had been broken since v5.17.6-144-ga3444cc.

That commit added, inter alia, this comment to scope.h:

+ * Of course, doing the size check *after* pushing means we must always
+ * ensure there are SS_MAXPUSH free slots on the savestack

But STRESS_REALLOC makes the initial savestack size just 1, and
SS_MAXPUSH is 4.  So ‘./miniperl -e0’ failed an assertion.

perl.c

diff --git a/perl.c b/perl.c
index b551d45..e245f39 100644 (file)
--- a/perl.c
+++ b/perl.c
@@ -3995,8 +3995,10 @@ Perl_init_debugger(pTHX)
 
 #ifndef STRESS_REALLOC
 #define REASONABLE(size) (size)
+#define REASONABLE_but_at_least(size,min) (size)
 #else
 #define REASONABLE(size) (1) /* unreasonable */
+#define REASONABLE_but_at_least(size,min) (min)
 #endif
 
 void
@@ -4032,9 +4034,9 @@ Perl_init_stacks(pTHX)
     PL_scopestack_ix = 0;
     PL_scopestack_max = REASONABLE(32);
 
-    Newx(PL_savestack,REASONABLE(128),ANY);
+    Newx(PL_savestack,REASONABLE_but_at_least(128,SS_MAXPUSH),ANY);
     PL_savestack_ix = 0;
-    PL_savestack_max = REASONABLE(128);
+    PL_savestack_max = REASONABLE_but_at_least(128,SS_MAXPUSH);
 }
 
 #undef REASONABLE