Skip to content

Protection problems with C++ interfaces #712

@krlmlr

Description

@krlmlr

My package "bindrcpp" provides a C++ interface via // [[Rcpp::interfaces(cpp)]]. I was able to track down spurious segmentation faults (in dplyr, tidyverse/dplyr#2811) to (what I think is) a protection error in the auto-generated C++ wrappers for these interfaces.

The commit krlmlr/bindrcpp@6d1e2bd shows both the problem and the solution: In general, wrap() will perform allocation of R objects, and without extra shielding these can be garbage collected even before the wrapped function is called, because the latter has all SEXP in its signature.

After applying this particular commit, I'm not seeing test failures anymore, which before occurred after a few iterations. Happy to submit a PR.

CC @lionel-.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions