Hi! Look at cpan/Encode/Encode.xs for XS functions. Every one has different check if first argument can be modified or not. Some functions have SvPOK() check, some SvREADONLY(), SvSMAGICAL(src), SvGMAGICAL() and some SvIsCOW(). After these check every XS function calling either sv_force_normal() or sv_mortalcopy() or sv_newmortal()+sv_copypv(). And some none. In apidoc is documented macro SvTHINKFIRST() which I understand is that which needs to be called for checking if sv_force_normal() is needed or not. I believe that for calling sv_utf8_upgrade() is needed to call sv_mortalcopy() first (to prevent modification of input scalar). Can some expert look at that code if this is enough to make sv argument modifiable? if (SvTHINKFIRST(sv)) sv_force_normal(sv) I think because of this problem in Encode (which is in core) there are bugs like these: https://rt.cpan.org/Public/Bug/Display.html?id=117158 https://github.com/dankogai/p5-encode/pull/66 (PS: please CC me as I'm not subscribed to this high volume list)Thread Next