Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Inline::C doesn't know when to sv_force_normal or to respect SvREADONLY #57

Open
wchristian opened this issue Jan 14, 2017 · 0 comments

Comments

@wchristian
Copy link
Contributor

Found in Perl-GPU/OpenGL-Modern#16

This code does not work reliably: https://gist.github.com/wchristian/6df5740d442002a311cbeb8282cfca4d

Zefram and mst opined in #p5p that this might be fixable:

(Zefram) your four() function doesn't sv_force_normal() or otherwise respect SvREADONLY
(mst) I guess nobody realised they needed to teach Inline::C about that
(Zefram) Inline::C can't tell whether the function body is going to try to mutate the string. XS has the same problem
(Mithaldu) is there a quick and common way to declare those inputs as "gonna mutate those"?
(Zefram) no, it's a rare need
(Zefram) you'll have to take an SV* and do it yourself, or create a custom typemap to do it if you need it a lot
(Zefram) the failure to respect SvREADONLY is a reportable bug in any case
(Mithaldu) how does one normally respect SvREADONLY?
(Zefram) if(SvREADONLY(argsv)) croak("woah nelly!");
(Zefram) sv_force_normal() is a better way, because COWed strings are SvREADONLY but may actually be mutatable
(Zefram) sv_force_normal() will de-COW and remove the SvREADONLY status if you're allowed to mutate the scalar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant