Re: [Rd] [External] Possible ALTREP bug

2021-06-17 Thread Gabriel Becker
Hi Toby, Just to be more concrete about why to avoid REAL and about the iteration macros Luke mentioned. The ITERATE_BY_REGION* macros in include/R_ext/Itermacros.h are built on top of *_GET_REGION rather than REAL/INTEGER. The key difference here is that REAL/INTEGER go down to the Dataptr

Re: [Rd] [External] Possible ALTREP bug

2021-06-17 Thread luke-tierney
On Thu, 17 Jun 2021, Toby Hocking wrote: Oliver, for clarification that section in writing R extensions mentions VECTOR_ELT and REAL but not REAL_ELT nor any other *_ELT functions. I was looking for an explanation of all the *_ELT functions (which are apparently new), not just VECTOR_ELT.

Re: [Rd] [External] Possible ALTREP bug

2021-06-17 Thread Toby Hocking
Oliver, for clarification that section in writing R extensions mentions VECTOR_ELT and REAL but not REAL_ELT nor any other *_ELT functions. I was looking for an explanation of all the *_ELT functions (which are apparently new), not just VECTOR_ELT. Thanks Simon that response was very helpful. One

Re: [Rd] [External] Possible ALTREP bug

2021-06-16 Thread Simon Urbanek
The usual quote applies: "use the source, Luke": $ grep _ELT *.h | sort Rdefines.h:#define SET_ELEMENT(x, i, val) SET_VECTOR_ELT(x, i, val) Rinternals.h: The function STRING_ELT is used as an argument to arrayAssign even Rinternals.h:#define VECTOR_ELT(x,i)((SEXP *) DATAPTR(x))[i]

Re: [Rd] [External] Possible ALTREP bug

2021-06-16 Thread Oliver Madsen
*_ELT accessor functions are described in "vector accessor functions" in Writing R extensions. https://cran.r-project.org/doc/manuals/r-release/R-exts.html#Vector-accessor-functions On Wed, Jun 16, 2021 at 4:22 PM Toby Hocking wrote: > By the way, where is the documentation for INTEGER_ELT,

Re: [Rd] [External] Possible ALTREP bug

2021-06-16 Thread Toby Hocking
By the way, where is the documentation for INTEGER_ELT, REAL_ELT, etc? I looked in Writing R Extensions and R Internals but I did not see any mention. REAL_ELT is briefly mentioned on https://svn.r-project.org/R/branches/ALTREP/ALTREP.html Would it be possible to please add some mention of them to

Re: [Rd] [External] Possible ALTREP bug

2021-05-28 Thread luke-tierney
Since the INTEGER_ELT, REAL_ELT, etc, functions are fairly new it may be possible to check that places where they are used allow for them to allocate. I have fixed the one that got caught by Gabor's example, and a rchk run might be able to pick up others if rchk knows these could allocate. (I may

Re: [Rd] [External] Possible ALTREP bug

2021-05-28 Thread Gabriel Becker
Hi Jim et al, Just to hopefully add a bit to what Luke already answered, from what I am recalling looking back at that bioconductor thread Elt methods are used in places where there are hard implicit assumptions that no garbage collection will occur (ie they are called on things that aren't

Re: [Rd] [External] Possible ALTREP bug

2021-05-28 Thread Jim Hester
>From reading the discussion on the Bioconductor issue tracker it seems like the reason the GC is not suspended for the non-string ALTREP Elt methods is primarily due to performance concerns. If this is the case perhaps an additional flag could be added to the `R_set_altrep_*()` functions so

Re: [Rd] [External] Possible ALTREP bug

2021-05-28 Thread Gábor Csárdi
Thank you Luke, that makes a lot of sense, Gabor On Fri, May 28, 2021 at 3:41 PM wrote: > > integer and real Elt methods are not expected to allocate. You would > have to suspend GC to be able to do that. This currently can't be done > from package code. > > Best, > > luke > > On Fri, 28 May

Re: [Rd] [External] Possible ALTREP bug

2021-05-28 Thread luke-tierney
integer and real Elt methods are not expected to allocate. You would have to suspend GC to be able to do that. This currently can't be done from package code. Best, luke On Fri, 28 May 2021, Gábor Csárdi wrote: I have found some weird SEXP corruption behavior with ALTREP, which could be a