-
-
Notifications
You must be signed in to change notification settings - Fork 218
add template specializations to avoid DATAPTR use #1310
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
Nice stuff. Would you mind if I spend the usual day or two and a half on rev.deps, "just in case" ? |
Nice implementation, LGTM! Given that these now are going to be ASAN errors on CRAN anyways, I'd say it's fine if they trigger errors from our side. |
Very true but it may make updating at CRAN harder for us if we trigger N new things in M packages. |
86cf6ba
to
69cb4dd
Compare
For sure -- we could also consider whether we should allow users (or CRAN) to configure whether out-of-bounds checks should be errors, warnings, or something else. |
Three hours in (had some follow-up to do on RcppArmadillo run first)
2 of the 3 are out of bounds (aum, BART) the third is small numerical diff on test so maybe not us (bayesianVars). PS1: Twelve hours in:
PS2: Twentyfour hours in
|
Will look forward to seeing whether this resolves lme4/lme4#794 (still hoping that what we're seeing is not the revealing of previously cryptic out-of-bounds accesses, but rather things that are legal but trigger an ASAN warning anyway ...) |
The reverse depends run finished just as I was leaving for a two-day bike trip. The results are not terrible but also not something which makes me think we can commit this as is:
Almost all the 'fails' are due to run-time and not install-time so it could be the 'harsher' out of bounds access. I will try to summarize later. |
@kevinushey With the extra delay of me disappearing for 1 1/2 or 2 days 😀 I was now able to summarize the reverse dependency run. As logged, it is essentially 'out of bounds'. So we probably want to preemptively define the 'death by bounds check' away, or maybe tone it down to a message. PS I played a little with a simple define to avoid the current |
Most of them already have ASAN/UBSAN errors on CRAN, and the others will likely have them when the CRAN machinery reaches them. |
I am much less sanguine here as we are (by the standard release pattern) looking into a release in two week (early July) to four weeks (mid July). I think we need to address this, or possibly roll it to the next release with sufficient time to communicate to affected maintainers. (Also, package |
Then, let's make it a warning for now and an error in the next release? |
I ran into errors when I mod'ed it to 'continue' rather than @kevinushey Any insights from your end? |
Thanks for the update, @kevinushey -- I will give this a spin in another reverse-dependency run. Another thing I noticed was that if one where to define the 'off-switch' the code doesn't actually compile cleanly. I tried this diff diff --git a/inst/include/Rcpp/vector/Subsetter.h b/inst/include/Rcpp/vector/Subsetter.h
index 0d8b32a6..0905e1a3 100644
--- a/inst/include/Rcpp/vector/Subsetter.h
+++ b/inst/include/Rcpp/vector/Subsetter.h
@@ -147,7 +147,7 @@ private:
}
#else
template <typename IDX>
- void check_indices(IDX* x, IDX n, IDX size) {}
+ void check_indices(IDX* x, R_xlen_t n, R_xlen_t size) {}
#endif
void get_indices( traits::identity< traits::int2type<INTSXP> > t ) { Can you take a peek? |
Should be good now. We now give a warning rather than a hard error; I indicated in NEWS that this might change in the future. |
In one spot. You left a stop() in the other. On purpose? |
I left https://github.com/RcppCore/Rcpp/pull/1310/files#diff-4d30eca18cf4d872269fc011605a047e2212875dcb25688bd2460986c632064bL144 alone because that was pre-existing code (we already gave a hard error in those cases) but I can switch that to a warning if we want to be uniform? |
Oh, I completely missed that we already stopped there / that that bit was not new code. My bad! |
So I ran another reverse dependency check, and the result summary is here. It has seven failures of which one is due to missing build dependencies and at least one is recurrent leaving five. One is possibly local / spurious (connection issue), leaving four. CRAN may let me get away with arguing that the DATAPTR improvement is worth it. |
We are down to five now. One is possibly a test setup issue 1. One is a package for which CRAN requested other changes. I will open an issue here with links and try to get in touch with the maintainers -- but first things first: I will merge this, and then make a new incremental release 1.0.12.4 with this merged and make it available via the drat (and r-universe) so that the affected maintainers can test with it. Footnotes
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is ready now. Big thank you for preparing it!
Addresses #1308, but note that this PR would turn these out-of-bounds accesses into R errors, and so we might expect to see some CRAN failures. If that feels too aggressive, we could make these warnings instead, or control the behavior with an environment variable (read on package load), or something else.
This PR seeks to avoid some of the crashes seen in packages using Rcpp, where out-of-bounds accessed could trigger an ASAN misaligned read (due to special behavior in DATAPTR attempting to catch such usages).
This PR also now adds bounds checking to offset accessing via
operator[]
for the various Vector classes provided by Rcpp; controlled via the sameRCPP_NO_BOUNDS_CHECK
macro used by the subsetting code.For example:
Would now give:
Checklist
R CMD check
still passes all tests