R 包调用的 Fortran 代码仅在 Linux 上导致段错误崩溃
Fortran code called by R package causes segfault crash on Linux only
我正在尝试使用 smwrQW R package. I can get it to work on Windows machines (example("censReg", "smwrQW")
). However, running the same code on a Linux machine causes me an instant segfault. I believe I have tracked the error to the following line。
您应该能够使用 Docker 和以下命令集重现此行为:
docker pull rocker/tidyverse
docker run -it rocker/tidyverse /bin/bash
sudo apt-get install ed
Rscript -e "devtools::install_github('USGS-R/smwrBase')"
Rscript -e "devtools::install_github('USGS-R/smwrGraphs')"
Rscript -e "devtools::install_github('USGS-R/smwrStats')"
Rscript -e "devtools::install_github('USGS-R/smwrQW')"
Rscript -e "example('censReg', package = 'smwrQW')"
是否是gfortran(6.3.0)的Docker版本与RTools中的版本不匹配导致的问题?参见 http://www.thecoatlessprofessor.com/programming/rcpp-rcpparmadillo-and-os-x-mavericks-lgfortran-and-lquadmath-error/#the-solution
我遇到了两个令人费解的怪癖。首先,如果我在上面链接的行之前设置一个断点 (browser()
)(并手动单步执行),则没有错误。其次,travis 构建似乎通过了。
我 运行 gdb 按照 http://r-pkgs.had.co.nz/src.html#src-debugging:
的说明进行操作
Program received signal SIGSEGV, Segmentation fault.
nortest (censflag=..., df=0, llr=0, nobsc=24, sresid=..., plev=0,
ierr=<error reading variable: Cannot access memory at address 0x0>)
at NORTEST.f:75
75 IERR = 0
原来 NORTEST
子例程期望的变量之一 (IERR
) 没有被传递。修正了分配,没有更多的错误!谢谢德克!
更新
我不知道为什么旧代码在 Windows:
上运行
CALL NORTEST(CENSFLAG,DF,LLRAML,NOBSC,SRESID,PLEVAML)
当 NORTEST
需要一个额外的参数时:
SUBROUTINE NORTEST(CENSFLAG,DF,LLR,NOBSC,SRESID,PLEV,IERR)
我正在尝试使用 smwrQW R package. I can get it to work on Windows machines (example("censReg", "smwrQW")
). However, running the same code on a Linux machine causes me an instant segfault. I believe I have tracked the error to the following line。
您应该能够使用 Docker 和以下命令集重现此行为:
docker pull rocker/tidyverse
docker run -it rocker/tidyverse /bin/bash
sudo apt-get install ed
Rscript -e "devtools::install_github('USGS-R/smwrBase')"
Rscript -e "devtools::install_github('USGS-R/smwrGraphs')"
Rscript -e "devtools::install_github('USGS-R/smwrStats')"
Rscript -e "devtools::install_github('USGS-R/smwrQW')"
Rscript -e "example('censReg', package = 'smwrQW')"
是否是gfortran(6.3.0)的Docker版本与RTools中的版本不匹配导致的问题?参见 http://www.thecoatlessprofessor.com/programming/rcpp-rcpparmadillo-and-os-x-mavericks-lgfortran-and-lquadmath-error/#the-solution
我遇到了两个令人费解的怪癖。首先,如果我在上面链接的行之前设置一个断点 (browser()
)(并手动单步执行),则没有错误。其次,travis 构建似乎通过了。
我 运行 gdb 按照 http://r-pkgs.had.co.nz/src.html#src-debugging:
的说明进行操作Program received signal SIGSEGV, Segmentation fault.
nortest (censflag=..., df=0, llr=0, nobsc=24, sresid=..., plev=0,
ierr=<error reading variable: Cannot access memory at address 0x0>)
at NORTEST.f:75
75 IERR = 0
原来 NORTEST
子例程期望的变量之一 (IERR
) 没有被传递。修正了分配,没有更多的错误!谢谢德克!
更新
我不知道为什么旧代码在 Windows:
上运行CALL NORTEST(CENSFLAG,DF,LLRAML,NOBSC,SRESID,PLEVAML)
当 NORTEST
需要一个额外的参数时:
SUBROUTINE NORTEST(CENSFLAG,DF,LLR,NOBSC,SRESID,PLEV,IERR)