Skip to content
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

IsUndefined() breaks r_callback in v8 8.0.357 #75

Closed
JanMarvin opened this issue Nov 29, 2019 · 2 comments · Fixed by #76
Closed

IsUndefined() breaks r_callback in v8 8.0.357 #75

JanMarvin opened this issue Nov 29, 2019 · 2 comments · Fixed by #76

Comments

@JanMarvin
Copy link
Contributor

Since v8 8.0.357 the args[x]->IsUndefined() condition does not work anymore. The R session crashes. If I keep only the Length() condition introduced in #71 all tests succeed.

diff --git a/src/bindings.cpp b/src/bindings.cpp
index 7f17653..f15487c 100644
--- a/src/bindings.cpp
+++ b/src/bindings.cpp
@@ -97,9 +97,9 @@ void r_callback(std::string fun, const v8::FunctionCallbackInfo<v8::Value>& args
     v8::String::Utf8Value arg0(args.GetIsolate(), args[0]);
     Rcpp::String fun(*arg0);
     Rcpp::CharacterVector out;
-    if(args.Length() == 1 || args[1]->IsUndefined()){
+    if(args.Length() == 1){
       out = r_call(fun);
-    } else if(args.Length() == 2 || args[2]->IsUndefined()) {
+    } else if(args.Length() == 2) {
       v8::Local<v8::Object> obj1 = v8::Local<v8::Object>::Cast(args[1]);
       v8::String::Utf8Value arg1(args.GetIsolate(), v8::JSON::Stringify(args.GetIsolate()->GetCurrentContext(), obj1).ToLocalChecked());
       Rcpp::String json(ToCString(arg1));

Not sure what changed this behavior, there have been a few commits in 8.0.357, but I have narrowed it down to this release.

JanMarvin referenced this issue in JanMarvin/v8-R Nov 29, 2019
@JanMarvin
Copy link
Contributor Author

Thanks, wasn't sure if you wanted to keep the IsUndefined() behavior

@jeroen jeroen closed this as completed in #76 Dec 1, 2019
@jeroen
Copy link
Owner

jeroen commented Dec 1, 2019

I don't remember why I used IsUndefined, it may be a legacy thing from V8 way back when.

I do find it strange how upstream keeps silently breaking the apis but your fix seems to work on all systems so 🤷‍♂ . Thanks!!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants