[Rcpp-devel] Passing pointers to objects between libs results in weird UBSAN warning

Dirk Eddelbuettel edd at debian.org
Mon Aug 20 17:39:43 CEST 2018


On 20 August 2018 at 16:26, Jan van der Laan wrote:
| Hi Dirk,
| 
| The suggestion of Iñaki has been changed in the github code and also the 
| visitor stuff is not needed to trigger the exception.
| 
| 
| On 20-08-18 16:01, Dirk Eddelbuettel wrote:
| 
| > 
| > The only thought I had so far (and I had no time to play with the code) is to
| > maybe wrap Rcpp::Shield<> around the XPtr object.
| 
| I have to say that I am currently on the subway with a spotty internet 
| connection, so searching is hard, but I have trouble finding 
| documentation for shield. From what I could find, it would call a

There is very little of that :-/

| PROTECT on contruction and UNPROTECT on destruction. Is that correct. 
| Should I do that in pkg1 or pkg2?

I would. In essence in C++ you the ctor and dtor "for free" and we use that
to wrap objects.  And generally speaking that is better stronger than the
PROTECT and UNPROTECT as we can rely on the scope resolution to have it
triggered. So I would try it. Then again, it may not help, but we find it
made the Rcpp code better.

Dirk

| Thanks.
| 
| Jan
| 
| > 
| > Dirk
| > 
| 
| 
| 

-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the Rcpp-devel mailing list