From: Nicholas Clark Date: Thu, 13 Apr 2006 21:59:52 +0000 (+0000) Subject: (Hopefully) fix coredumps in ByteLoader, which were a side effect of X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=93d343c6c59d1d6b5e6307c31585c77ab830183d;p=p5sagit%2Fp5-mst-13.2.git (Hopefully) fix coredumps in ByteLoader, which were a side effect of fixing a bug in B, and non-robust autogenerated code. When autogenerating initialiser statements for an array, it's a bad plan to have the size of that array hard coded. p4raw-id: //depot/perl@27795 --- diff --git a/bytecode.pl b/bytecode.pl index f0763dd..4da765a 100644 --- a/bytecode.pl +++ b/bytecode.pl @@ -90,7 +90,10 @@ for ($i = 0; $i < @optype - 1; $i++) { printf BYTERUN_C " sizeof(%s),\n", $optype[$i], $i; } printf BYTERUN_C " sizeof(%s)\n", $optype[$i], $i; -print BYTERUN_C <<'EOT'; + +my $size = @specialsv; + +print BYTERUN_C <<"EOT"; }; void * @@ -110,7 +113,7 @@ byterun(pTHX_ register struct byteloader_state *bstate) dVAR; register int insn; U32 ix; - SV *specialsv_list[6]; + SV *specialsv_list[$size]; BYTECODE_HEADER_CHECK; /* croak if incorrect platform */ Newx(bstate->bs_obj_list, 32, void*); /* set op objlist */ diff --git a/ext/ByteLoader/bytecode.h b/ext/ByteLoader/bytecode.h index 7ba0236..1d06b08 100644 --- a/ext/ByteLoader/bytecode.h +++ b/ext/ByteLoader/bytecode.h @@ -91,7 +91,11 @@ typedef char *pvindex; arg = arg ? savepv(arg) : arg; \ } STMT_END -#define BSET_ldspecsv(sv, arg) sv = specialsv_list[arg] +#define BSET_ldspecsv(sv, arg) STMT_START { \ + assert(arg < sizeof(specialsv_list) / sizeof(specialsv_list[0])); \ + sv = specialsv_list[arg]; \ + } STMT_END + #define BSET_ldspecsvx(sv, arg) STMT_START { \ BSET_ldspecsv(sv, arg); \ BSET_OBJ_STOREX(sv); \ diff --git a/ext/ByteLoader/byterun.c b/ext/ByteLoader/byterun.c index c8543f7..77568ba 100644 --- a/ext/ByteLoader/byterun.c +++ b/ext/ByteLoader/byterun.c @@ -51,7 +51,7 @@ byterun(pTHX_ register struct byteloader_state *bstate) dVAR; register int insn; U32 ix; - SV *specialsv_list[6]; + SV *specialsv_list[7]; BYTECODE_HEADER_CHECK; /* croak if incorrect platform */ Newx(bstate->bs_obj_list, 32, void*); /* set op objlist */