This is not a question but a request to help diagnose and fix a problem.
Using the latest (1.0.2) version of rmongodb the following code crashes the session of R 2.15.2 on Mac OS X. The code works in R 2.15.1 on a different Mac OS X machine.
library(rmongodb)
mongo <- mongo.create('127.0.0.1', db='test')
print(mongo.is.connected(mongo))
mongo.find.one(mongo, 'unknown')
The output is:
> library(rmongodb)
rmongodb package (mongo-r-driver) loaded
Use 'help("mongo")' to get started.
> mongo <- mongo.create('127.0.0.1', db='test')
> print(mongo.is.connected(mongo))
[1] TRUE
> mongo.find.one(mongo, 'unknown')
R(60519) malloc: *** error for object 0x7fff5fbfce10: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
The same type of crash happens if you pass a non-existent command to MongoDB. Again, this used to work under R 2.15.1.
> library(rmongodb)
> mongo <- mongo.create('127.0.0.1', db='test')
> mongo.command(mongo, 'test', list(isMaster=1))
ismaster : 8 true
maxBsonObjectSize : 16 16777216
ok : 1 1.000000
> mongo.command(mongo, 'test', list(fake=1))
R(66743) malloc: *** error for object 0x7fff5fbfde20: pointer being freed was not allocated
*** set a breakpoint in malloc_error_break to debug
Abort trap: 6
I have created an issue in the rmongodb project and would appreciate any help scoping & validating the problem to enable the package developer to hone in on what needs fixing or, perhaps, prove that it is not an rmongodb issue but some strange interaction in my environment.
I will accept an answer from someone who runs the code either on 2.15.1 and 2.15.2 on Mac OS X or on 2.15.2 on Mac OS X and at least one other environment.
According to the package author this issue is fixed on GitHub but CRAN hasn't been updated.
Related
I can't get the h2o to work in my R. It shows the following error. Have no clue what it means. Previously it gave me an error because I didn't have Java 64 bit version. I downloaded the 64bit - restarted my pc - and started the process again and now it gives me this error.
Any suggestions?
library(h2o)
----------------------------------------------------------------------
Your next step is to start H2O:
> h2o.init()
For H2O package documentation, ask for help:
> ??h2o
After starting H2O, you can use the Web UI at http://localhost:54321
For more information visit http://docs.h2o.ai
----------------------------------------------------------------------
Attaching package: ‘h2o’
The following objects are masked from ‘package:stats’:
cor, sd, var
The following objects are masked from ‘package:base’:
%*%, %in%, &&, ||, apply, as.factor, as.numeric, colnames, colnames<-, ifelse,
is.character, is.factor, is.numeric, log, log10, log1p, log2, round, signif, trunc
> h2o.init(nthreads = -1)
H2O is not running yet, starting it now...
Note: In case of errors look at the following log files:
C:\Users\ADM_MA~1\AppData\Local\Temp\RtmpygK1EJ/h2o_Adm_Mayur_started_from_r.out
C:\Users\ADM_MA~1\AppData\Local\Temp\RtmpygK1EJ/h2o_Adm_Mayur_started_from_r.err
java version "9"
Java(TM) SE Runtime Environment (build 9+181)
Java HotSpot(TM) 64-Bit Server VM (build 9+181, mixed mode)
Starting H2O JVM and connecting: ............................................................
[1] "localhost"
[1] 54321
[1] TRUE
[1] -1
[1] "Failed to connect to localhost port 54321: Connection refused"
[1] 127
Error in h2o.init(nthreads = -1) :
H2O failed to start, stopping execution.
In addition: Warning message:
running command 'curl 'http://localhost:54321'' had status 127
Screenshot for h2o error in R
Based on the error message and the troubleshooting we carried out in the comments, it seems that you are using a version of Java (Java 1.9) which is too new for your version of H2O.
Your 2 options seem to be:
Verify that your version of H2O is up to date. If not, update it.
Download a compatible version of Java, i.e. Java 1.8 (you can just use it for this 1 task rather than for everything, if you prefer)
Note that on the main documentation page of H2O v3 it says:
Java 7 or later. Note: Java 9 is not yet released and is not currently
supported.
But at the same time they usually have several Beta and Alpha development branches going, so you might find one of those that works with Java 9.
So if anyone else is facing the same issue.
My recommendation (after spending about over 10 hours trying to figure this out (worth mentioning)) is check your version of java.
If it's higher than 8 then either keep it remove it.
I removed it because I didn't want to deal with setting the JAVA Home function in R and to reduce work.
Make sure you install Java 7 or 8 but a 64 bit version. h2o doesn't work if you have 32 bit.
Then voila! Just go ahead and type install.package('h2o') in your rstudio.
I wanted to be extra careful in my final attempt of this so unloaded and uninstalled the library because I had installed it before and then installed it again and then loaded it using library(h2o) and then h20.init() worked just fine.
I am going over 'Create Graphs and Plots Using R (Data Science End-to-End Walkthrough)' procedure.
Please check link https://msdn.microsoft.com/en-us/library/mt629162.aspx
I have issue with step 'Create a Map Plot', when executing:
myplots <- rxExec(mapPlot, inDataSource, googMap, timesToRun = 1)
plot(myplots[[1]][["myplot"]])
I am getting error:
Warning: namespace 'CompatibilityAPI' is not available and has been replaced
by .GlobalEnv when processing object 'inputObject'
====== DESKTOP-PHAA5KQ ( process 1 ) has started run
at 2017-01-24 11:39:07.56 ======
Warning: namespace 'CompatibilityAPI' is not available and has been replaced
by .GlobalEnv when processing object 'inputObject'
Loading required package: ggplot2
Loading required package: maps
# ATTENTION: maps v3.0 has an updated 'world' map. #
# Many country borders and names have changed since 1990. #
# Type '?world' or 'news(package="maps")'. See README_v3. #
Error in slot(from, what) :
no slot of name "maxColWidth" for this object of class "RxSqlServerData"
Calls: source ... anyStrings -> validityMethod -> as -> asMethod -> slot
Execution halted
Error in rxCompleteClusterJob(hpcServerJob, consoleOutput, autoCleanup) :
No results available - final job state: failed
> plot(myplots[[1]][["myplot"]])
Error in plot(myplots[[1]][["myplot"]]) : object 'myplots' not found
Thanks in advance for any suggestion.
I think this is a version issue.
This question gave me some context. Your IDE or client may not be using the same version of R as R-Services.
Check the version of R in your IDE and R-Services using:
R.Version()
For R-Services, navigate to C:\Program Files\Microsoft SQL Server\MSSQL13.YOUR_SERVER_NAME\R_SERVICES\bin then run R.exe as admin.
You might see that the versions are different. In my case I was running 3.3.2 in RStudio but have 3.2.2 in R-Services.
For RStudio, here's how to use different versions of R. Starting RStudio with the Control key held down allowed me to select the R-Services instance and run the code successfully.
You can also change your default library path so that whenever you open your IDE you're working with the server's version of R.
In my case both R services and R studio had same version. And the error message was ggplot2 is required by ggmap. For my solution I uninstalled both ggplot2 and ggmap, Closed R studio and reopened it with administrative rights.
Since I upgraded to R Version 3.3.1, when I try and exit from R using q(), I get the following message: "Error in setInternet2(TRUE) : use != NA is defunct"
This happens on every exit.
I haven't used setInternet2 and it is not in .Rprofile, or .Rprofile.site.
I do not have a .Renviron.site file.
I checked I had the right setup files using:
file.path(getwd(),".Rprofile")
file.path(getwd(),".Rprofile.Site")
file.path(getwd(),".Renviron.site")
I'm using R version 3.3.1 (2016-06-21) and Windows 7 x64 Service Pack 1
I know it's a late reply, but for the record:
This happened because
as of R 3.3.0, setInternet2 is now defunct. Use of setInternet2 should be replaced with the method = "wininet" argument to the url and download.file functions
So it's not like anything else got changed or added, just before this wouldn't have caused such a message.
To know where it stems from is maybe not that easy, it could also be that you had in the past set it and saved your workspace and never cleaned your workspace completely afterwards.
When I installed and opened R studio (0.98.1091) in my Macbook ( OS X 10.9.5), it shows an error message as follows. I have R (3.1.2) in my application, which seems work fine.
I also tried R (3.0.3) which works fine, just in case the higher version of R (3.1.2) conflicts with R studio with some reason. But, each time, R-studio kept giving me the same error message after installed.
ERROR r error 4 (R code execution error)
[errormsg=Error in identical(call[[iL]],quote(
doTryCatch)) :
7 arguments passed to .Internal(identical) which
requires 5
, code=local(source("/Volumes/
Rstudio-0.98.1091
1/Rstudio.app/Contents/
Resources/R/ToolsR",local=TRUE, echo=FALSE, verbose=FALSE,
keep.source=FALSE, encoding='UTF-8'))}; OCCURRED
AT:core::Error r::exec::<anaonymous
namespace>::evaluateExpressionsUnsafe(SEXP,SEXP,SEXP*,sexp::Protect *) /Users
/rstudio/rstudio/src/cpp/r/RExce.cpp:148
It would be much appreciated if anyone could suggest a solution for this.
Is there a simple way to trigger a crash in R? This is for testing purposes only, to see how a certain program that uses R in the background reacts to a crash and help determine if some rare problems are due to crashes or not.
The easiest way is to call C-code. C provides a standard function abort()[1] that does what you want. You need to call: .Call("abort").
As #Phillip pointed out you may need to load libc via:
on Linux, dyn.load("/lib/x86_64-linux-gnu/libc.so.6") before issuing .Call("abort"). The path may of course vary depending on your system.
on OS X, dyn.load("/usr/lib/libc.dylib")
on Windows (I just tested it on XP as I could not get hold of a newer version.) you will need to install Rtools[2]. After that you should load dyn.load("C:/.../Rtools/bin/cygwin1.dll").
There is an entire package on GitHub dedicated to this:
crash
R package that purposely crash an R session. WARNING: intended
for test.
How to install a package from github is covered in other questions.
I'm going to steal an idea from #Spacedman, but I'm giving him full conceptual credit by copying from his Twitter feed:
Segfault #rstats in one easy step:
options(device=function(){});plot(1)
reported Danger, will crash your R session.
— Barry Rowlingson (#geospacedman) July 16, 2014
As mentioned in a comment to your question, the minimal approach is a simple call to the system function abort(). One way to do this in one line is to
R> Rcpp::cppFunction('int crashMe(int ignored) { ::abort(); }');
R> crashMe(123)
Aborted (core dumped)
$
or you can use the inline package:
R> library(inline)
R> crashMe <- cfunction(body="::abort();")
R> crashMe()
Aborted (core dumped)
$
You can of course also do this outside of Rcpp or inline, but then you need to deal with the system-dependent ways of compiling, linking and loading.
I'll do this in plain C because my C++-foo isn't Dirkian:
Create a C file, segv.c:
#include <signal.h>
void crashme(){raise(SIGSEGV);}
Compile it at the command line (windows users will have to work this out for themselves):
R CMD SHLIB segv.c
In R, load and run:
dyn.load("segv.so") # or possibly .dll for Windows users
.C("crashme")
Producing a segfault:
> .C("crashme")
*** caught segfault ***
address 0x1d9e, cause 'unknown'
Traceback:
1: .C("crashme")
Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection: 1
aborting ...
Segmentation fault
This is the same behaviour as the one Thomas references in the graphics system bug report which I have filed and might get fixed one day. However this two-liner will always raise a segfault...
Maybe Dirk can one-line-Rcpp-ise it?
If you want to crash your R, try this
lapply("", function(x) eval(sys.call(1)))
(Save everything before running because this immediately results in "R Session Aborted")
Edit: This works for me on Windows 10.