Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.
Sign upProtection problems with C++ interfaces #712
Comments
|
It's been a while but we did revise that aspect once or twice already. Could you provide a reproducible example we could call before and after? With and without |
|
Thanks. That commit is the reprex, hub clone krlmlr/bindrcpp
cd bindrcpp
git checkout 6d1e2bd^ # omit ^ to see fixed behavior
R -q -e 'devtools::test(reporter = c("summary", "stop"))' |
|
I am sorry but I don't use And involving an entire different package strikes me as a little far away from "minimal". |
|
Give me a minute to translate that for you. I seriously recommend checking out |
|
Yes, I read about it. So far exiting command-line and magit are good enough for me. |
|
who needs hub when there's magit ;) |
|
Thanks for the pointers, will check out magit. Now, for the reprex:
If you install from a clone with library(bindrcpp)
gctorture2(29)
for (i in 1:1000) {
print(i)
env_cb <- bindrcpp:::cpp_create_environment(letters, "toupper")
env <- env_cb$env
env2_cb <- bindrcpp:::cpp_create_environment(LETTERS, "tolower", parent = env)
env2 <- env2_cb$env
stopifnot(identical(get("a", env2), "A"))
stopifnot(identical(get("x", env2), "X"))
stopifnot(identical(env2$a, NULL))
stopifnot(identical(env2$x, NULL))
stopifnot(identical(env2$B, "b"))
stopifnot(identical(env2$Y, "y"))
stopifnot(identical(length(ls(env2)), length(letters)))
env2$a <- "a"
stopifnot(identical(get("a", env2), "a"))
} |
|
PR is here: #713
…On Wed, Jun 14, 2017 at 8:45 AM, Kirill Müller ***@***.***> wrote:
Thanks for the pointers, will check out magit.
Now, for the reprex:
1. Install bindrcpp from https://github.com/krlmlr/bindrcpp/tree/
a7759861e780fa84cf022f31809af3744599abea
<https://github.com/krlmlr/bindrcpp/tree/a7759861e780fa84cf022f31809af3744599abea>
2. Run the script below, it should stop very soon
3. Now install the fixed version from https://github.com/krlmlr/
bindrcpp/tree/6d1e2bde24fd8a26a3911923cd2e6cd0a1a29180
<https://github.com/krlmlr/bindrcpp/tree/6d1e2bde24fd8a26a3911923cd2e6cd0a1a29180>
4. Run the script below, it should run until the end
If you install from a clone with R CMD INSTALL ., you need to remove
src/*.o before switching to a different version.
library(bindrcpp)
gctorture2(29)
for (i in 1:1000) {
print(i)
env_cb <- bindrcpp:::cpp_create_environment(letters, "toupper")env <- env_cb$envenv2_cb <- bindrcpp:::cpp_create_environment(LETTERS, "tolower", parent = env)env2 <- env2_cb$env
stopifnot(identical(get("a", env2), "A"))
stopifnot(identical(get("x", env2), "X"))
stopifnot(identical(env2$a, NULL))
stopifnot(identical(env2$x, NULL))
stopifnot(identical(env2$B, "b"))
stopifnot(identical(env2$Y, "y"))
stopifnot(identical(length(ls(env2)), length(letters)))#expect_error(env2$B <- "B", "read-only")env2$a <- "a"
stopifnot(identical(get("a", env2), "a"))
}
—
You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub
<#712 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AAGXx0z3KK_9S8UeYOTrwAMya8ICCDlNks5sD9XWgaJpZM4N5zBG>
.
|
Add Shield around parameters in Rcpp::interfaces (fixes #712)
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 allSEXPin 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-.