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

use read-only variants of {STRING/VECTOR}_PTR #1317

Merged
merged 5 commits into from
Jul 11, 2024

Conversation

kevinushey
Copy link
Contributor

Pull Request Template for Rcpp

Closes #1316. I tried to do this in a way that lets us use the read-only variants with newer versions of R, and fall back to the non-API variants for older versions of R.

Checklist

  • Code compiles correctly
  • R CMD check still passes all tests
  • Preferably, new tests were added which fail without the change
  • Document the changes by file in ChangeLog

@kevinushey kevinushey requested a review from eddelbuettel July 7, 2024 12:35
# define RCPP_STRING_PTR STRING_PTR_RO
#else
# define RCPP_STRING_PTR STRING_PTR
#endif
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very nice. I wondered about the need to make this conditonal on existence of the new macro or min R version.

@@ -50,7 +54,8 @@ void char_set_string_elt(SEXP x, R_xlen_t i, const char* value) {

// [[Rcpp::register]]
SEXP* get_string_ptr(SEXP x) {
return STRING_PTR(x);
// TODO: should we deprecate this?
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May need a full rev.dep run to see if it is being called?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe we leave this code as-is for this PR, and then later test their removal in a separate PR, to see what breaks?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds like a plan!

@eddelbuettel
Copy link
Member

eddelbuettel commented Jul 7, 2024

Reverse-depends check running. Looks good so far but many more packages to go ...

Update 1 @ 3.6h in: 177 pass, 0 fail

Update 2 @ 13.6h in: 781 pass, 1 known-not-new fail

Update 3 @ 24h in: 1410 pass, no new regression (3 fail for 'other' reasons, 14 skip)

Update 4 on 07/10: This finished without new issue but we realized we need a second run one which is now running.

Update 5 @ 15.6h: 1540 successes, one known fail and three fail for lack of depends, 14 skipped

Update 6 @ 31.1h (thanks, ccache): 2829 successes, seven unrelated fails, 25 skipped.

So will merge and proceed with release.

@eddelbuettel
Copy link
Member

eddelbuettel commented Jul 8, 2024

@kevinushey I just ran an r-devel CMD check --as-cran and I still got the warning on this branch.

edd@rob:~/git/rcpp(bugfix/vector-string-ptr-read-only)$ git ls|head -4
* edcf98f8 - (HEAD -> bugfix/vector-string-ptr-read-only, origin/bugfix/vector-string-ptr-read-only) one more const (30 hours ago) <Kevin Ushey>
* 1cb485b5 - another const_cast (31 hours ago) <Kevin Ushey>
* cd0f41ac - use read-only variants of {STRING/VECTOR}_PTR (31 hours ago) <Kevin Ushey>
* 51896112 - (origin/master, origin/HEAD, master) Release 1.0.12.4 (2 weeks ago) <Dirk Eddelbuettel>
edd@rob:~/git/rcpp(bugfix/vector-string-ptr-read-only)$ 

I named that 1.0.12.4.1 and it is the one I am testing now but:

edd@rob:~/git/rcpp(bugfix/vector-string-ptr-read-only)$ rdcc.sh Rcpp_1.0.12.4.1.tar.gz                                                                                            
* using log directory ‘/tmp/r/Rcpp.Rcheck’                                                                                                                                        
* using R Under development (unstable) (2024-07-07 r86877)                                                                                                                        
* using platform: x86_64-pc-linux-gnu                                                                                                                                             
* R was compiled by                                                                                                                                                               
    gcc (Ubuntu 13.2.0-4ubuntu3) 13.2.0                                                                                                                                           
    GNU Fortran (Ubuntu 13.2.0-4ubuntu3) 13.2.0                               
* running under: Ubuntu 23.10                                                            
* using session charset: UTF-8                                                           
* using option ‘--as-cran’                                                               
* checking for file ‘Rcpp/DESCRIPTION’ ... OK                                               
* this is package ‘Rcpp’ version ‘1.0.12.4.1’     
[....]
* checking compiled code ... NOTE
File ‘Rcpp/libs/Rcpp.so’:
  Found non-API calls to R: ‘STRING_PTR’, ‘VECTOR_PTR’

Compiled code should not call non-API entry points in R.

See ‘Writing portable packages’ in the ‘Writing R Extensions’ manual,
and section ‘Moving into C API compliance’ for issues with the use of non-API entry points.
* checking sizes of PDF files under ‘inst/doc’ ... OK

Any idea why? Is that an error in the string matching / grepping? Should we not call them RCPP_{STRING,VECTOR}_PTR ?

PS: Hm. Running strings on Rcpp/libs/Rcpp.so does show it for old and new.

@@ -112,7 +112,7 @@ namespace Rcpp {
case BCODESXP: return "BCODESXP";
case EXTPTRSXP: return "EXTPTRSXP";
case WEAKREFSXP: return "WEAKREFSXP";
#if R_Version >= R_Version(4,4,0) // replaces S4SXP in R 4.4.0
#if R_VERSION >= R_Version(4,4,0) // replaces S4SXP in R 4.4.0
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one seemed a bit strange; I'm not sure if this really worked before (or, if it did, why it did)?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that looks like you spotted an 'ooops'. Thank you!

And thanks for the update. It look good. Will have to run another rev.dep run but we should be good by end of week. Fingers crossed!

@eddelbuettel eddelbuettel merged commit 9c5f71c into master Jul 11, 2024
16 checks passed
@eddelbuettel eddelbuettel deleted the bugfix/vector-string-ptr-read-only branch August 20, 2024 18:14
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

Successfully merging this pull request may close these issues.

New CRAN warnings on STRING_PTR and VECTOR_PTR
2 participants