Skip to content

Stack trace for a miraiError affected by BLAS/LAPACK #216

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
shikokuchuo opened this issue Feb 24, 2025 · 7 comments · Fixed by #217
Closed

Stack trace for a miraiError affected by BLAS/LAPACK #216

shikokuchuo opened this issue Feb 24, 2025 · 7 comments · Fixed by #217

Comments

@shikokuchuo
Copy link
Member

library(mirai)
f <- function(x) if (x > 0) stop("positive")
m <- mirai({f(-1); f(1)}, f = f)
m[]$stack.trace
#> [[1]]
#> stop("positive")
#> 
#> [[2]]
#> f(1)

sessionInfo()
#> R version 4.4.2 (2024-10-31)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 24.04.2 LTS
#> 
#> Matrix products: default
#> BLAS:   /usr/lib/x86_64-linux-gnu/openblas-pthread/libblas.so.3 
#> LAPACK: /usr/lib/x86_64-linux-gnu/openblas-pthread/libopenblasp-r0.3.26.so;  LAPACK version 3.12.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
#>  [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
#>  [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       
#> 
#> time zone: Europe/London
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] mirai_2.1.0.9000
#> 
#> loaded via a namespace (and not attached):
#>  [1] digest_0.6.37     fastmap_1.2.0     xfun_0.51         nanonext_1.5.1   
#>  [5] glue_1.8.0        knitr_1.49        htmltools_0.5.8.1 rmarkdown_2.29   
#>  [9] lifecycle_1.0.4   cli_3.6.4         reprex_2.1.1      withr_3.0.2      
#> [13] compiler_4.4.2    rstudioapi_0.17.1 tools_4.4.2       evaluate_1.0.3   
#> [17] yaml_2.3.10       rlang_1.1.5       fs_1.6.5

Created on 2025-02-24 with reprex v2.1.1

@shikokuchuo
Copy link
Member Author

shikokuchuo commented Feb 24, 2025

@wlandau can you help me by running the above reprex on your macbook / on another machine? I've come across a weird bug (likely in base R or else my R configuration) where using Intel MKL BLAS/LAPACK adds an additional line to the stack trace.

This ultimately boils down to what which() returns on a list with 2 identical values.

Not a critical bug by any means (more cosmetic in nature), but perhaps something mirai can handle if reproducible.

@wlandau
Copy link

wlandau commented Feb 24, 2025

On Mac OS, I do get an extra line:

library(mirai)
f <- function(x) if (x > 0) stop("positive")
m <- mirai({f(-1); f(1)}, f = f)
m[]$stack.trace
#> [[1]]
#> stop("positive")
#> 
#> [[2]]
#> f(1)
#> 
#> [[3]]
#> eval(._mirai_.[[".expr"]], envir = ._mirai_., enclos = .GlobalEnv)

sessionInfo()
#> R version 4.4.0 (2024-04-24)
#> Platform: aarch64-apple-darwin20
#> Running under: macOS 15.3.1
#> 
#> 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.4-arm64/Resources/lib/libRlapack.dylib;  LAPACK version 3.12.0
#> 
#> locale:
#> [1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8
#> 
#> time zone: America/Indiana/Indianapolis
#> tzcode source: internal
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] mirai_2.1.0.9000
#> 
#> loaded via a namespace (and not attached):
#> [1] compiler_4.4.0      tools_4.4.0         rstudioapi_0.16.0   nanonext_1.5.1.9000

@wlandau
Copy link

wlandau commented Feb 24, 2025

Same on RHEL 9:

library(mirai)
f <- function(x) if (x > 0) stop("positive")
m <- mirai({f(-1); f(1)}, f = f)
m[]$stack.trace
#> [[1]]
#> stop("positive")
#> 
#> [[2]]
#> f(1)
#> 
#> [[3]]
#> eval(._mirai_.[[".expr"]], envir = ._mirai_., enclos = .GlobalEnv)
sessionInfo()
#> R version 4.3.2 (2023-10-31)
#> Platform: x86_64-pc-linux-gnu (64-bit)
#> Running under: Red Hat Enterprise Linux 9.4 (Plow)
#> 
#> Matrix products: default
#> BLAS/LAPACK: FlexiBLAS OPENBLAS-OPENMP;  LAPACK version 3.9.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_US.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_US.UTF-8        LC_COLLATE=en_US.UTF-8    
#>  [5] LC_MONETARY=en_US.UTF-8    LC_MESSAGES=en_US.UTF-8   
#>  [7] LC_PAPER=en_US.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_US.UTF-8 LC_IDENTIFICATION=C       
#> 
#> time zone: America/Indiana/Indianapolis
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] mirai_2.1.0.9000
#> 
#> loaded via a namespace (and not attached):
#> [1] compiler_4.3.2      nanonext_1.5.1.9000

@shikokuchuo
Copy link
Member Author

shikokuchuo commented Feb 24, 2025

Now I can't even reproduce it with MKL BLAS 😞 :

library(mirai)
f <- function(x) if (x > 0) stop("positive")
m <- mirai({f(-1); f(1)}, f = f)
m[]$stack.trace
#> [[1]]
#> stop("positive")
#> 
#> [[2]]
#> f(1)
sessionInfo()
#> R version 4.4.2 (2024-10-31)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 24.04.2 LTS
#> 
#> Matrix products: default
#> BLAS/LAPACK: /opt/intel/oneapi/mkl/2025.0/lib/libmkl_rt.so.2;  LAPACK version 3.11.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
#>  [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
#>  [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       
#> 
#> time zone: Europe/London
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> other attached packages:
#> [1] mirai_2.1.0.9000
#> 
#> loaded via a namespace (and not attached):
#>  [1] digest_0.6.37     fastmap_1.2.0     xfun_0.51         nanonext_1.5.1   
#>  [5] glue_1.8.0        knitr_1.49        htmltools_0.5.8.1 rmarkdown_2.29   
#>  [9] lifecycle_1.0.4   cli_3.6.4         reprex_2.1.1      withr_3.0.2      
#> [13] compiler_4.4.2    rstudioapi_0.17.1 tools_4.4.2       evaluate_1.0.3   
#> [17] yaml_2.3.10       rlang_1.1.5       fs_1.6.5

Created on 2025-02-24 with reprex v2.1.1

@shikokuchuo
Copy link
Member Author

It's non-deterministic?? 😕

library(mirai)
f <- function(x) if (x > 0) stop("positive")
m <- mirai({f(-1); f(1)}, f = f)
m[]$stack.trace
#> [[1]]
#> stop("positive")
#> 
#> [[2]]
#> f(1)
#> 
#> [[3]]
#> eval(._mirai_.[[".expr"]], envir = ._mirai_., enclos = .GlobalEnv)
sessionInfo()
#> R version 4.4.2 (2024-10-31)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 24.04.2 LTS
#> 
#> Matrix products: default
#> BLAS/LAPACK: /opt/intel/oneapi/mkl/2025.0/lib/libmkl_rt.so.2;  LAPACK version 3.11.0
#> 
#> locale:
#>  [1] LC_CTYPE=en_GB.UTF-8       LC_NUMERIC=C              
#>  [3] LC_TIME=en_GB.UTF-8        LC_COLLATE=en_GB.UTF-8    
#>  [5] LC_MONETARY=en_GB.UTF-8    LC_MESSAGES=en_GB.UTF-8   
#>  [7] LC_PAPER=en_GB.UTF-8       LC_NAME=C                 
#>  [9] LC_ADDRESS=C               LC_TELEPHONE=C            
#> [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C       
#> 
#> time zone: Europe/London
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> loaded via a namespace (and not attached):
#>  [1] digest_0.6.37     fastmap_1.2.0     xfun_0.51         glue_1.8.0       
#>  [5] knitr_1.49        htmltools_0.5.8.1 rmarkdown_2.29    lifecycle_1.0.4  
#>  [9] cli_3.6.4         reprex_2.1.1      withr_3.0.2       compiler_4.4.2   
#> [13] rstudioapi_0.17.1 tools_4.4.2       evaluate_1.0.3    yaml_2.3.10      
#> [17] rlang_1.1.5       fs_1.6.5

Created on 2025-02-24 with reprex v2.1.1

@shikokuchuo
Copy link
Member Author

This was caused by a which() in the source code returning possibly 2 values, eliminated simply by taking the max().

@shikokuchuo
Copy link
Member Author

Will be fixed by #217. @wlandau thanks for testing. In case you still see this after that's merged do let me know.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants