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

Re: [FIX] [perl #8760]

Thread Previous | Thread Next
From:
Enache Adrian
Date:
February 4, 2003 02:09
Subject:
Re: [FIX] [perl #8760]
Message ID:
20030204101533.GA11817@ratsnest.hole
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:
--------------------------------------------------------------------
--- /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:

$ perl -Dt -e '$_="foo"; utf8::upgrade($_); warn (/bar/i ? "bar" : "no bar");' 2>~/a
$ perl -Dt -e '$_="foo"; utf8::upgrade($_); warn (/bar/m ? "bar" : "no bar");' 2>~/b
$ diff -y -W80 ~/a ~/b | less -S

Regards
Adi

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