浏览代码

HPCC-9710 R embedding gives spurious stack errors in Roxie

The R code for checking stack limits assumes that all calls are on the same
thread as the original context was created on - this will not always be
true in ECL (and hardly ever true in Roxie).

Signed-off-by: Richard Chapman <rchapman@hpccsystems.com>
Richard Chapman 12 年之前
父节点
当前提交
781d561743
共有 1 个文件被更改,包括 7 次插入0 次删除
  1. 7 0
      plugins/Rembed/Rembed.cpp

+ 7 - 0
plugins/Rembed/Rembed.cpp

@@ -61,6 +61,7 @@ namespace Rembed
 {
 {
 
 
 // Use a global object to ensure that the R instance is initialized only once
 // Use a global object to ensure that the R instance is initialized only once
+// Because of R's dodgy stack checks, we also have to do so on main thread
 
 
 static class RGlobalState
 static class RGlobalState
 {
 {
@@ -69,6 +70,11 @@ public:
     {
     {
         const char *args[] = {"R", "--slave" };
         const char *args[] = {"R", "--slave" };
         R = new RInside(2, args, true, false, false);
         R = new RInside(2, args, true, false, false);
+        // The R code for checking stack limits assumes that all calls are on the same thread
+        // as the original context was created on - this will not always be true in ECL (and hardly
+        // ever true in Roxie
+        // Setting the stack limit to -1 disables this check
+        R_CStackLimit = -1;
 // Make sure we are never unloaded (as R does not support it)
 // Make sure we are never unloaded (as R does not support it)
 // we do this by doing a dynamic load of the Rembed library
 // we do this by doing a dynamic load of the Rembed library
 #ifdef _WIN32
 #ifdef _WIN32
@@ -133,6 +139,7 @@ extern void unload()
 
 
 MODULE_INIT(INIT_PRIORITY_STANDARD)
 MODULE_INIT(INIT_PRIORITY_STANDARD)
 {
 {
+    queryGlobalState(); // make sure gets loaded by main thread
     return true;
     return true;
 }
 }
 MODULE_EXIT()
 MODULE_EXIT()