regex bug: "variable ... will not stay shared"

G

gb345

Some code that used to work fine with perl 5.8.8 now generates a
warning when I run it with perl 5.10.0. The error is caused by a
recursive regex that is supposed to match a balanced expression.
This regex is defined using qr//, and is assigned to the variable
$pex, and mentions this variable in its definition.

The warning message is:

Variable "$pex" will not stay shared at (re_eval 5) line 2.
Variable "$pex" will not stay shared at (re_eval 6) line 2.

Here's the beast:

my $pex;
$pex = qr/
\{
(?:
(?:
"
( (?> (?:[^"\\]|\\[^"])* ) (?> \\" (?:[^"\\]|\\[^"])* )* )
"
|
(?!\{) ( [^",]* ) (?<!\})
|
(??{ $pex })
)
(?:
,
(?:
"
( (?> (?:[^"\\]|\\[^"])* ) (?> \\" (?:[^"\\]|\\[^"])* )* )
"
|
(?!\{) ( [^",]* ) (?<!\})
|
(??{ $pex })
)
)*
)?
\}
/x;

I want to fix whatever it is that the warning is warning about
(rather than simply turn off the warning), but it's not clear to
me exactly what the problem is (especially since this code has been
performing flawlessly up to now).

Any clarifications of what the error message is actually saying,
or suggestions to fix the problem would be much appreciated.

Many thanks in advance!

Gabe
 
S

sln

Some code that used to work fine with perl 5.8.8 now generates a
warning when I run it with perl 5.10.0. The error is caused by a
recursive regex that is supposed to match a balanced expression.
This regex is defined using qr//, and is assigned to the variable
$pex, and mentions this variable in its definition.

The warning message is:

Variable "$pex" will not stay shared at (re_eval 5) line 2.
Variable "$pex" will not stay shared at (re_eval 6) line 2.
I want to fix whatever it is that the warning is warning about
(rather than simply turn off the warning), but it's not clear to
me exactly what the problem is (especially since this code has been
performing flawlessly up to now).

Any clarifications of what the error message is actually saying,
or suggestions to fix the problem would be much appreciated.

Many thanks in advance!

Gabe

I don't get that message on my 5.10.0 multi-threaded x86 build
(although seen it before). Its probably the usage, certain parts
were untouched.

Can you post a sample usage that generates the warning.

Also, I don't see how this matches balanced text/expression.
It doesen't on my sample. Maybe you could describe what it is
you are trying to get with it. Are you trying to capture?

-sln
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,754
Messages
2,569,525
Members
44,997
Latest member
mileyka

Latest Threads

Top