Function power() causing R session to crash
eduardohorta opened this issue · comments
Entering, e.g., power(2,3) will deliver the following error message:
*** caught illegal operation ***
address 0x110f29f80, cause 'illegal opcode'
A minimal code example that reproduces the bug:
library(CVXR)
power(2,3)
Output
> library(CVXR)
Attaching package: ‘CVXR’
The following object is masked from ‘package:stats’:
power
> power(2,3)
*** caught illegal operation ***
address 0x104d6bf80, cause 'illegal opcode'
Traceback:
1: gmp::as.bigq(p)
2: pow_high(p)
3: .local(.Object, ...)
4: initialize(value, ...)
5: initialize(value, ...)
6: new("Power", ...)
7: .Power(x = x, p = p, max_denom = max_denom)
8: power(2, 3)
Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection:
Version
> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Catalina 10.15.6
Matrix products: default
BLAS: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRblas.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libRlapack.dylib
locale:
[1] C/UTF-8/C/C/C/C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] CVXR_1.0-8
loaded via a namespace (and not attached):
[1] bit_4.0.4 compiler_4.0.2 R6_2.4.1 Matrix_1.2-18
[5] gmp_0.6-0 Rcpp_1.0.5 bit64_4.0.5 grid_4.0.2
[9] Rmpfr_0.8-1 lattice_0.20-41
This is not a reproducible bug and your session info shows that CVXR
is not attached.
> library(CVXR)
Attaching package: ‘CVXR’
The following object is masked from ‘package:stats’:
power
> power(2,3)
Power(2, 3, c("1/3", "2/3"))>
> sessionInfo()
R version 4.0.2 (2020-06-22)
Platform: x86_64-apple-darwin19.5.0 (64-bit)
Running under: macOS Catalina 10.15.6
Matrix products: default
BLAS/LAPACK: /usr/local/Cellar/openblas/0.3.10_1/lib/libopenblasp-r0.3.10.dylib
locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] CVXR_1.0-8
loaded via a namespace (and not attached):
[1] bit_1.1-15.2 compiler_4.0.2 R6_2.4.1 Matrix_1.2-18
[5] gmp_0.6-0 Rcpp_1.0.5 bit64_0.9-7 grid_4.0.2
[9] Rmpfr_0.8-1 lattice_0.20-41
This is not a reproducible bug and your session info shows that
CVXR
is not attached.
Sorry @bnaras, I forgot to copy the full output. The output is
> library(CVXR)
Attaching package: ‘CVXR’
The following object is masked from ‘package:stats’:
power
> power(2,3)
*** caught illegal operation ***
address 0x104d6bf80, cause 'illegal opcode'
Traceback:
1: gmp::as.bigq(p)
2: pow_high(p)
3: .local(.Object, ...)
4: initialize(value, ...)
5: initialize(value, ...)
6: new("Power", ...)
7: .Power(x = x, p = p, max_denom = max_denom)
8: power(2, 3)
Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
Selection:
Notice that CVXR
appears under other attached packages
in the session info.
Curiously, this same example does work in a rstudio.cloud session.
So this indicates there is something peculiar to your R installation since it works for my R session too. I suspect it is your gmp
R library or the libgmp
that it is linking to. It is easiest to uninstall gmp
(both R and the library) and reinstall.
@bnaras Thank you for the feedback. Unfortunately, uninstalling and reinstalling R and gmp
didn't work.
I have exactly the same issue. My R version is 4.0.2, mac Catalina 10.15.6 and CVXR 1.0-8. I have tried on Rstudio and from the terminal. The issue appears when i run either power(2,3)
or when i was trying with the vignette line: objective <- Minimize(sum((Y - X %*% betaHat)^2))
I am new with this package, any help will be great.
This could be a problem with your settings on Catalina which is far more picky about libraries. You may have to allow full disk access to /usr/bin/ruby
.
@bnaras Unfortunately providing full disk access to /usr/bin/ruby
(and also /usr/bin/local/R
) did not solve the issue.
@p-palacios Indeed, I first bumped into this error when trying to optimize a quadratic loss as you did. From rStudio there was no error message: the session simply crashed. After investigating a little bit (starting R through the Terminal) I came up with this minimal (non-)working example. If you have urgency in using the CVXR
package:
Curiously, this same example does work in a rstudio.cloud session.
So far we don't have a reproducible example. In a brand new R session, can you run the statement
gmp::as.bigq(3)
Can you do the same in a new Rstudio session?
Dear @bnaras gmp::as.bigq(3) does not work with RStudio, last version, or in the terminal, unfortunately. I have already tried the access to /usr/bin/ruby. It didn't work.
@eduardohorta thanks for the suggestion of using RStudio cloud.
That suggests that this has nothing to with CVXR
directly. Your installation does not run a function from the gmp
package which CVXR
uses. So there is something wrong with your R installation or the packages you have installed.
I'm closing this issue since the problem seems to be stemming from the gmp
package: indeed, writing
library(gmp)
gmp::as.bigq(3)
yields the output
*** caught illegal operation ***
address 0x10d320f80, cause 'illegal opcode'
Traceback:
1: gmp::as.bigq(3)
Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
I reported the gmp
bug on https://forgemia.inra.fr/sylvain.jasson/gmp/-/issues/1
I had the same problems and the solution was to clone the repository from the R-package gmp
here:
https://forgemia.inra.fr/sylvain.jasson/gmp.git
and then I built the package by myself and all problems with macOS and the gmp
package were gone.
@JohannesFriedrich Could you please detail how you proceeded?
I think you have git
, a c compiler and gmp
(eg. via brew) installed on your mac.
- Remove your current R-package
gmp
viaremove.packages("gmp")
- Go to the command line
- write
git clone https://forgemia.inra.fr/sylvain.jasson/gmp.git
and clone the repository - write
R CMD build gmp
to build the package - write
R CMD install gmp
to install the package
See the command line if any error occurs. If not, go to R and test, e.g. gmp::factorize(12)
@JohannesFriedrich I was able to build but not install:
$ R CMD build gmp
* checking for file ‘gmp/DESCRIPTION’ ... OK
* preparing ‘gmp’:
* checking DESCRIPTION meta-information ... OK
* cleaning src
* running ‘cleanup’
* checking for LF line-endings in source and make files and shell scripts
* checking for empty or unneeded directories
* looking to see if a ‘data/datalist’ file should be added
* building ‘gmp_0.6-1.tar.gz’
$ R CMD install gmp
* installing to library ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library’
* installing *source* package ‘gmp’ ...
** using staged installation
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking for __gmpz_ui_sub in -lgmp... no
configure: error: GNU MP not found, or not 4.1.4 or up, see http://gmplib.org
ERROR: configuration failed for package ‘gmp’
* removing ‘/Library/Frameworks/R.framework/Versions/4.0/Resources/library/gmp’
Any insights?
The easiest way: use brew install gmp
from your command line (if you have brew
installed!).