symengine.R icon indicating copy to clipboard operation
symengine.R copied to clipboard

illegal opcode on mac

Open mattfidler opened this issue 4 years ago • 12 comments

I tried out the new github runner and have the following when loading symengine on mac:

 *** caught illegal operation ***
address 0x106a04ed5, cause 'illegal opcode'

Traceback:
 1: dyn.load(file, DLLpath = DLLpath, ...)
 2: library.dynam(chname, package, lib.loc, ...)
 3: library.dynam_2("symengine", pkgname, libname)
 4: fun(libname, pkgname)
 5: doTryCatch(return(expr), name, parentenv, handler)
 6: tryCatchOne(expr, names, parentenv, handlers[[1L]])
 7: tryCatchList(expr, classes, parentenv, handlers)
 8: tryCatch(fun(libname, pkgname), error = identity)
 9: runHook(".onLoad", env, package.lib, package)
10: loadNamespace("symengine")
11: new.env(parent = loadNamespace("symengine"))

https://github.com/nlmixrdevelopment/RxODE/runs/1521723803?check_suite_focus=true

mattfidler avatar Dec 09 '20 04:12 mattfidler

This uses the prebuilt mac binaries on CRAN which means they may not work correctly.

mattfidler avatar Dec 09 '20 12:12 mattfidler

Thanks for the report. I will look into this.

Marlin-Na avatar Dec 09 '20 16:12 Marlin-Na

Note that it works if I use devtools::install_github("symengine/symengine.R")

mattfidler avatar Dec 09 '20 17:12 mattfidler

@mattfidler, what's the cpu model of the macos runner?

isuruf avatar Dec 11 '20 00:12 isuruf

Not sure; This is the output at the top:

Current runner version: '2.274.2'
Operating System
  Mac OS X
  10.15.7
  19H15
Virtual Environment
  Environment: macos-10.15
  Version: 20201130.3
  Included Software: https://github.com/actions/virtual-environments/blob/macOS-10.15/20201130.3/images/macos/macos-10.15-Readme.md
Prepare workflow directory
Prepare all required actions
Getting action download info
Download action repository 'actions/checkout@v2'
Download action repository 'r-lib/actions@v1'
Download action repository 'actions/cache@v2'
Download action repository 'actions/upload-artifact@main'

mattfidler avatar Dec 11 '20 01:12 mattfidler

More information about the virtual machine is here:

https://github.com/actions/virtual-environments/blob/main/images/macos/macos-10.15-Readme.md

I believe it uses the Microsoft Azure framework if that helps.

mattfidler avatar Dec 11 '20 01:12 mattfidler

@mattfidler Thanks for the information. FYI, I can't reproduce the error on my computer (macOS 10.15.4), by R CMD checking RxODE with CRAN version of symengine.

I don't know the precise reason of the crash, but I guess we can try adding -mmacosx-version-min=10.13 to cmake flags. R uses it by default when compiling the package's source code, but I think we didn't pass it down when compiling the symengine C++ source bundled in the R package. (Though that would be confusing as well, since I think CRAN is actually building binaries on macOS 10.13).

Meanwhile, I wonder if it is possible to configure github runner to use install.packages("symengine", type="source")?

Marlin-Na avatar Dec 11 '20 05:12 Marlin-Na

@isuruf sysctl -n machdep.cpu.brand_string gives Intel(R) Xeon(R) CPU E5-1650 v2

these are quite old cpus that don't have support for instruction sets such as avx2, maybe the CRAN version of symengine was compiled with -march=native or a similar flag to enable such instructions?

@Marlin-Na this would also be consistent with it working for you, since this issue would only appear on older cpus.

lkeegan avatar Dec 11 '20 10:12 lkeegan

There flags are here:

CC="clang -mmacosx-version-min=10.13" CXX="clang++ -mmacosx-version-min=10.13" OBJC="clang -mmacosx-version-min=10.13" FC="gfortran -mmacosx-version-min=10.13" F77="gfortran -mmacosx-version-min=10.13" CFLAGS='-Wall -g -O2' CXXFLAGS='-Wall -g -O2' OBJCFLAGS='-Wall -g -O2' FCFLAGS='-Wall -g -O2' F77FLAGS='-Wall -g -O2' --enable-memory-profiling --x-libraries=/opt/X11/lib --x-includes=/opt/X11/include --enable-R-framework --build=x86_64-apple-darwin17.0

Thank from the R source project: https://svn.r-project.org/R-dev-web/trunk/QA/Simon/R4/conf.high-sierra-x86_64

mattfidler avatar Dec 11 '20 12:12 mattfidler

I'm unsure since the build hasn't completed, but install.packages("symengine", type="source") seems to work

https://github.com/nlmixrdevelopment/RxODE/runs/1538236241?check_suite_focus=true

mattfidler avatar Dec 11 '20 16:12 mattfidler

The build does work. My guess is that it has to do with the -mmacosx-version-min=10.13 flag.

mattfidler avatar Dec 11 '20 16:12 mattfidler

Note that travis is going away at the end of this year, others will probably use github actions as a replacement.

mattfidler avatar Dec 11 '20 17:12 mattfidler