develooper Front page | perl.perl5.porters | Postings from November 2003

Re: 5.8.2 coredump: tied hashes implemented as XSUB methods

Thread Previous | Thread Next
Nick Ing-Simmons
November 19, 2003 02:56
Re: 5.8.2 coredump: tied hashes implemented as XSUB methods
Message ID:
Alan Burlison <> writes:
>> I have a module (Solaris::Kstat) which implements a tied hash entirely 
>> from XSUB code.  This works fine in 5.6.1, but cores in 5.8.2.
>I've done a bit more digging, and this is failing because in 5.6.1 I was 
>setting the keys & values of the tied hashes to be readonly, and this has 
>clashed with the way the 'Restricted hash' functionality introduced 
>post-5.6.1 which also uses the READONLY flags.  The implementation of 
>restricted hashes isn't exactly clearly documented on perlguts, so I haven't 
>yet figured out exactly what I am doing wrong.  I'm setting/unsetting 
>READONLY on the hashes themselves, and on the entries returned by 
>hv_fetch(), but obviously this isn't correct.  I'm getting the SEGV in 
>Perl_hv_clear, here:
>         I32 i;
>         HE* entry;
>         for (i = 0; i <= (I32) xhv->xhv_max; i++) {
>--->         entry = ((HE**)xhv->xhv_array)[i];
>because xhv->xhv_array is NULL - I have no idea why yet.  Can anyone shed 
>any light on exactly how the READONLY flags are supposed to be set to get 
>the various restricted hash behaviours?

It is _reasonably_ intuitive - my memory is:

If you set SvREADONLY on the HV then 
the keys become fixed - you can't add anything and if you delete 
the hash entry remains with value being a place-holder value.

AFAIK the SvREADONLY of the SVs returned from FETCH are not special.

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