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

Changes to hints hash via keyword are clobbered by pragmatic module

Thread Next
David Mertens
December 12, 2016 14:38
Changes to hints hash via keyword are clobbered by pragmatic module
Message ID:
Hello everyone,

I am writing about peculiar behavior with the hints hash. I'll be happy to
produce a simplified test case if the answer is not obvious. I am currently
working with Perl v5.22, but I expect this is a problem on other versions.

In my distribution I utilize two means for modifying the contents of a key
in the hints hash. In the first case, I simply follow the guidance of
perlpragma and append to it. See
In the second case, I have C code that triggers on a keyword. This code
retrieves the current hints hash with CopHINTHASH_get(PL_curcop) (see,
appends to the SV (line 1241), stores the result back in the hints hash
with cophh_store_pvs (line 1246), and calls CopHINTHASH_set (line 1247).

This usually works. If I use the keyword multiple times in a row, they all
append to the hints hash fine. If I use pragmatic modules, they append to
the hints has fine. If I use pragmatic modules followed by keywords, they
append to the hints hash fine. But, if I use keywords followed by a
pragmatic module, the appends made by the keywords are not visible.

The only way this makes sense to me is if the Perl-level $^H{"
C::Blocks/extended_symtab_tables"} is a cached copy of the hints hash. I
would have hoped that the CopHINTHASH_set would invalidate the cache, but
that does not appear to be the case. Is there a trick too working with the
hints hash from C that I've missed?


 "Debugging is twice as hard as writing the code in the first place.
  Therefore, if you write the code as cleverly as possible, you are,
  by definition, not smart enough to debug it." -- Brian Kernighan

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