-
-
Notifications
You must be signed in to change notification settings - Fork 219
Rcpp_PreserveObject/Rcpp_ReplaceObject to protect underlying SEXP in String #322
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
Conversation
Good point -- having the I think this looks good. We might slate a time to move to using the |
Was just (ahem) chasing a seg.fault between on Rcpp-using package of mine and one of a colleague. Likely string related ... We sorta-kinda decided that we may as well call the next one 0.12.0, given the And just to be plain, I think we all hate breaking ABIs. But leaving bugs out in the open is worse, no? |
Of course, fixing bugs has the highest priority. Give me some time and let's see how many packages will be broken. Then we can make better decision. |
Thanks, KK, but this may be different: we are not wondering what not longer compiles (== API change) but what, when not recompiled, no longer runs (== ABI change). This is also nasty, and we already required rebuild-due-to-ABI twice. We'd rather avoid it, but bugs are bugs... |
I think I know what you mean. Just let me do some research. Actually we are
|
I don't think it will be ABI breaking if the entire implementation of On Tue, Jul 7, 2015 at 5:22 PM, Kevin Ushey notifications@github.com
|
Yes, good point. |
And FWIW Conrad tossed an Armadillo release candidate at me which I am currently rev.dep-testing, along with Rcpp 'HEAD'. All good so far with 28 out 129 built and only one R CMD check fail (for AFAIK as usual, a missing Suggests: not tested for). |
I think we might need to do a bit more here to make sure that copying and Whenever the object is destroyed we'll call Rcpp_ReleaseObject on the data. Assignment looks good to me via Rcpp_ReplaceObject. @kevinushey Could you take one more look with the above issues in mind? On Wed, Jul 8, 2015 at 8:42 AM, Dirk Eddelbuettel notifications@github.com
|
Once upon a time these two functions just set the magic bit R itself would consult before doing the release. As R is not (yet) using reference counting simply setting the bit again (and again and ...) should do no harm. |
But then when you unset the bit in a destructor are you freeing the other On Wed, Jul 8, 2015 at 9:27 AM, Dirk Eddelbuettel notifications@github.com
|
What on earth are you all talking about unsetting bits. No such thing is done by If that's the only place this SEXP was reachable from, then the GC will do its thing, but under no circumstance does Rcpp or Please show me otherwise if the implementation has evolved to tweaking with the internal bits, I'd like to see that. |
Based on that here is my concern:
Does this effectively free the SEXP from underneath the String instance Seems like it does but I could easily be missing something. On Wed, Jul 8, 2015 at 9:47 AM, Romain François notifications@github.com
|
So it is preserved (by This can be debugged, with some hackery (not cran proof stuff), you can get access to the precious list and traverse it yourself to check how many times a given All of Rcpp would fall apart if it was not preserving the same SEXP multiple times, just think about a function that passes a |
Okay, very good point re: the rest Rcpp. I think we are good here. On Wed, Jul 8, 2015 at 9:57 AM, Romain François notifications@github.com
|
So at least we have a temporary fix (not elegant). @jjallaire I also think it will not be ABI-breaking, so give me some time to rewrite the String class, maybe this weekend. |
This passed a reverse-dependency check with only one new issue -- a seg.fault in package cccp by Bernhard which I'll look into separately -- so I will merge this now. |
Rcpp_PreserveObject/Rcpp_ReplaceObject to protect underlying SEXP in String
This is for #321 .
Rewriting
String
class usingPreserveStorage
will be much elegant, but I am afraid it might break existing code.This PR just provides a simple solution using
Rcpp_PreserveObject
, the underlyingSEXP
will be protect in constructor and unprotect byRcpp_ReleaseObject
.