Closed p5pRT closed 12 years ago
When I update my module re::engine::Lua for Perl 5.12 & 5.14\, qr// segfaults in the function Perl_reg_temp_copy (regcomp.c). Because this function assumes that the field offs of REGEXP is always set by the method comp of the regex_engine. But in re::engine::Lua\, offs is set by the method exec.
re::engine::Lua 0.08 includes a workaround\, but I propose a patch.
On Wed May 16 10:01:50 2012\, fperrad wrote:
This is a bug report for perl from perrad@cpan.org\, generated with the help of perlbug 1.39 running under perl 5.14.2.
----------------------------------------------------------------- [Please describe your issue here] When I update my module re::engine::Lua for Perl 5.12 & 5.14\, qr// segfaults in the function Perl_reg_temp_copy (regcomp.c). Because this function assumes that the field offs of REGEXP is always set by the method comp of the regex_engine. But in re::engine::Lua\, offs is set by the method exec.
re::engine::Lua 0.08 includes a workaround\, but I propose a patch.
[snip]
Locally applied patches: From 84d2d39de77ef762886a6215a787410a5a9563d1 Mon Sep 17 00:00:00 2001 From: Francois Perrad \francois\.perrad@​gadz\.org Date: Wed\, 16 May 2012 17:55:22 +0200 Subject: [PATCH] copy .offs only if not null.
--- regcomp.c | 8 +++++--- 1 file changed\, 5 insertions(+)\, 3 deletions(-)
diff --git a/regcomp.c b/regcomp.c index 143f349..c3a258a 100644 --- a/regcomp.c +++ b/regcomp.c @@ -12729\,7 +12729\,6 @@ Perl_reg_temp_copy (pTHX_ REGEXP *ret_x\, REGEXP *rx) { struct regexp *ret; struct regexp *const r = (struct regexp *)SvANY(rx); - register const I32 npar = r->nparens+1;
PERL\_ARGS\_ASSERT\_REG\_TEMP\_COPY;
@@ -12749\,8 +12748\,11 @@ Perl_reg_temp_copy (pTHX_ REGEXP *ret_x\, REGEXP *rx) SvLEN_set(ret_x\, 0); SvSTASH_set(ret_x\, NULL); SvMAGIC_set(ret_x\, NULL); - Newx(ret->offs\, npar\, regexp_paren_pair); - Copy(r->offs\, ret->offs\, npar\, regexp_paren_pair); + if (r->offs) { + const I32 npar = r->nparens+1; + Newx(ret->offs\, npar\, regexp_paren_pair); + Copy(r->offs\, ret->offs\, npar\, regexp_paren_pair); + } if (r->substrs) { Newx(ret->substrs\, 1\, struct reg_substr_data); StructCopy(r->substrs\, ret->substrs\, struct reg_substr_data); -- 1.7.9.5
I tested this patch on blead on Darwin/PPC and it passed all current tests. It should be evaluated by others for how well it deals with the problem François described.
Thank you very much. Jim Keenan
The RT System itself - Status changed from 'new' to 'open'
On Wed May 23 20:10:05 2012\, jkeenan wrote:
I tested this patch on blead on Darwin/PPC and it passed all current tests. It should be evaluated by others for how well it deals with the problem Fran�ois described.
Could someone who understands the regexp plugin interface please comment on this?
--
Father Chrysostomos
"Father Chrysostomos via RT" \perlbug\-followup@​perl\.org wrote: :On Wed May 23 20:10:05 2012\, jkeenan wrote: :> I tested this patch on blead on Darwin/PPC and it passed all current :> tests. It should be evaluated by others for how well it deals with the :> problem Fran�ois described. : :Could someone who understands the regexp plugin interface please comment :on this?
I'm not such a person. The change does not look unreasonable to me\, on a 5-minute look; but I'd need to dig further to be sure it was safe simply to fail to set ret->offs (rather than\, say\, setting it to NULL). I'd also be rather happier if the patch came with a test\, though by the sounds of it that's unlikely to be possible in pure perl code.
Hugo
On Wed\, Jun 20\, 2012 at 07:42:24AM +0100\, hv@crypt.org wrote:
"Father Chrysostomos via RT" \perlbug\-followup@​perl\.org wrote: :On Wed May 23 20:10:05 2012\, jkeenan wrote: :> I tested this patch on blead on Darwin/PPC and it passed all current :> tests. It should be evaluated by others for how well it deals with the :> problem Fran�ois described. : :Could someone who understands the regexp plugin interface please comment :on this?
It looks good to me.
I'm not such a person. The change does not look unreasonable to me\, on a 5-minute look; but I'd need to dig further to be sure it was safe simply to fail to set ret->offs (rather than\, say\, setting it to NULL). I'd also be rather happier if the patch came with a test\, though by the sounds of it that's unlikely to be possible in pure perl code.
The new regex structure is initially nulled\, so it should be safe. The regex API does't appear to be tested - certainly there's nothing in ext/XS-APItest/.
-- More than any other time in history\, mankind faces a crossroads. One path leads to despair and utter hopelessness. The other\, to total extinction. Let us pray we have the wisdom to choose correctly. -- Woody Allen
On Wed May 16 10:01:50 2012\, fperrad wrote:
From 84d2d39de77ef762886a6215a787410a5a9563d1 Mon Sep 17 00:00:00 2001 From: Francois Perrad \francois\.perrad@​gadz\.org Date: Wed\, 16 May 2012 17:55:22 +0200 Subject: [PATCH] copy .offs only if not null.
--- regcomp.c | 8 +++++--- 1 file changed\, 5 insertions(+)\, 3 deletions(-)
diff --git a/regcomp.c b/regcomp.c index 143f349..c3a258a 100644 --- a/regcomp.c +++ b/regcomp.c @@ -12729\,7 +12729\,6 @@ Perl_reg_temp_copy (pTHX_ REGEXP *ret_x\, REGEXP *rx) { struct regexp *ret; struct regexp *const r = (struct regexp *)SvANY(rx); - register const I32 npar = r->nparens+1;
PERL\_ARGS\_ASSERT\_REG\_TEMP\_COPY;
@@ -12749\,8 +12748\,11 @@ Perl_reg_temp_copy (pTHX_ REGEXP *ret_x\, REGEXP *rx) SvLEN_set(ret_x\, 0); SvSTASH_set(ret_x\, NULL); SvMAGIC_set(ret_x\, NULL); - Newx(ret->offs\, npar\, regexp_paren_pair); - Copy(r->offs\, ret->offs\, npar\, regexp_paren_pair); + if (r->offs) { + const I32 npar = r->nparens+1; + Newx(ret->offs\, npar\, regexp_paren_pair); + Copy(r->offs\, ret->offs\, npar\, regexp_paren_pair); + } if (r->substrs) { Newx(ret->substrs\, 1\, struct reg_substr_data); StructCopy(r->substrs\, ret->substrs\, struct reg_substr_data); -- 1.7.9.5
Thank you. Applied as 774656327327593. --
Father Chrysostomos
@cpansprout - Status changed from 'open' to 'resolved'
Migrated from rt.perl.org#112962 (status was 'resolved')
Searchable as RT112962$