[Rd] changes in R-devel and zero-extent objects in Rcpp

Ben Bolker bbo|ker @end|ng |rom gm@||@com
Mon Jun 10 17:02:38 CEST 2024


   Thanks, that's very useful.

   AFAICT, in the problematic case we are doing some linear algebra with 
zero-column matrices that are mathematically well-defined (and whose 
base-R equivalents work correctly). It's maybe not surprising that 
Eigen/RcppEigen would do some weird stuff in this edge case.  I'll see 
if I can come up with some pure RcppEigen/Eigen examples to illustrate 
the problem ...

   cheers
    Ben



On 2024-06-10 10:12 a.m., Mikael Jagan wrote:
> 
> The ASan output is:
> 
>      > reference binding to misaligned address 0x000000000001 for type 
> 'const double', which requires 8 byte alignment
> 
> That there is a "reference" to 0x1 means that there really _is_ an 
> attempt to
> access memory there.  The stack trace provided by ASan tells you exactly 
> where
> it happens: line 100 of
> RcppEigen/inst/include/Eigen/src/Core/products/GeneralMatrixMatrixTriangular.h:
> 
>      for(Index k2=0; k2<depth; k2+=kc)
>      {
>        const Index actual_kc = (std::min)(k2+kc,depth)-k2;
> 
> 
>        // note that the actual rhs is the transpose/adjoint of mat
>        pack_rhs(blockB, rhs.getSubMapper(k2,0), actual_kc, size);
>                         ^^^^^^^^^^^^^^^^^^^^^^
> 
> where 'rhs' is an object wrapping the pointer with a method 
> getSubMapper(i, j)
> for accessing the data like a matrix.  In the first loop iteration, you 
> access
> rhs[0]; there is no defensive test for 'rhs' of positive length.
> 
> So ASan _is_ revealing an illegal access, complaining only now (since 
> r86629)
> because _now_ the address that you access illegally is misaligned.

-- 
Dr. Benjamin Bolker
Professor, Mathematics & Statistics and Biology, McMaster University
Director, School of Computational Science and Engineering
(Acting) Graduate chair, Mathematics & Statistics
 > E-mail is sent at my convenience; I don't expect replies outside of 
working hours.



More information about the R-devel mailing list