develooper Front page | perl.perl5.porters | Postings from March 2003

[PATCH] COW formats (was Re: Smoke [5.9.0] 19044 FAIL(F) linux 2.4.18-3 (i686/1 cpu))

Thread Previous
From:
Nicholas Clark
Date:
March 29, 2003 16:48
Subject:
[PATCH] COW formats (was Re: Smoke [5.9.0] 19044 FAIL(F) linux 2.4.18-3 (i686/1 cpu))
Message ID:
20030330003547.GO274@Bagpuss.unfortu.net
On Sun, Mar 23, 2003 at 12:00:00PM +0100, Abe Timmerman wrote:
> Automated smoke report for 5.9.0 patch 19044 on linux - 2.4.18-3 (i686/1 cpu)
>           v1.16_25      using cc version 2.96 20000731 (Red Hat Linux 7.3 296-110)

> O O F O O F  -Accflags='-DPERL_COPY_ON_WRITE'

> O O F O O F  -Duseithreads -Accflags='-DPERL_COPY_ON_WRITE'

> Failures:
> 
> linux       [locale:nl_NL]-Accflags='-DPERL_COPY_ON_WRITE'
>     t/op/write...........................FAILED at test 9
> 
> linux       [locale:nl_NL]-DDEBUGGING -Accflags='-DPERL_COPY_ON_WRITE'
>     t/op/write...........................FAILED at test 9
>     lib/locale...........................FAILED at test 99
> 
> linux       [locale:nl_NL]-Duseithreads
>               (cont) -Accflags='-DPERL_COPY_ON_WRITE'
>     t/op/write...........................FAILED at test 9
> 
> linux       [locale:nl_NL]-DDEBUGGING -Duseithreads
>               (cont) -Accflags='-DPERL_COPY_ON_WRITE'
>     t/op/write...........................FAILED at test 9
>     lib/locale...........................FAILED at test 99

On Mon, Mar 03, 2003 at 12:10:49AM +0000, Nicholas Clark wrote:
> On Sun, Mar 02, 2003 at 11:06:38AM +0000, Nicholas Clark wrote:
> > This is just a heads up because I don't have time right now to investigate
> > this further. [I need to have a tutorial written before I start trying to
> > present it :-) ]
> > 
> > It looks like recent changes to the format code can cause SEGVs:
> 
> My apologies. I've been accusing the wrong patches. It's actually because
> my /usr/local/bin/perl is built with -DPERL_COPY_ON_WRITE
> 
> The recent UTF8 patches are entirely innocent.

And I'm sorry to have caused Inaba-san distress and fruitless bug-hunting
by accusing them falsely.

> > I've no idea what dprofpp is doing, but clearly it's doing something that's
> > not in a regression test.
> 
> Well, that bit of my original message is still Vail.

oops. "valid".

> I can't easily work out how it's all screwed up as calling Perl_dump_sv
> on tmpForm causes a SEGV within the called routine. I think I'm going to
> go to bed instead.

Undefined behaviour. It seems that when you copy a format, the result is a
plain PV. But a format (PVFM) is >=PVIV, so COW thinks it can kick in.

EPERL5INTERNALSTOOCOMPLEX
use more 'parrot';

The appended patch should fix this. I'm not sure how to write a regression
test to check for undefined behaviour triggered as the result of writing
outside of an allocated block, but for the specific case with t/op/write.t
run it as

perl -C16 t/op/write.t

to watch it get upset.
MALLOC_OPTIONS=A on FreeBSD helps, as earlier chunk overwrite warnings become
aborts, which gdb "spots" :-)

Nicholas Clark

--- sv.c.orig	Wed Mar 26 23:18:16 2003
+++ sv.c	Sun Mar 30 00:28:55 2003
@@ -3683,8 +3683,16 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, regi
 	    goto glob_assign;
 	}
 	break;
-    case SVt_PV:
     case SVt_PVFM:
+#ifdef PERL_COPY_ON_WRITE
+	if ((SvFLAGS(sstr) & CAN_COW_MASK) == CAN_COW_FLAGS) {
+	    if (dtype < SVt_PVIV)
+		sv_upgrade(dstr, SVt_PVIV);
+	    break;
+	}
+	/* Fall through */
+#endif
+    case SVt_PV:
 	if (dtype < SVt_PV)
 	    sv_upgrade(dstr, SVt_PV);
 	break;
@@ -4006,6 +4014,7 @@ Perl_sv_setsv_flags(pTHX_ SV *dstr, regi
                 /* making another shared SV.  */
                 STRLEN cur = SvCUR(sstr);
                 STRLEN len = SvLEN(sstr);
+		assert (SvTYPE(dstr) >= SVt_PVIV);
                 if (len) {
                     /* SvIsCOW_normal */
                     /* splice us in between source and next-after-source.  */

Thread Previous


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