in reply to Modification of non-creatable hash value attempted

I found it in my XS code too.

if a XS function stores static variables like &PL_sv_undef, &PL_sv_yes, &PL_sv_no into hashes and you want overwrite the hash entry, you will get this error.

for example:

void
xs_fnc()
PREINIT:
  HV *hv;
PPCODE:
  hv = newHV();
  hv_store( hv, "key", 3, &PL_sv_undef, 0 );
  ST(0) = sv_2mortal( newRV( sv_2mortal( (SV *) hv ) ) );
  XSRETURN(1);

$hashref = xs_fnc();
$hashref->{'key'} = 'bla'; # error
  • Comment on Re: Modification of non-creatable hash value attempted