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

Re: [FIX] [perl #8760]

Thread Previous | Thread Next
From:
Rafael Garcia-Suarez
Date:
February 4, 2003 02:25
Subject:
Re: [FIX] [perl #8760]
Message ID:
20030204112541.6104c0f2.rgarciasuarez@free.fr
Enache Adrian <enache@rdslink.ro> wrote:
> On Mon, Feb 03, 2003 at 05:52:17PM +0200, Jarkko Hietaniemi wrote:
> > 
> >   $_ = "foo";
> >   utf8::upgrade($_);
> >   warn (/bar/i ? "bar" : "no bar");
> > 
> >  and I also spent some time in the debugger and it seems that
> >  Perl_pp_warn -> Perl_warner -> Perl_vmess -> S_closest_cop
> >  thinks that CopLINE is zero, and that's why the line and the file
> >  are not printed.  I have no idea why CopLINE would be zero because
> >  of case-insensitively matching against a UTF-8-ed scalar (Yes, the /i
> >  is required.)
> 
> This fixes it for me:

Thanks, for the patch, but I've already fixed it in a less intrusive
way (I restore only the cop_line for the current cop.) And I patched
in function Perl_vload_module.
See : http://archive.develooper.com/perl5-changes%40perl.org/msg06629.html
(strangely, the message I sent to P5P hasn't shown up already).

However I have the impression that your patch is more correct than
mine, without any evidence (I don't restore curcop but only cop_line,
and it appears that I get the correct cop_file(gv)? with and without
threads.) If you can work out any proof that your patch avoids problems
that my patch doesn't address, I'll be happy to apply it. I'll look
at it more closely in the meantime.

> --------------------------------------------------------------------
> --- /arc/perl-current/utf8.c	2003-01-07 12:34:01.000000000 +0200
> +++ perl-current/utf8.c	2003-02-04 11:35:41.000000000 +0200
> @@ -1517,6 +1517,7 @@ Perl_swash_init(pTHX_ char* pkg, char* n
>      SV* errsv_save;
>  
>      if (!gv_fetchmeth(stash, "SWASHNEW", 8, -1)) {	/* demand load utf8 */
> +	COP *ocurcop = PL_curcop;
>  	ENTER;
>  	errsv_save = newSVsv(ERRSV);
>  	Perl_load_module(aTHX_ PERL_LOADMOD_NOIMPORT, newSVpv(pkg,0), Nullsv);
> @@ -1524,6 +1525,7 @@ Perl_swash_init(pTHX_ char* pkg, char* n
>  	    sv_setsv(ERRSV, errsv_save);
>  	SvREFCNT_dec(errsv_save);
>  	LEAVE;
> +	PL_curcop = ocurcop;
>      }
>      SPAGAIN;
>      PUSHSTACKi(PERLSI_MAGIC);
> --------------------------------------------------------------------
> 
> The demand loading of utf8 clobbers PL_curcop at Perl_scalarseq (op.c:856).
> 
> This is some kind of reversed backtrace:
> Perl_pp_match  pp_hot.c:1255
>   Perl_regexec_flags  at regexec.c:1933
>     S_find_byclass  at regexec.c:1111
>       Perl_to_utf8_fold  at utf8.c:1504
> 	Perl_to_utf8_case  at utf8.c:1349
> 	  Perl_swash_init  at utf8.c:1522
> 	    Perl_load_module  at op.c:2922
> 	      Perl_vload_module  at op.c:2970
> 		Perl_utilize  at op.c:2877
> 		  Perl_newATTRSUB  at op.c:4152
> 		    Perl_scalarseq  op.c:856
> 
> Maybe the save/retrieve should be made even deeper
> (in load_module, utilize, etc ?)
> 
> The /i flag is really confusing. When it's left out, Perl aggressively
> optimizes away code and the bug doesn't creep out. Check with this:

Thread Previous | Thread Next


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