develooper Front page | perl.perl5.porters | Postings from December 2002

Re: [perl #18915] array assignment works correctly only in debugger

Thread Previous | Thread Next
From:
Gurusamy Sarathy
Date:
December 30, 2002 19:52
Subject:
Re: [perl #18915] array assignment works correctly only in debugger
Message ID:
200212310351.gBV3pYp29511@smtp3.ActiveState.com
On Mon, 30 Dec 2002 04:06:37 GMT, hv@crypt.org wrote:
>Nicholas Clark <nick@unfortu.net> wrote:
>:It's a utf8 regexp bug - I think something to do with the swash code.
>:It's still unsolved in the development version (tested with 18251)
>:
>:Your program should work if you unset $LANG (or change it to something that
>:isn't UTF8) - not a fix, but hopefully an acceptable workaround.
>:
>:The smallest case I can get it down to is:
>:
>:#!/usr/bin/perl -w
>:
>:for my $a (0,1) {
>:  $_ = 'readin,database,readout';
>:  if ($ARGV[0])  {
>:    $_ .= chr 256;
>:    chop;
>:  }
>:  /(.+)/;
>:
>:  my @d = split /[,]/,$1;
>:  print join (':',@d), "\n";
>:}
>:__END__
>:
>:Without any arguments (not utf8) I see:
>:
>:readin:database:readout
>:readin:database:readout
>:
>:with $ARGV[1] true, I see:
>:
>:#adin:database:readout
>:readin:database:readout
>
>This appears to have been fixed by one or more of Sarathy's patches
>18355-8.

It is most likely 18358 that fixes it (18355-7 are trivial patches).  
See attached patch and description.

I'd appreciate someone reducing the above into a valid test case.
Thanks!


Sarathy
gsar@ActiveState.com
-----------------------------------8<-----------------------------------
Change 18358 by gsar@rake on 2002/12/28 03:30:49

	save_re_context() was not saving many regexec.c state
	variables, resulting in various reentrancy problems when
	the swatches were autoloaded by perl in the midst of a
	match

Affected files ...

... //depot/perl/regcomp.c#318 edit

Differences ...

==== //depot/perl/regcomp.c#318 (text) ====
Index: perl/regcomp.c
--- perl/regcomp.c#317~18356~	Fri Dec 27 18:08:23 2002
+++ perl/regcomp.c	Fri Dec 27 19:30:49 2002
@@ -5020,20 +5020,6 @@
 void
 Perl_save_re_context(pTHX)
 {
-#if 0
-    SAVEPPTR(RExC_precomp);		/* uncompiled string. */
-    SAVEI32(RExC_npar);		/* () count. */
-    SAVEI32(RExC_size);		/* Code size. */
-    SAVEI32(RExC_flags);		/* are we folding, multilining? */
-    SAVEVPTR(RExC_rx);		/* from regcomp.c */
-    SAVEI32(RExC_seen);		/* from regcomp.c */
-    SAVEI32(RExC_sawback);		/* Did we see \1, ...? */
-    SAVEI32(RExC_naughty);		/* How bad is this pattern? */
-    SAVEVPTR(RExC_emit);		/* Code-emit pointer; &regdummy = don't */
-    SAVEPPTR(RExC_end);		/* End of input for compile */
-    SAVEPPTR(RExC_parse);		/* Input-scan pointer. */
-#endif
-
     SAVEI32(PL_reg_flags);		/* from regexec.c */
     SAVEPPTR(PL_bostr);
     SAVEPPTR(PL_reginput);		/* String-input pointer. */
@@ -5042,6 +5028,7 @@
     SAVEVPTR(PL_regstartp);		/* Pointer to startp array. */
     SAVEVPTR(PL_regendp);		/* Ditto for endp. */
     SAVEVPTR(PL_reglastparen);		/* Similarly for lastparen. */
+    SAVEVPTR(PL_reglastcloseparen);	/* Similarly for lastcloseparen. */
     SAVEPPTR(PL_regtill);		/* How far we are required to go. */
     SAVEGENERICPV(PL_reg_start_tmp);		/* from regexec.c */
     PL_reg_start_tmp = 0;
@@ -5063,6 +5050,19 @@
     SAVEI32(PL_reg_oldpos);			/* from regexec.c */
     SAVEVPTR(PL_reg_oldcurpm);		/* from regexec.c */
     SAVEVPTR(PL_reg_curpm);		/* from regexec.c */
+    SAVEPPTR(PL_reg_oldsaved);		/* old saved substr during match */
+    PL_reg_oldsaved = Nullch;
+    SAVEI32(PL_reg_oldsavedlen);	/* old length of saved substr during match */
+    PL_reg_oldsavedlen = 0;
+    SAVEI32(PL_reg_maxiter);		/* max wait until caching pos */
+    PL_reg_maxiter = 0;
+    SAVEI32(PL_reg_leftiter);		/* wait until caching pos */
+    PL_reg_leftiter = 0;
+    SAVEGENERICPV(PL_reg_poscache);	/* cache of pos of WHILEM */
+    PL_reg_poscache = Nullch;
+    SAVEI32(PL_reg_poscache_size);	/* size of pos cache of WHILEM */
+    PL_reg_poscache_size = 0;
+    SAVEPPTR(PL_regprecomp);		/* uncompiled string. */
     SAVEI32(PL_regnpar);		/* () count. */
     SAVEI32(PL_regsize);		/* from regexec.c */
 
End of Patch.

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