How to crash R?
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
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 loaddyn.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.