New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Strange behavior when assigning values in Environment, due to GC #780
Comments
Phew, that was long. Not sure what the operational approach may be. Tell people to wrap their What is the status of |
I learned that configuring R with library(Rcpp)
cppFunction(
code = '
Environment f() {
Environment env = Function("new.env")();
env["A"] = 123;
return env;
}
'
)
gctorture(TRUE)
e <- f()
gctorture(FALSE) The result:
Wrapping it with |
Thanks for the investigation! I suspect the error lies here: Rcpp/inst/include/Rcpp/api/meat/proxy.h Line 131 in 2645fce
The call to I'll see if I can get this fixed up! |
Interesting. This got closed via @kevinushey wring 'should resolve ...' in the initial comment box. I had thought one needed '(closes ...)' in the title. |
Any of the following work:
c.f. https://help.github.com/articles/closing-issues-using-keywords/ |
In any comment box or just the first? That it works outside of Title: was news to me. |
Only in the initial box or as part of the chunk per: |
I've been running into a very hard-to-debug problem which I believe is due to a GC during assignment to an Environment. In some cases, the result of assignment into an Environment has the wrong type, and in other cases, the Environment somehow gets lost.
Here is an example to run in a clean R session:
When I run this on my Mac, here's what it prints out for the last commands:
Inspecting the objects gives this:
If I run the code a second time, then the results turn out normal. This is the output from a second run:
I get the exact same result when I run the same code in the r-base Docker image. To reproduce:
When I run the same code in a custom build of R-devel with PROTECTCHECK defined, I get something else weird:
e
simply never gets assigned.If the strings get wrapped with
CharacterVector()
, then the problem doesn't happen. Unlike the code above, this code works fine:In my particular case, the problem happens with httpuv. When I run the PROTECTCHECK build of R, I get this error in some httpuv code when it assigns a string to an environment:
The code in question looks like this:
And many other places where a string is assigned results in the same error message. Wrapping all of them in
CharacterVector()
seems to make the error go away.If it would help, I can provide the Dockerfile used to create the build of R with PROTECTCHECK defined.
The text was updated successfully, but these errors were encountered: