From the look of it, once $y is weakened, the hash gets a magic
back-reference attached to it.
Before the weakening of $y
DB<5> Dump($x)
SV = RV(0x817be1c) at 0x816329c
REFCNT = 1
FLAGS = (ROK)
RV = 0x8163350
SV = PVHV(0x84cdbf8) at 0x8163350
REFCNT = 2
FLAGS = (SHAREKEYS)
IV = 1
NV = 0
ARRAY = 0x82f65d0 (0:7, 1:1)
hash quality = 100.0%
KEYS = 1
FILL = 1
MAX = 7
RITER = -1
EITER = 0x0
Elt "a" HASH = 0xca2e9442
SV = PV(0x814cea4) at 0x81633a4
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x8164990 "worked\n"\0
CUR = 7
LEN = 8
After the weakening of $y
DB<6> Dump($x)
SV = RV(0x817be1c) at 0x816329c
REFCNT = 1
FLAGS = (ROK)
RV = 0x8163350
SV = PVHV(0x84cdbf8) at 0x8163350
REFCNT = 1
FLAGS = (RMG,SHAREKEYS)
IV = 1
NV = 0
MAGIC = 0x8574020
MG_VIRTUAL = &PL_vtbl_backref
MG_TYPE = PERL_MAGIC_backref(<)
MG_FLAGS = 0x02
REFCOUNTED
MG_OBJ = 0x8525484
SV = PVAV(0x84c4a54) at 0x8525484
REFCNT = 2
FLAGS = ()
IV = 0
NV = 0
ARRAY = 0x84aafb8
FILL = 0
MAX = 3
ARYLEN = 0x0
FLAGS = (REAL)
Elt No. 0
SV = RV(0x817be58) at 0x81632cc
REFCNT = 1
FLAGS = (ROK,WEAKREF,IsUV)
RV = 0x8163350
SV = PVHV(0x84cdbf8) at 0x8163350
REFCNT = 1
FLAGS = (RMG,SHAREKEYS)
IV = 1
NV = 0
MAGIC = 0x8574020
MG_VIRTUAL = &PL_vtbl_backref
MG_TYPE = PERL_MAGIC_backref(<)
MG_FLAGS = 0x02
REFCOUNTED
MG_OBJ = 0x8525484
SV = PVAV(0x84c4a54) at 0x8525484
REFCNT = 2
FLAGS = ()
IV = 0
NV = 0
ARRAY = 0x84aafb8
FILL = 0
MAX = 3
ARYLEN = 0x0
FLAGS = (REAL)
ARRAY = 0x82f65d0 (0:7, 1:1)
hash quality = 100.0%
KEYS = 1
FILL = 1
MAX = 7
RITER = -1
EITER = 0x0
ARRAY = 0x82f65d0 (0:7, 1:1)
hash quality = 100.0%
KEYS = 1
FILL = 1
MAX = 7
RITER = -1
EITER = 0x0
Elt "a" HASH = 0xca2e9442
SV = PV(0x814cea4) at 0x81633a4
REFCNT = 1
FLAGS = (POK,pPOK)
PV = 0x8164990 "worked\n"\0
CUR = 7
LEN = 8
The #perl channel recommends taking the cloning code from sv.c to handle
the various types of SV cloning that you don't current handle.
Specifically (in my case) that for PERL_MAGIC_backref(<)