/[pkgs]/devel/perl/perl-5.10.0-much-better-swap-logic.patch
ViewVC logotype

Contents of /devel/perl/perl-5.10.0-much-better-swap-logic.patch

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (show annotations) (download) (as text)
Mon Jul 27 07:11:46 2009 UTC (3 months, 3 weeks ago) by mmaslano
Branch: MAIN
CVS Tags: F-12-split, perl-5_10_0-80_fc12, perl-5_10_0-81_fc12, perl-5_10_0-84_fc13, perl-5_10_0-82_fc13, perl-5_10_0-79_fc12, perl-5_10_0-78_fc12, perl-5_10_0-77_fc12, perl-5_10_0-83_fc13, perl-5_10_0-76_fc12, HEAD
File MIME type: text/x-patch
* Mon Jul 27 2009 Marcela Mašláňová <mmaslano@redhat.com> - 4:5.10.0-76
- 494773 much better swap logic to support reentrancy and fix assert failure (rt #60508)
1 diff -up perl-5.10.0/embed.fnc.much perl-5.10.0/embed.fnc
2 --- perl-5.10.0/embed.fnc.much 2009-07-27 08:31:33.839374246 +0200
3 +++ perl-5.10.0/embed.fnc 2009-07-27 08:32:05.322374620 +0200
4 @@ -1441,7 +1441,6 @@ ERsn |U8* |reghop4 |NN U8 *pos|I32 off|N
5 #endif
6 ERsn |U8* |reghopmaybe3 |NN U8 *pos|I32 off|NN const U8 *lim
7 ERs |char* |find_byclass |NN regexp * prog|NN const regnode *c|NN char *s|NN const char *strend|NULLOK regmatch_info *reginfo
8 -Es |void |swap_match_buff|NN regexp * prog
9 Es |void |to_utf8_substr |NN regexp * prog
10 Es |void |to_byte_substr |NN regexp * prog
11 ERs |I32 |reg_check_named_buff_matched |NN const regexp *rex|NN const regnode *prog
12 diff -up perl-5.10.0/embed.h.much perl-5.10.0/embed.h
13 --- perl-5.10.0/embed.h.much 2007-12-18 11:47:07.000000000 +0100
14 +++ perl-5.10.0/embed.h 2009-07-27 08:31:34.016378805 +0200
15 @@ -1426,7 +1426,6 @@
16 #if defined(PERL_CORE) || defined(PERL_EXT)
17 #define reghopmaybe3 S_reghopmaybe3
18 #define find_byclass S_find_byclass
19 -#define swap_match_buff S_swap_match_buff
20 #define to_utf8_substr S_to_utf8_substr
21 #define to_byte_substr S_to_byte_substr
22 #define reg_check_named_buff_matched S_reg_check_named_buff_matched
23 @@ -3714,7 +3713,6 @@
24 #if defined(PERL_CORE) || defined(PERL_EXT)
25 #define reghopmaybe3 S_reghopmaybe3
26 #define find_byclass(a,b,c,d,e) S_find_byclass(aTHX_ a,b,c,d,e)
27 -#define swap_match_buff(a) S_swap_match_buff(aTHX_ a)
28 #define to_utf8_substr(a) S_to_utf8_substr(aTHX_ a)
29 #define to_byte_substr(a) S_to_byte_substr(aTHX_ a)
30 #define reg_check_named_buff_matched(a,b) S_reg_check_named_buff_matched(aTHX_ a,b)
31 diff -up perl-5.10.0/ext/Devel/PPPort/parts/embed.fnc.much perl-5.10.0/ext/Devel/PPPort/parts/embed.fnc
32 --- perl-5.10.0/ext/Devel/PPPort/parts/embed.fnc.much 2007-12-18 11:47:07.000000000 +0100
33 +++ perl-5.10.0/ext/Devel/PPPort/parts/embed.fnc 2009-07-27 08:32:58.859374528 +0200
34 @@ -1436,7 +1436,6 @@ ERsn |U8* |reghop4 |NN U8 *pos|I32 off|N
35 #endif
36 ERsn |U8* |reghopmaybe3 |NN U8 *pos|I32 off|NN const U8 *lim
37 ERs |char* |find_byclass |NN regexp * prog|NN const regnode *c|NN char *s|NN const char *strend|NULLOK regmatch_info *reginfo
38 -Es |void |swap_match_buff|NN regexp * prog
39 Es |void |to_utf8_substr |NN regexp * prog
40 Es |void |to_byte_substr |NN regexp * prog
41 ERs |I32 |reg_check_named_buff_matched |NN const regexp *rex|NN const regnode *prog
42 diff -up perl-5.10.0/pod/perlapi.pod.much perl-5.10.0/pod/perlapi.pod
43 diff -up perl-5.10.0/pod/perlguts.pod.much perl-5.10.0/pod/perlguts.pod
44 diff -up perl-5.10.0/proto.h.much perl-5.10.0/proto.h
45 --- perl-5.10.0/proto.h.much 2009-07-27 08:31:33.000000000 +0200
46 +++ perl-5.10.0/proto.h 2009-07-27 08:35:52.103374484 +0200
47 @@ -3851,9 +3851,6 @@ STATIC char* S_find_byclass(pTHX_ regexp
48 __attribute__nonnull__(pTHX_3)
49 __attribute__nonnull__(pTHX_4);
50
51 -STATIC void S_swap_match_buff(pTHX_ regexp * prog)
52 - __attribute__nonnull__(pTHX_1);
53 -
54 STATIC void S_to_utf8_substr(pTHX_ regexp * prog)
55 __attribute__nonnull__(pTHX_1);
56
57 diff -up perl-5.10.0/regcomp.c.much perl-5.10.0/regcomp.c
58 --- perl-5.10.0/regcomp.c.much 2009-07-27 08:31:33.000000000 +0200
59 +++ perl-5.10.0/regcomp.c 2009-07-27 08:37:09.598625044 +0200
60 @@ -9167,7 +9167,6 @@ Perl_pregfree(pTHX_ struct regexp *r)
61 if (r->saved_copy)
62 SvREFCNT_dec(r->saved_copy);
63 #endif
64 - Safefree(r->swap);
65 Safefree(r->offs);
66 Safefree(r);
67 }
68 @@ -9216,7 +9215,6 @@ Perl_reg_temp_copy (pTHX_ struct regexp
69 ret->saved_copy = NULL;
70 #endif
71 ret->mother_re = r;
72 - ret->swap = NULL;
73
74 return ret;
75 }
76 diff -up perl-5.10.0/regexec.c.much perl-5.10.0/regexec.c
77 --- perl-5.10.0/regexec.c.much 2007-12-18 11:47:08.000000000 +0100
78 +++ perl-5.10.0/regexec.c 2009-07-27 08:40:15.966404877 +0200
79 @@ -1718,26 +1718,6 @@ S_find_byclass(pTHX_ regexp * prog, cons
80 return s;
81 }
82
83 -static void
84 -S_swap_match_buff (pTHX_ regexp *prog) {
85 - regexp_paren_pair *t;
86 -
87 - if (!prog->swap) {
88 - /* We have to be careful. If the previous successful match
89 - was from this regex we don't want a subsequent paritally
90 - successful match to clobber the old results.
91 - So when we detect this possibility we add a swap buffer
92 - to the re, and switch the buffer each match. If we fail
93 - we switch it back, otherwise we leave it swapped.
94 - */
95 - Newxz(prog->swap, (prog->nparens + 1), regexp_paren_pair);
96 - }
97 - t = prog->swap;
98 - prog->swap = prog->offs;
99 - prog->offs = t;
100 -}
101 -
102 -
103 /*
104 - regexec_flags - match a regexp against a string
105 */
106 @@ -1765,7 +1745,7 @@ Perl_regexec_flags(pTHX_ REGEXP * const
107 I32 multiline;
108 RXi_GET_DECL(prog,progi);
109 regmatch_info reginfo; /* create some info to pass to regtry etc */
110 - bool swap_on_fail = 0;
111 + regexp_paren_pair *swap = NULL;
112
113 GET_RE_DEBUG_FLAGS_DECL;
114
115 @@ -1843,9 +1823,16 @@ Perl_regexec_flags(pTHX_ REGEXP * const
116 reginfo.ganch = strbeg;
117 }
118 if (PL_curpm && (PM_GETRE(PL_curpm) == prog)) {
119 - swap_on_fail = 1;
120 - swap_match_buff(prog); /* do we need a save destructor here for
121 - eval dies? */
122 + /* We have to be careful. If the previous successful match
123 + was from this regex we don't want a subsequent partially
124 + successful match to clobber the old results.
125 + So when we detect this possibility we add a swap buffer
126 + to the re, and switch the buffer each match. If we fail
127 + we switch it back, otherwise we leave it swapped.
128 + */
129 + swap = prog->offs;
130 + /* do we need a save destructor here for eval dies? */
131 + Newxz(prog->offs, (prog->nparens + 1), regexp_paren_pair);
132 }
133 if (!(flags & REXEC_CHECKED) && (prog->check_substr != NULL || prog->check_utf8 != NULL)) {
134 re_scream_pos_data d;
135 @@ -2144,6 +2131,7 @@ Perl_regexec_flags(pTHX_ REGEXP * const
136 goto phooey;
137
138 got_it:
139 + Safefree(swap);
140 RX_MATCH_TAINTED_set(prog, PL_reg_flags & RF_tainted);
141
142 if (PL_reg_eval_set)
143 @@ -2189,10 +2177,12 @@ phooey:
144 PL_colors[4], PL_colors[5]));
145 if (PL_reg_eval_set)
146 restore_pos(aTHX_ prog);
147 - if (swap_on_fail)
148 + if (swap) {
149 /* we failed :-( roll it back */
150 - swap_match_buff(prog);
151 -
152 + Safefree(prog->offs);
153 + prog->offs = swap;
154 + }
155 +
156 return 0;
157 }
158
159 diff -up perl-5.10.0/regexp.h.much perl-5.10.0/regexp.h
160 --- perl-5.10.0/regexp.h.much 2007-12-18 11:47:08.000000000 +0100
161 +++ perl-5.10.0/regexp.h 2009-07-27 08:41:06.882374786 +0200
162 @@ -88,7 +88,7 @@ typedef struct regexp {
163 /* Data about the last/current match. These are modified during matching*/
164 U32 lastparen; /* last open paren matched */
165 U32 lastcloseparen; /* last close paren matched */
166 - regexp_paren_pair *swap; /* Swap copy of *offs */
167 + regexp_paren_pair *swap; /* Unused: 5.10.1 and later */
168 regexp_paren_pair *offs; /* Array of offsets for (@-) and (@+) */
169
170 char *subbeg; /* saved or original string
171 diff -up perl-5.10.0/t/op/pat.t.much perl-5.10.0/t/op/pat.t
172 --- perl-5.10.0/t/op/pat.t.much 2007-12-18 11:47:08.000000000 +0100
173 +++ perl-5.10.0/t/op/pat.t 2009-07-27 08:44:50.343375513 +0200
174 @@ -4558,10 +4558,27 @@ ok($@=~/\QSequence \k... not terminated
175 ok("aaa" =~ /$s/, "#45337");
176 }
177
178 +# This only works under -DEBUGGING because it relies on an assert().
179 +{
180 + local $BugId = '60508';
181 + local $Message = "Check capture offset re-entrancy of utf8 code.";
182 +
183 + sub fswash { $_[0] =~ s/([>X])//g; }
184 + my $k1 = "." x 4 . ">>";
185 + fswash($k1);
186 +
187 + my $k2 = "\x{f1}\x{2022}";
188 + $k2 =~ s/([\360-\362])/>/g;
189 + fswash($k2);
190 +
191 + iseq($k2, "\x{2022}", "utf8::SWASHNEW doesn't cause capture leaks");
192 +}
193 +
194 # Put new tests above the dotted line about a page above this comment
195 iseq(0+$::test,$::TestCount,"Got the right number of tests!");
196 # Don't forget to update this!
197 BEGIN {
198 - $::TestCount = 4013;
199 + $::TestCount = 4014;
200 print "1..$::TestCount\n";
201 }
202 +

admin@fedoraproject.org
ViewVC Help
Powered by ViewVC 1.1.2