Help diagnosing random R.NET crashes

Jul 13, 2012 at 6:44 PM
Edited Jul 16, 2012 at 11:28 PM

I hope somebody can pass along some tips in diagnosing what appears to be random failures.

I have an R script that I have tested using the R Gui and it runs flawlessly every time.  This script uses a custom R package I am working on, but it runs without problems using any of the standard R interfaces.

However, when I source that same script using R.NET, it only works about 50-75% of the time.   It behaves like there is a random chance of getting a good session.  Some days are good. Other days I have a really hard time getting anything to run.  I suspected I had a corrupted version of Windows. So, I used a freshly installed Windows 7 system and I still see the same results.

My test app

  1. initializes R.NET,
  2. sleeps about 500 milliseconds
  3. Execute R command "R.version.string" and read character result to verify connection is working  
  4. executes R script
  5. reads a boolean and integer from global environment
  6. removes data objects in global environment; created by step 2
  7. repeat steps 2-5  1000 times.

When a failure happens it always occurs on the first or second time through the loop above. If it does not fail at the beginning, it always completes running the script 1000 times. This script runs the same sequence of commands using the same data each time.

When it fails I get the following output on stderr;

 Error: C stack usage is too close to the limit
 Error: unprotect_ptr: pointer not found
 Error: unprotect_ptr: pointer not found

About 9 seconds after these messages appear, my test application just exits.

 This failure has occurred durring execution of any of the R commands above. I have even received this error executing the "R.version.string" command during the very first iteration of the loop.  Once this occurrs, I have to close the current R session (includes app exit) and create a new one. Next attempt running the test runs flawlessly with no changes and no system reboot.

I have full execption trapping in place, the error that occurs blows past all my catch statements. It is an untrappible error, so I do not know what the error is.

I am using the latest version of R.NET (rdotnet_a833e72cbf58 April 11, 2012).  I compiled it in debug mode and targeted the x86 CPU.  I have tried using the the official  stable release (version 4.1), but I see the same issue. I am running the 32-bit version of R (and R.NET) on a Windows 7 (64-bit).

Can anyone please give me some tips to help solve this problem? 

Any ideas on how to obtain better diagnostic information?

I do not have a simple code example to include at this time.  I will continue to attempt to create a simplified example that demonstrates the error that uses built in or CRAN packages.


Jul 10, 2014 at 6:59 AM
+1 Same Error. Undiagnosable, on Mono/Ubuntu.