Ubuntu 16.04 上的 R DotNet 分段错误

问题描述

我无法弄清楚为什么我的 R 调用突然失败并出现分段错误(核心转储)错误。我已经将其追溯到 R.DotNet 中的 TryEvaluate 调用: IntPtr 指针 = this.GetFunction()(handle,environment.DangerousGetHandle(),out errorOccurred);

不幸的是,这不是我创建的代码,我对 R 的工作原理知之甚少,我只是一直在维护它。

我使用的是 Ubuntu 16.04,我尝试安装几个不同版本的 R 来查看 R(4.0、3.6、3.4)是否有问题 可能不是很有帮助,但是失败时正在执行的语句是: post(Tree,file="output/Error2withQChanges_noprune.ps"

任何想法如何找出导致分段错误的原因?我不是每次都收到错误,但似乎某些数据集导致它发生。

这是我用于 Ubuntu 容器的 dockerfile:

FROM ubuntu:16.04

#install R
#I took the same steps as installing R on ubuntu from here: https://www.digitalocean.com/community/tutorials/how-to-install-r-on-ubuntu-16-04-2
# We apparently have to install the libgdiplus library. Without it I was getting an error in R where it said it Couldn't find the shared library libdl
# The closest I Could find was: https://github.com/VahidN/EPPlus.Core/issues/40#issuecomment-370366985 
# installing that fixed the library not found issues

RUN apt-get update \
    && apt-get install -y software-properties-common \
    && apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9 \
    && add-apt-repository 'deb http://cloud.r-project.org/bin/linux/ubuntu xenial-cran35/' \
    && apt-get update \
    && apt-get install -y r-base --no-install-recommends \
    && apt-get install -y --no-install-recommends libgdiplus libc6-dev \
    && rm -rf /var/lib/apt/lists/*

#copy in client folder
copY clientfolder /clientfolder

#explicitly set R_Home variable
ENV R_HOME /usr/lib/R

以下是在失败之前运行的 R 命令:

library(rpart)
Tree <- rpart(Pass ~ <a bunch of columns in my dataset separated by +>,data=ErrorData,minsplit=1,minbucket=1,method='class')
gc()
PrunedTree <- prune(Tree,cp=Tree$cptable[which.min(Tree$cptable[,"xerror"]),"CP"])
ErrorData["leafid"] <- PrunedTree$where
post(Tree,file="/output/Error2withQChanges_noprune.ps")
post(PrunedTree,file="/output/Error2withQChanges.ps")
gc()

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)