develooper Front page | perl.perl5.porters | Postings from November 1999

Re: FAIL HTML-Parser-XS-2.99_13 PA-RISC1.1 10.20

From:
Gisle Aas
Date:
November 25, 1999 04:16
Subject:
Re: FAIL HTML-Parser-XS-2.99_13 PA-RISC1.1 10.20
Message ID:
m3vh6q6a5y.fsf@eik.g.aas.no
----------------------------------------XS--------
MODULE = Test           PACKAGE = Test

SV*
test(...)
   CODE:
     RETVAL = &PL_sv_undef;
   OUTPUT:
     RETVAL


---------------------------------------perl-------
use Test;
$a = \undef;         # will increment refcount on PL_sv_undef
$a = Test::test();   # perl5.004_05 will die "Modification of a read-only value attempted"
--------------------------------------------------

Does anybody know which patch to perl5.004_05 introduced this behaviour?
Is it wrong to return &PL_sv_undef as shown above?


The fix that I have now applied to HTML/Parser.xs is this one:

Index: Parser.xs
===================================================================
RCS file: /home/cvs/aas/perl/mods/html-parser/Parser.xs,v
retrieving revision 2.40
retrieving revision 2.41
diff -u -p -u -r2.40 -r2.41
--- Parser.xs	1999/11/25 11:22:22	2.40
+++ Parser.xs	1999/11/25 11:59:52	2.41
@@ -1624,7 +1624,16 @@ accum(pstate,...)
 	PSTATE* pstate
     CODE:
         RETVAL = pstate->accum ? newRV_inc((SV*)pstate->accum)
-	                       : &PL_sv_undef;
+#if !(PATCHLEVEL == 4 && SUBVERSION == 5)
+			       : &PL_sv_undef
+#else
+         /* For perl5.004_05 returning PL_sv_undef will terminate
+          * the program with the "Modification of a read-only value attempted"
+          * message if its reference count happen to be incremented.
+          * Returning a copy is then better.
+          */
+	                       : newSVsv(&PL_sv_undef);
+#endif
         if (items > 1) {
 	    SV* aref = ST(1);
             AV* av = (AV*)SvRV(aref);

Regards,
Gisle




nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About