在带有Rcpp的Ubuntu Xenial上抛出std :: runtime_error时出现段错误

丹尼尔·法贝尔

我和libctor一起在Rcpp上有一个非常奇怪的行为。

我有一个具有2个功能的文件:

#include <torch/torch.h>
#include <Rcpp.h> 

// [[Rcpp::export]]
void test_error () {  
  throw std::runtime_error("hi this is my error");
}

// [[Rcpp::export]]
void test_error2 () {  
  Rcpp::Rcout << torch::arange(1) << std::endl;
}

当我打电话时test_error()出现段错误(g ++):

terminate called after throwing an instance of 'std::bad_alloc'
  what():  std::bad_alloc
Aborted (core dumped)

clang ++错误是:

terminate called after throwing an instance of 'std::length_error'
  what():  basic_string::_M_create
Aborted (core dumped)

test_error2 可以正常工作。

此错误仅在Ubuntu Xenial上发生。我使用Ubuntu Trusty和MacOS进行了测试,没有出现段错误。

如果我test_error2从文件中删除的代码,即使没有删除该#include <torch/torch.h>也没有任何错误

还测试了使用clang ++和g ++进行编译。同样的错误。

我在这里创建了一个小型仓库并提供了我可以做的最少示例。

有谁知道这可能是什么?

注意configure文件将从pytorch的网站上自动下载并安装libtorch。因此,如果您不想这样做,请不要安装软件包。

丹尼尔·法贝尔

事实证明,使用较旧版本编译程序包g++效果很好。

我安装了g++-4.9

sudo apt-get install g++-4.9

编辑.R/Makevars使用g++-4.9

CXX=g++-4.9
CXX11=g++-4.9

然后重新编译Rcpp和程序包。

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章

在抛出'std::runtime_error' what() 实例后调用终止:filebuf 和 ostream 的 I/O 错误

使用带有用户定义函数的 Rcpp/Armadillo 和 openMP 并行时出现段错误

移动std :: runtime_error的构造函数

继承自std :: runtime_error

带有 GCC 7.2.0 的 Ubuntu 17.10 上的 strptime 错误

使用带有 typedef 的 Rcpp 编译错误

如何dllexport从std :: runtime_error派生的类?

TensorFlow for Python 3在Ubuntu上安装时抛出错误

在 Ubuntu 上安装 Artery 时,构建 INET 抛出异常错误

擦除带有不可打印字符的 std::string 上的删除成语抛出异常

带有std :: promise的C ++ 11分段错误

结合OpenGl和QML时在glDrawArrays上出现段错误

使用带有AVR-GCC的Atmel Studio进行编译时出现随机段错误

在带有Nvidia gpu的ubuntu 16.04上使用VLC播放.mkv vidoe时出现断断续续的图形

在带有RVM的Linux Mint上运行“捆绑安装”时,出现许多临时的UnknownHost错误

在带有数组的对象上使用它时,为什么会出现$ parse错误?

启动错误:无法检测图形环境;带有Ubuntu16.04的VM上的pycharm-community

umake 无法在 Ubuntu 20.10 上安装带有 python 相关错误的idea-ultimate

在带有GTK + 3的Ubuntu 14.04上构建wxWidgets时出错

在 Google Cloud Shell 上抛出错误,但在 Studio Code 上没有抛出错误

ubuntu 16.04 Xenial Xerus上的Wi-Fi经常断开连接且DNS错误

如何在Ubuntu 16.04 xenial上安装Unison 2.40(解决“致命错误:收到意外的标头”)

如何在Ubuntu 16.04 xenial上安装Unison 2.40(解决“致命错误:收到意外的标头”)

运行Apache和Passenger的Ubuntu上的Rails App抛出带有参数的404

段 在std :: vector上推指针时出现故障

带有Rcpp代码的软件包无法在Windows上构建

带有 Rcpp 的 R Cran 包构建在除 Solaris 之外的每个系统上

TP-Link AC1750在Ubuntu上安装时带有安装CD,没有以太网

带有ASM的ActiveRecord模型上的delay_job-吞噬失败的方法错误,而是抛出“错误数量的参数”