develooper Front page | perl.perl5.porters | Postings from March 2007

Re: [perl #41531] somehow PL_hints goes readonly causing havoc, (charnames possibly involved).

Thread Previous | Thread Next
March 12, 2007 02:46
Re: [perl #41531] somehow PL_hints goes readonly causing havoc, (charnames possibly involved).
Message ID:
On 2/18/07, via RT yves orton <> wrote:
> # New Ticket Created by  yves orton
> # Please include the string:  [perl #41531]
> # in the subject line of all future correspondence about this issue.
> # <URL: >
> This is a bug report for perl from demerphq@fresh,
> generated with the help of perlbug 1.35 running under perl 5.9.5.
> -----------------------------------------------------------------
> [Please enter your report here]
> The following script:
>     use charnames ':full';
>     eval '/$regex/';
>     die $@ if $@;
> Dies with the following error:
> Attempt to access disallowed key 'regcomp' in a restricted hash...
> I can't find anything in charnames that would set the hints hash
> to readonly. But if its not used then no problem occurs. I note
> also that charnames stores a lot of stuff in the hints hash.
> Nor can I see anything different about the way the 'regcomp' key
> is looked up as compared to every other core routine that uses
> keys in the hints hash, so i suspect that this type of bug could
> occur with other hints hash lookups.
> While obviously it would be best to figure out why the hash is being
> set to readonly I also think we could lose a chunk of duplicated code
> by making a routine hints_fetch() that handles doing lookups from
> the hints hash, and at the same time provide hv_fetch_common a flag
> that would prevent fetches from a locked hints hash from blowing up.
> IMO this /needs/ to be solved before 5.10 comes out.

Attached patch (without any tests, sorry) fixes this problem as can be
illustrated by the following one liner:

  ..\perl -e"BEGIN{$^H{x}=1}; eval 'print $^H{y}'; print $@||'ok'"

Ill try to follow up with a patch to add a test for this behaviour. I
just want to make sure this patch is posted before i disappear for the
rest of the week.


perl -Mre=debug -e "/just|another|perl|hacker/"

Thread Previous | Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About