-
Notifications
You must be signed in to change notification settings - Fork 581
Pass clone parameter to CLONE methods as a UV #23325
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
base: blead
Are you sure you want to change the base?
Conversation
Any CLONE method that needs to call sv_clone and friends needs to pass this on as an argument. On older releases such an argument would not be passed, so they would need to take it as an optional argument to work in both cases. E.g. void CLONE(SV* classname, UV uv_params = 0) CODE: CLONE_PARAMS* params = INT2PTR(params); That means this change can break XS modules not taking the extra argument into account. Fortunately most modules have cargo-culted a CLONE(...) from perlxs so they're safe from this change.
Can't C level arg 2nd problem, I've found in rare cases CLONE method runs "too late" during a clone, and Module A, calls into Module B, but Module B didnt get its CLONE sub called yet, so its MY_CXT struct isn't duplicated/ctor-ed yet, and Mod B will now see uninited memory ( HV* PL_modglobal or PP visible package $scalars @arrays get their MGf_DUP MG vtable callback fired earlier than CLONE methods firing AFAIK. |
In this particular case, I guess it could. It kind of feels wrong because in other cases (e.g.
Yeah they're unordered, but that doesn't have anything to do with this PR.
Correct. |
perlmod says:
"Currently CLONE is called with no parameters" should be amended, but this also means modules that don't accept an additional parameter are Doing It Wrong™. (This wording has been in perlmod since 2004; before that, CLONE's parameters were not documented at all.)
Does this mean I can now crash XS modules in pure perl by simply calling |
Good to know, I will adapt that.
Yeah, but the same is true of a lot of others things really (e.g. anything taking a PTROBJ) |
If my_perl or CV* data smuggling is not picked as the final solution. I suggest adding CLONE_PARAMS * type to the root p5p typemap file so the user has less src code opportunities to make a mistake vs a long copy paste of casting the UV to a CLONE_PARAMS * type and EUPXS hides more internals from the user. |
I'm not very invested in any particular solution, I'm mainly invested in solving the problem of "sometimes |
I agree its a defect. |
Any CLONE method that needs to call
sv_clone()
and friends needs to pass this on as an argument.On older releases such an argument would not be passed, so they would need to take it as an optional argument to work in both cases. E.g.
That means this change can break XS modules not taking the extra argument into account. Fortunately most modules have cargo-culted a CLONE(...) from perlxs so they're safe from this change. A quick grep suggests only four CPAN dists are affected such, Data::UUID, Net::LDNS, GObject, and Zonemaster::LDNS