jwood000 / RcppAlgos

Tool for Solving Problems in Combinatorics and Computational Mathematics
GNU General Public License v2.0
45 stars 5 forks source link

R Session Aborted by call to `partitionsGeneral` #39

Closed PuzzledFace closed 1 year ago

PuzzledFace commented 1 year ago
library(RcppAlgos)

valuesSet <- c(10, 5, 2, 1, -1, -2, -5, -10)
partitionsGeneral(valueSet, m=2, target=3)

produces

image

As a first time user of RcppAlgos, I may be misusing the function, but even if so, I feel any error on my part could be more elegantly handled.

I am attempting to find combinations of pairs of values in valueSet that sum to 3. The solution should be c(5, -2).

Environment details:

OS: MacOS Mojave 10.14.6 IDE: RStudio 2021.09.2 Build 382 R version 4.2.1 (2022-06-23) -- "Funny-Looking Kid" RcppAlgos version: 2.6.0

jwood000 commented 1 year ago

@PuzzledFace,

I am not able to replicate the error. Here is what I get:

library(RcppAlgos)

valuesSet <- c(10, 5, 2, 1, -1, -2, -5, -10)
partitionsGeneral(valuesSet, m=2, target=3)
     [,1] [,2]
[1,]   -2    5
[2,]    1    2

Also, I have several unit tests that cover these mixed cases and they pass on multiple platforms.

Could you give us your sessionInfo()? E.g. here is mine:

sessionInfo()
R version 4.2.1 (2022-06-23)
Platform: aarch64-apple-darwin20 (64-bit)
Running under: macOS Monterey 12.6

Matrix products: default
LAPACK: /Library/Frameworks/R.framework/Versions/4.2-arm64/Resources/lib/libRlapack.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] RcppAlgos_2.6.0

loaded via a namespace (and not attached):
[1] compiler_4.2.1 parallel_4.2.1 tools_4.2.1    gmp_0.6-6 

Just curious, do you have a Mac with one of the newer M chips?

PuzzledFace commented 1 year ago

Thank you for the almost instantaneous response.

I did suspect it was an operating system issue and I am not surprised that you have unit tests that cover this sort of example.

No, I do not have a Mac with an M-series chip (yet). I'm using a mid-2010 MacPro: image

I can test on a MacBook as well. And on Windows and Linux machines when I return to work in the New Year. I will update then.

sessionInfo() below.

R version 4.2.1 (2022-06-23)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Mojave 10.14.6

Matrix products: default
BLAS:   /System/Library/Frameworks/Accelerate.framework/Versions/A/Frameworks/vecLib.framework/Versions/A/libBLAS.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.2/Resources/lib/libRlapack.dylib

locale:
[1] en_GB.UTF-8/en_GB.UTF-8/en_GB.UTF-8/C/en_GB.UTF-8/en_GB.UTF-8

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] magrittr_2.0.3  stringr_1.4.1   RcppAlgos_2.6.0

loaded via a namespace (and not attached):
[1] compiler_4.2.1 parallel_4.2.1 tools_4.2.1    gmp_0.6-9      stringi_1.7.8 

Happy New Year.

jwood000 commented 1 year ago

@PuzzledFace,

Thanks for that.

I asked because I recently ran into a similar issue with the R version that I downloaded not matching the OS. It behaved very strangely even with other packages. I remember being able to initiate an R session abort by using only functions from other packages that needed compilation such as the gmp package.

In the meantime, I will try to replicate your build with docker to see if I can make some headway.

I really appreciate the report and Happy New Year to you as well!

jwood000 commented 1 year ago

As a last check, I noticed your RStudio version is quite old. There are two thing you could try:

  1. Run your code in the vanilla R IDE. I think for your build, you should have R GUI 1.79. If it doesn't crash, try:
  2. Updating RStudio and see if the problem persists.

Hope this helps

PuzzledFace commented 1 year ago

OK. So running

library(RcppAlgos)

R.Version()$version.string
Sys.info()["sysname"]
Sys.info()["version"]
valueSet <- c(10, 5, 2, 1, -1, -2, -5, -10)
partitionsGeneral(valueSet, m=2, target=3)

on my two work machines produces

> R.Version()$version.string 
[1] "R version 4.1.3 (2022-03-10)" 
> Sys.info()["sysname"] 
sysname  
"Linux"  
> Sys.info()["version"]
                              version  
"#1 SMP Fri Dec 9 12:54:21 UTC 2022"  
> valueSet <- c(10, 5, 2, 1, -1, -2, -5, -10) 
> partitionsGeneral(valueSet, m=2, target=3)      
       [,1] [,2] 
[1,]   -2    5
[2,]    1    2

and

> R.Version()$version.string
[1] "R version 4.2.1 (2022-06-23 ucrt)"
> Sys.info()["sysname"]
  sysname 
"Windows" 
> Sys.info()["version"]
      version 
"build 19044" 
> valueSet <- c(10, 5, 2, 1, -1, -2, -5, -10)
> partitionsGeneral(valueSet, m=2, target=3)
     [,1] [,2]
[1,]   -2    5
[2,]    1    2

So it seems clear that the problem is due to a problem on my local OS X box rather than anything under your control. Unfortunately the OS X box is so old I can't upgrade the OS sufficiently to install the latest versions of R and RStudio.

Thanks for your input and speedy responses.

jwood000 commented 1 year ago

@PuzzledFace,

I'm closing this issue for now. If you obtain in new findings, please feel free to open back up.

Thanks, Joseph