编辑文件时Rstudio rsession挂起

时间:2017-10-13 22:16:42

标签: r ubuntu rstudio

我已经玩了几个小时这个问题了,我想我终于可以重复了。

当我开始一个新的Rstudio会话时,一切正常,没有问题。我甚至可以加载对象并执行正确的代码。

编辑当前文件时出现问题。一旦我编辑该文件,我就不能再执行命令了,当我查看top的CPU使用情况时,它显示rsession正在使用100%CPU并且它永远不会停止。在此期间,我可以继续编辑文件,Rstudio GUI似乎工作正常,但代码执行被冻结。我也无法在那时保存文件。

编辑:我尝试编辑的文档类型是.Rmd降价文档。我只是尝试在非markdown R脚本中运行相同的代码,它运行正常。这个问题必须以某种方式与降价相关。

EDIT2:^^ nevermind,即使不是.Rmd文件,问题仍然存在。将脚本保存为普通的.R脚本后,它会导致rsession再次挂起。

EDIT3:我忘了提到这是最近发生的事情,可能是由更新的R版本,Rstudio版本或系统库引起的。昨天我能够在Rstudio中编辑这个脚本而没有任何问题。我本周更新了Rstudio,但直到几天后才看到这个问题。我很快就更新了我的系统,之后可能还更新了R版本。我正在努力了解这是如何导致当前问题的。

EDIT4:找到导致错误的代码段,发布在下面。

发生错误时(编辑文件后)

的rsession的Backtrace
Thread 1 "rsession" received signal SIGTERM, Terminated.
0x00007fbd0cb5ab38 in ?? () from /usr/lib/R/lib/libR.so
(gdb) backtrace
#0  0x00007fbd0cb5ab38 in ?? () from /usr/lib/R/lib/libR.so
#1  0x00007fbd0cb71196 in ?? () from /usr/lib/R/lib/libR.so
#2  0x00007fbd0cb72499 in ?? () from /usr/lib/R/lib/libR.so
#3  0x00007fbd0cb6ae8c in Rf_eval () from /usr/lib/R/lib/libR.so
#4  0x00007fbd0cb6b3b9 in ?? () from /usr/lib/R/lib/libR.so
#5  0x00007fbd0cb6b878 in ?? () from /usr/lib/R/lib/libR.so
#6  0x00007fbd0cb6132d in ?? () from /usr/lib/R/lib/libR.so
#7  0x00007fbd0cb6aa88 in Rf_eval () from /usr/lib/R/lib/libR.so
#8  0x00007fbd0cb6b3b9 in ?? () from /usr/lib/R/lib/libR.so
#9  0x00007fbd0cb6b878 in ?? () from /usr/lib/R/lib/libR.so
#10 0x00007fbd0cb6132d in ?? () from /usr/lib/R/lib/libR.so
#11 0x00007fbd0cb6aa88 in Rf_eval () from /usr/lib/R/lib/libR.so
#12 0x00007fbd0cb6b3b9 in ?? () from /usr/lib/R/lib/libR.so
#13 0x00007fbd0cb6b878 in ?? () from /usr/lib/R/lib/libR.so
#14 0x00007fbd0cb6132d in ?? () from /usr/lib/R/lib/libR.so
#15 0x00007fbd0cb6aa88 in Rf_eval () from /usr/lib/R/lib/libR.so
#16 0x00007fbd0cb6b3b9 in ?? () from /usr/lib/R/lib/libR.so
#17 0x00007fbd0cb6b878 in ?? () from /usr/lib/R/lib/libR.so
#18 0x00007fbd0cb6132d in ?? () from /usr/lib/R/lib/libR.so
#19 0x00007fbd0cb6aa88 in Rf_eval () from /usr/lib/R/lib/libR.so
#20 0x00007fbd0cb6b3b9 in ?? () from /usr/lib/R/lib/libR.so
#21 0x00007fbd0cb6b878 in ?? () from /usr/lib/R/lib/libR.so
#22 0x00007fbd0cb6132d in ?? () from /usr/lib/R/lib/libR.so
#23 0x00007fbd0cb6aa88 in Rf_eval () from /usr/lib/R/lib/libR.so
#24 0x00007fbd0cb6ceaf in ?? () from /usr/lib/R/lib/libR.so
#25 0x00007fbd0cb623c0 in ?? () from /usr/lib/R/lib/libR.so
#26 0x00007fbd0cb6aa88 in Rf_eval () from /usr/lib/R/lib/libR.so
#27 0x00007fbd0cb6ceaf in ?? () from /usr/lib/R/lib/libR.so
#28 0x00007fbd0cb623c0 in ?? () from /usr/lib/R/lib/libR.so
#29 0x00007fbd0cb6aa88 in Rf_eval () from /usr/lib/R/lib/libR.so
#30 0x00007fbd0cb6ceaf in ?? () from /usr/lib/R/lib/libR.so
#31 0x00007fbd0cb623c0 in ?? () from /usr/lib/R/lib/libR.so
#32 0x00007fbd0cb6aa88 in Rf_eval () from /usr/lib/R/lib/libR.so
#33 0x00007fbd0cb6ceaf in ?? () from /usr/lib/R/lib/libR.so
#34 0x00007fbd0cb623c0 in ?? () from /usr/lib/R/lib/libR.so
#35 0x00007fbd0cb6aa88 in Rf_eval () from /usr/lib/R/lib/libR.so
#36 0x00007fbd0cb6ceaf in ?? () from /usr/lib/R/lib/libR.so
#37 0x00007fbd0cb6ac56 in Rf_eval () from /usr/lib/R/lib/libR.so
#38 0x00007fbd0cb1a58e in ?? () from /usr/lib/R/lib/libR.so
---Type <return> to continue, or q <return> to quit---
#39 0x00007fbd0cb1bac1 in R_ToplevelExec () from /usr/lib/R/lib/libR.so
#40 0x00007fbd0cb1bb09 in R_tryEval () from /usr/lib/R/lib/libR.so
#41 0x0000000000de4189 in rstudio::r::exec::(anonymous namespace)::evaluateExpressionsUnsafe(SEXPREC*, SEXPREC*, SEXPREC**, rstudio::r::sexp::Protect*, rstudio::r::exec::(anonymous namespace)::EvalType) [clone .constprop.57] ()
#42 0x0000000000de5d55 in rstudio::r::exec::evaluateString(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, SEXPREC**, rstudio::r::sexp::Protect*) ()
#43 0x000000000070c85f in rstudio::session::modules::rparser::(anonymous namespace)::resolveObjectAssociatedWithCall(rstudio::core::r_util::token_cursor::RTokenCursor, rstudio::r::sexp::Protect*, bool, bool*) [clone .constprop.1377] ()
#44 0x000000000070e3f7 in rstudio::session::modules::rparser::(anonymous namespace)::mightPerformNonstandardEvaluation(rstudio::core::r_util::token_cursor::RTokenCursor const&, rstudio::session::modules::rparser::ParseStatus&) ()
#45 0x0000000000997dd2 in rstudio::session::modules::rparser::doParse(rstudio::core::r_util::token_cursor::RTokenCursor&, rstudio::session::modules::rparser::ParseStatus&) ()
#46 0x000000000099a320 in rstudio::session::modules::rparser::parse(rstudio::core::FilePath const&, std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, rstudio::session::modules::rparser::ParseOptions const&) ()
#47 0x00000000008a9e65 in rstudio::session::modules::diagnostics::parse(std::__cxx11::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> > const&, rstudio::core::FilePath const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool) ()
#48 0x00000000008adf66 in rstudio::session::modules::diagnostics::(anonymous namespace)::lintRSourceDocument(rstudio::core::json::JsonRpcRequest const&, rstudio::core::json::JsonRpcResponse*) ()
#49 0x0000000000783a0f in rstudio_boost::detail::function::function_invoker2<rstudio::core::Error (*)(rstudio::core::json::JsonRpcRequest const&, rstudio::core::json::JsonRpcResponse*), rstudio::core::Error, rstudio::core::json::JsonRpcRequest const&, rstudio::core::json::JsonRpcResponse*>::invoke(rstudio_boost::detail::function::function_buffer&, rstudio::core::json::JsonRpcRequest const&, rstudio::core::json::JsonRpcResponse*) ()
#50 0x0000000000c5f898 in rstudio::core::json::(anonymous namespace)::runSynchronousFunction(rstudio_boost::function<rstudio::core::Error (rstudio::core::json::JsonRpcRequest const&, rstudio::core::json::JsonRpcResponse*)> const&, rstudio::core::json::JsonRpcRequest const&, rstudio_boost::function<void (rstudio::core::Error const&, rstudio::core::json::JsonRpcResponse*)> const&) ()
#51 0x00000000007e46f9 in rstudio::session::rpc::handleRpcRequest(rstudio::core::json::JsonRpcRequest const&, rstudio_boost::shared_ptr<rstudio::session::HttpConnection>, rstudio::session::http_methods::ConnectionType) ()
#52 0x00000000007e99bb in rstudio::session::http_methods::handleConnection(rstudio_boost::shared_ptr<rstudio::session::HttpConnection>, rstudio::session::http_methods::ConnectionType) ()
#53 0x00000000007ebc8b in rstudio::session::http_methods::waitForMethod(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, rstudio_boost::function<void ()> const&, rstudio_boost::function<bool ()> const&, rstudio::core::json::JsonRpcRequest*) ()
#54 0x0000000000754b13 in rstudio::session::console_input::rConsoleRead(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, bool, rstudio::r::session::RConsoleInput*) ()
#55 0x0000000000e22cba in rstudio::r::session::RReadConsole(char const*, unsigned char*, int, int) ()
#56 0x00007fbd0cb9431c in Rf_ReplIteration () from /usr/lib/R/lib/libR.so
---Type <return> to continue, or q <return> to quit---
#57 0x00007fbd0cb94811 in ?? () from /usr/lib/R/lib/libR.so
#58 0x00007fbd0cb948c8 in run_Rmainloop () from /usr/lib/R/lib/libR.so
#59 0x0000000000e4098f in rstudio::r::session::runEmbeddedR(rstudio::core::FilePath const&, rstudio::core::FilePath const&, bool, bool, SA_TYPE, rstudio::r::session::Callbacks const&, rstudio::r::session::InternalCallbacks*) ()
#60 0x0000000000e1ef3f in rstudio::r::session::run(rstudio::r::session::ROptions const&, rstudio::r::session::RCallbacks const&) ()
#61 0x0000000000718a83 in main ()

rstudio诊断:

[1] "1.1.383"

$R
[1] "/usr/bin/R"

$pdflatex
[1] "/usr/bin/pdflatex"

$bibtex
[1] "/usr/bin/bibtex"

$gcc
[1] "/usr/bin/gcc"

$git
[1] "/usr/bin/git"

$svn
[1] ""

R version 3.4.2 (2017-09-28)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 16.04.3 LTS

Matrix products: default
BLAS: /usr/lib/libblas/libblas.so.3.6.0
LAPACK: /usr/lib/lapack/liblapack.so.3.6.0

locale:
[1] LC_CTYPE=en_US.UTF-8 LC_NUMERIC=C LC_TIME=en_US.UTF-8 
[4] LC_COLLATE=en_US.UTF-8 LC_MONETARY=en_US.UTF-8 LC_MESSAGES=en_US.UTF-8 
[7] LC_PAPER=en_US.UTF-8 LC_NAME=C LC_ADDRESS=C 
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached):
[1] compiler_3.4.2 tools_3.4.2 yaml_2.1.14

SysInfo:
sysname release 
"Linux" "4.4.0-97-generic" 
version nodename 
"#120-Ubuntu SMP Tue Sep 19 17:28:18 UTC 2017" "reilly-Precision-7510" 
machine login 
"x86_64" "unknown" 
user effective_user 
"reilly" "reilly"

R Version:
_ 
platform x86_64-pc-linux-gnu 
arch x86_64 
os linux-gnu 
system x86_64, linux-gnu 
status 
major 3 
minor 4.2 
year 2017 
month 09 
day 28 
svn rev 73368 
language R 
version.string R version 3.4.2 (2017-09-28)
nickname Short Summer 
$CLICOLOR_FORCE
[1] "1"

$CLUTTER_IM_MODULE
[1] "xim"

$COMPIZ_BIN_PATH
[1] "/usr/bin/"

$COMPIZ_CONFIG_PROFILE
[1] "ubuntu"

$DBUS_SESSION_BUS_ADDRESS
[1] "unix:abstract=/tmp/dbus-O9bssVywYW"

$DEFAULTS_PATH
[1] "/usr/share/gconf/ubuntu.default.path"

$DERBY_HOME
[1] "/usr/lib/jvm/java-8-oracle/db"

$DESKTOP_SESSION
[1] "ubuntu"

$DISPLAY
[1] ":0"

$EDITOR
[1] "vi"

$GDM_LANG
[1] "en_US"

$GDMSESSION
[1] "ubuntu"

$GIO_LAUNCHED_DESKTOP_FILE
[1] "/usr/share/applications/rstudio.desktop"

$GIO_LAUNCHED_DESKTOP_FILE_PID
[1] "4600"

$GIT_ASKPASS
[1] "rpostback-askpass"

$GNOME_DESKTOP_SESSION_ID
[1] "this-is-deprecated"

$GNOME_KEYRING_CONTROL
[1] ""

$GNOME_KEYRING_PID
[1] ""

$GPG_AGENT_INFO
[1] "/home/reilly/.gnupg/S.gpg-agent:0:1"

$GTK2_MODULES
[1] "overlay-scrollbar"

$GTK_IM_MODULE
[1] "ibus"

$GTK_MODULES
[1] "gail:atk-bridge:unity-gtk-module"

$HOME
[1] "/home/reilly"

$IM_CONFIG_PHASE
[1] "1"

$INSTANCE
[1] ""

$J2REDIR
[1] "/usr/lib/jvm/java-8-oracle/jre"

$J2SDKDIR
[1] "/usr/lib/jvm/java-8-oracle"

$JAVA_HOME
[1] "/usr/lib/jvm/java-8-oracle"

$JOB
[1] "unity-settings-daemon"

$LANG
[1] "en_US.UTF-8"

$LANGUAGE
[1] "en_US"

$LD_LIBRARY_PATH
[1] "/usr/lib/R/lib:/home/bmreilly/software/ncbi/lib64:/home/reilly/software/ncbi/lib64::::/lib:/usr/lib/x86_64-linux-gnu:/usr/lib/jvm/java-8-oracle/jre/lib/amd64/server:/home/bmreilly/software/ncbi/lib64:/home/reilly/software/ncbi/lib64:"

$LN_S
[1] "ln -s"

$LOGNAME
[1] "reilly"

$MAKE
[1] "make"

$MANDATORY_PATH
[1] "/usr/share/gconf/ubuntu.mandatory.path"

$NGS_LIBDIR
[1] "/home/bmreilly/software/ncbi/lib64"

$PAGER
[1] "/usr/bin/pager"

$PATH
[1] "/home/reilly/software/ncbi/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin:/usr/lib/jvm/java-8-oracle/bin:/usr/lib/jvm/java-8-oracle/db/bin:/usr/lib/jvm/java-8-oracle/jre/bin"

$PWD
[1] "/home/reilly"

$QT4_IM_MODULE
[1] "xim"

$QT_ACCESSIBILITY
[1] "1"

$QT_IM_MODULE
[1] "ibus"

$QT_LINUX_ACCESSIBILITY_ALWAYS_ON
[1] "1"

$QT_QPA_PLATFORMTHEME
[1] "appmenu-qt5"

$R_BROWSER
[1] "xdg-open"

$R_BZIPCMD
[1] "/bin/bzip2"

$R_DOC_DIR
[1] "/usr/share/R/doc"

$R_GZIPCMD
[1] "/bin/gzip -n"

$R_HOME
[1] "/usr/lib/R"

$R_INCLUDE_DIR
[1] "/usr/share/R/include"

$R_LIBS_SITE
[1] "/usr/local/lib/R/site-library:/usr/lib/R/site-library:/usr/lib/R/library"

$R_LIBS_USER
[1] "~/R/x86_64-pc-linux-gnu-library/3.4"

$RMARKDOWN_MATHJAX_PATH
[1] "/usr/lib/rstudio/resources/mathjax-26"

$R_PAPERSIZE
[1] "letter"

$R_PAPERSIZE_USER
[1] "letter"

$R_PDFVIEWER
[1] "/usr/bin/xdg-open"

$R_PLATFORM
[1] "x86_64-pc-linux-gnu"

$R_PRINTCMD
[1] "/usr/bin/lpr"

$R_RD4PDF
[1] "times,inconsolata,hyper"

$R_SESSION_TMPDIR
[1] "/tmp/RtmpYB9etw"

$R_SHARE_DIR
[1] "/usr/share/R/share"

$RS_LOCAL_PEER
[1] "/tmp/18469-rsession"

$RS_PPM_FD_READ
[1] "21"

$RS_PPM_FD_WRITE
[1] "22"

$RS_RPOSTBACK_PATH
[1] "/usr/lib/rstudio/bin/rpostback"

$RS_SHARED_SECRET
[1] "16816927778469308861804289383"

$RSTUDIO
[1] "1"

$RSTUDIO_CONSOLE_COLOR
[1] "256"

$RSTUDIO_CONSOLE_WIDTH
[1] "109"

$RSTUDIO_PANDOC
[1] "/usr/lib/rstudio/bin/pandoc"

$RSTUDIO_SESSION_PORT
[1] "18469"

$RSTUDIO_USER_IDENTITY
[1] "reilly"

$RSTUDIO_WINUTILS
[1] "bin/winutils"

$R_SYSTEM_ABI
[1] "linux,gcc,gxx,gfortran,?"

$R_TEXI2DVICMD
[1] "/usr/bin/texi2dvi"

$R_UNZIPCMD
[1] "/usr/bin/unzip"

$R_ZIPCMD
[1] "/usr/bin/zip"

$SED
[1] "/bin/sed"

$SESSION
[1] "ubuntu"

$SESSIONTYPE
[1] "gnome-session"

$SHELL
[1] "/bin/bash"

$SHLVL
[1] "0"

$SSH_AUTH_SOCK
[1] "/run/user/1000/keyring/ssh"

$TAR
[1] "/bin/tar"

$TERM
[1] "xterm-256color"

$UPSTART_EVENTS
[1] "xsession started"

$UPSTART_INSTANCE
[1] ""

$UPSTART_JOB
[1] "unity7"

$UPSTART_SESSION
[1] "unix:abstract=/com/ubuntu/upstart-session/1000/1585"

$USER
[1] "reilly"

$XAUTHORITY
[1] "/home/reilly/.Xauthority"

$XDG_CONFIG_DIRS
[1] "/etc/xdg/xdg-ubuntu:/usr/share/upstart/xdg:/etc/xdg"

$XDG_CURRENT_DESKTOP
[1] "Unity"

$XDG_DATA_DIRS
[1] "/usr/share/ubuntu:/usr/share/gnome:/usr/local/share/:/usr/share/:/var/lib/snapd/desktop"

$XDG_GREETER_DATA_DIR
[1] "/var/lib/lightdm-data/reilly"

$XDG_MENU_PREFIX
[1] "gnome-"

$XDG_RUNTIME_DIR
[1] "/run/user/1000"

$XDG_SEAT
[1] "seat0"

$XDG_SEAT_PATH
[1] "/org/freedesktop/DisplayManager/Seat0"

$XDG_SESSION_DESKTOP
[1] "ubuntu"

$XDG_SESSION_ID
[1] "c2"

$XDG_SESSION_PATH
[1] "/org/freedesktop/DisplayManager/Session0"

$XDG_SESSION_TYPE
[1] "x11"

$XDG_VTNR
[1] "7"

$XMODIFIERS
[1] "@im=ibus"

[1] ".GlobalEnv" "tools:rstudio" "package:stats" "package:graphics" "package:grDevices"
[6] "package:utils" "package:datasets" "package:methods" "Autoloads" "package:base" 
Log file: rdesktop.log
--------------------------------------------------

(Empty)

Log file: rsession-reilly.log
--------------------------------------------------

13 Oct 2017 21:15:06 [rsession-reilly] WARNING Process supervisor did not terminate within 1 second; LOGGED FROM: void {anonymous}::rCleanup(bool) /home/ubuntu/rstudio/src/cpp/session/SessionMain.cpp:1099

以下是导致错误的代码段。

当这段代码保存到文档中时,打开并编辑文件后,rsession会挂起。如果这段代码不存在,文档工作正常。不完全确定发生了什么。这段代码只是我正在处理的一个未完成的功能,但不知何故它正在炸毁Rstudio。

iteratively_impute_pca_zscore_remove_outliers <- function(matrix, ... ) {
  repeat {
    imputed.mat <- impute_less_than_x_NA(matrix)
    pc1_score_
    if (length(SamplesToRemove)==0)
  }
}
repeat {

} (length(samplesToRemove)==0){

}

1 个答案:

答案 0 :(得分:1)

喝!感谢您报告此事并通过评论讨论该问题。这里的问题是这段代码:

repeat {

} (length(samplesToRemove)==0){

}

问题是,对于RStudio的诊断系统,这看起来像一个函数调用(!),其中repeat {}是要调用的函数的左侧。当RStudio尝试评估此函数时,它会卡在repeat {}循环中,永远不会有机会逃脱。

您应该可以通过将此位移到单独的行来解决此问题:

repeat {

}

(length(samplesToRemove)==0){

}

但我会为RStudio人员提交此文件,我们会尝试修复。