2017-10-13 78 views
2

我一直在這個問題上玩了好幾個小時,我想我終於可以重現它了。Rstudio rsession在編輯文件時掛起

當我開始新的Rstudio會話時,一切正常,沒有問題。我甚至可以加載對象並執行代碼。

編輯當前文件時出現問題。只要我編輯文件,我不能再執行命令,當我通過top查看CPU使用情況時,它顯示rsession正在使用100%的CPU,並且它永不停止。在此期間,我可以繼續編輯該文件,並且Rstudio GUI顯示工作正常,但代碼執行已凍結。我也無法保存文件。

編輯:我試圖編輯的文檔類型是.Rmd降價文檔。我只是嘗試在非Markdown R腳本中運行相同的代碼,並且運行良好。這個問題肯定與降價有關。

EDIT2:^^從不知道,即使沒有.Rmd文件,問題依然存在。將該腳本另存爲普通.R腳本後,它將導致rsession再次掛起。編輯3:我忘記提及這是最近發生的事情,可能是由更新的R版本,Rstudio版本或系統庫引起的。昨天我能夠在Rstudio中沒有任何問題的情況下編輯此腳本。本週我更新了Rstudio,但直到幾天後纔看到這個問題。我很快更新了我的系統,之後很可能還更新了R版本。我只是在努力瞭解這是如何導致目前的問題。

編輯4:發現了一段代碼導致錯誤,張貼如下。

rsession的回溯時發生錯誤(編輯後的文件)

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){ 

} 
+0

從回溯中看來,RStudio診斷引擎可能會卡住文件中的某些內容。你有沒有機會分享你正在編輯的文檔並保存?或者它是否會出現在任何類型的R文檔中? –

+0

你是對的!似乎這個問題出現在一些具體的文件中。我認爲這可能是因爲R文件在Rstudio中未打開時打開文件而導致R崩潰或與服務器的連接崩潰。現在每當我嘗試編輯這些文檔時,它都會崩潰。我無法分享文檔,因爲它們是非常大的knitr文檔。你對我如何恢復這些損壞的文件中的信息有什麼想法嗎?即將一個簡單的複製/粘貼到新的文檔工作? – Reilstein

+0

您可以嘗試使用其他編輯器(RStudio以外的其他編輯器)打開它們,然後將內容複製並粘貼到一個[GitHub Gist](https://gist.github.com/),並共享鏈接。也許值得嘗試[重置RStudio的狀態](https://support.rstudio.com/hc/en-us/articles/200534577-Resetting-RStudio-Desktop-s-State)。 –

回答

1

Oof!感謝您報告並通過評論討論此問題。這裏的問題是這段代碼:(!)

repeat { 

} (length(samplesToRemove)==0){ 

} 

的問題是,要RStudio的診斷系統,這看起來像一個函數調用,其中repeat {}是函數的左側被調用。當RStudio嘗試評估此功能時,它會卡在repeat {}循環中,並且永遠不會有機會逃脫。

您應該能夠通過移動該位爲一個獨立的行來解決此問題:

repeat { 

} 

(length(samplesToRemove)==0){ 

} 

但我會提交本作的RStudio人,我們會盡力得到修復。

+0

感謝您對診斷問題的幫助,並提出問題!這是一個令人頭痛的問題,我只是在我的繩索末端。我真的不認爲這是打破Rstudio的代碼本身。現在我更瞭解了Rstudio在幕後做了些什麼,我將來會注意到這一點! – Reilstein

+0

我很高興我能夠幫助!感謝您堅持不懈地解決這個問題;我相信遇到並處理這件事令人沮喪。 –