Skip to content
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

Segfault when exiting R #1125

Open
rbutleriii opened this issue Mar 4, 2025 · 3 comments
Open

Segfault when exiting R #1125

rbutleriii opened this issue Mar 4, 2025 · 3 comments

Comments

@rbutleriii
Copy link

I have notice that either with an interactive R session or a slurm script I get a segfault when trying to exit R.

 *** caught segfault ***
address 0x98, cause 'memory not mapped'

Traceback:
 1: x$unload()
 2: (function (x) x$unload())(<environment>)
An irrecoverable exception occurred. R is aborting now ...
/var/spool/slurm/slurmd/job47722788/slurm_script: line 4: 61773 Segmentation fault      (core dumped) Rscript 02-giotto_setup.R -s s23 -g WT-V -f 41,44,45,50,51,52,53,54,56,57,59,61,62,63,70,73,74,76,80,81 -d '/labs/flongo/Tau-PS19_C31_cortex_snRNAseq/CosMx/5_Raw_data/Run5990_S1_#23_1B' -o cortex -S 'seurat_object.annotated.rds,nb_clus,predicted.subclass,predicted.subclass.score,predicted.cluster,predicted.cluster.score' --slide_num 4

I save the giotto object with qs:

saveGiotto(gobj, 
  foldername = paste(slide, group, 'giotto_obj', sep="."), 
  dir = out_path,
  method = 'qs', 
  overwrite = FALSE
)

# cleanup
system("squeue -j $SLURM_JOBID --Format=TimeUsed")

It then completes the next line of code (system call), or if I am in an interactive R session it is fine until I go to close the session, were it will segfault and ask me if I want to core dump.

Is anyone else getting this? Is there a proper way to close the object? remove(gobj) doesn't seem to have an impact.

@rbutleriii
Copy link
Author

rbutleriii commented Mar 4, 2025

Here's a test with the R4.1.0 branch and GiottoData v0.2.5:

> library(Giotto)
Loading required package: GiottoClass
Giotto Suite 4.2.1
> library(GiottoData)
GiottoData 0.2.5
> set_giotto_python_path("/labs/flongo/reference/envs/giotto_env/bin/python")
a python path has been provided
Using python path:
 "/labs/flongo/reference/envs/giotto_env/bin/python"
[1] "/labs/flongo/reference/envs/giotto_env/bin/python"
> g <- updateGiottoObject(loadGiottoMini("cosmx"))
1. read Giotto object
2. read Giotto feature information
3. read Giotto spatial information
3.1 read Giotto spatial shape information
3.2 read Giotto spatial centroid information
3.3 read Giotto spatial overlap information
4. read Giotto image information
python already initialized in this session
 active environment : 'giotto_env'
 python version : 3.10
/oak/stanford/scg/lab_flongo/reference/envs/giotto_env/lib/python3.10/site-packages/numpy/core/getlimits.py:549: UserWarning: The value of the smallest subnormal for <class 'numpy.float64'> type is zero.
  setattr(self, word, getattr(machar, word).flat[0])
/oak/stanford/scg/lab_flongo/reference/envs/giotto_env/lib/python3.10/site-packages/numpy/core/getlimits.py:89: UserWarning: The value of the smallest subnormal for <class 'numpy.float64'> type is zero.
  return self._float_to_str(self.smallest_subnormal)
/oak/stanford/scg/lab_flongo/reference/envs/giotto_env/lib/python3.10/site-packages/numpy/core/getlimits.py:549: UserWarning: The value of the smallest subnormal for <class 'numpy.float32'> type is zero.
  setattr(self, word, getattr(machar, word).flat[0])
/oak/stanford/scg/lab_flongo/reference/envs/giotto_env/lib/python3.10/site-packages/numpy/core/getlimits.py:89: UserWarning: The value of the smallest subnormal for <class 'numpy.float32'> type is zero.
  return self._float_to_str(self.smallest_subnormal)
python already initialized in this session
 active environment : 'giotto_env'
 python version : 3.10
> ls()
[1] "g"
> remove(g)
> q()
Save workspace image? [y/n/c]: n

 *** caught segfault ***
address 0x98, cause 'memory not mapped'

Traceback:
 1: x$unload()
 2: (function (x) x$unload())(<environment>)

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:
> sessionInfo()
R version 4.2.2 (2022-10-31)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS/LAPACK: /oak/stanford/scg/lab_flongo/reference/envs/giotto_env/lib/libopenblasp-r0.3.29.so

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

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

other attached packages:
[1] GiottoData_0.2.5  Giotto_4.2.1      GiottoClass_0.4.7

loaded via a namespace (and not attached):
 [1] Rcpp_1.0.14          pillar_1.9.0         compiler_4.2.2
 [4] tools_4.2.2          digest_0.6.37        viridisLite_0.4.2
 [7] jsonlite_1.9.0       lifecycle_1.0.4      tibble_3.2.1
[10] scattermore_1.2      gtable_0.3.4         checkmate_2.3.2
[13] lattice_0.22-6       png_0.1-8            pkgconfig_2.0.3
[16] rlang_1.1.5          Matrix_1.6-5         igraph_2.0.3
[19] cli_3.6.4            parallel_4.2.2       ggrepel_0.9.5
[22] fastmap_1.1.1        terra_1.8-29         withr_3.0.0
[25] httr_1.4.7           dplyr_1.1.4          colorRamp2_0.1.0
[28] rappdirs_0.3.3       htmlwidgets_1.6.4    generics_0.1.3
[31] vctrs_0.6.5          gtools_3.9.5         GiottoVisuals_0.2.12
[34] grid_4.2.2           cowplot_1.1.3        tidyselect_1.2.1
[37] reticulate_1.41.0    glue_1.8.0           data.table_1.17.0
[40] R6_2.5.1             fansi_1.0.6          plotly_4.10.4
[43] tidyr_1.3.1          purrr_1.0.2          ggplot2_3.4.4
[46] magrittr_2.0.3       backports_1.5.0      scales_1.3.0
[49] codetools_0.2-20     GiottoUtils_0.2.4    htmltools_0.5.8.1
[52] colorspace_2.1-0     utf8_1.2.4           lazyeval_0.2.2
[55] munsell_0.5.1

@jiajic
Copy link
Member

jiajic commented Mar 4, 2025

I don't think I have noticed this before.
Was doing this fine on a previous version?

EDIT: I tried both of the following and ran into no issues. The RStudio instance closed without any issues.

library(Giotto)
library(GiottoData)
set_giotto_python_path()
g <- updateGiottoObject(loadGiottoMini("cosmx"))
ls()
remove(g)
q()

and

library(Giotto)
library(GiottoData)
set_giotto_python_path("/Users/george/Library/r-miniconda-arm64/envs/giotto_env/bin/pythonw")
g <- updateGiottoObject(loadGiottoMini("cosmx"))
ls()
remove(g)
q()
> sessionInfo()
R version 4.4.1 (2024-06-14)
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/New_York
tzcode source: internal

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

other attached packages:
[1] GiottoData_0.2.15 Giotto_4.2.1      GiottoClass_0.4.7

loaded via a namespace (and not attached):
 [1] SummarizedExperiment_1.34.0 gtable_0.3.6                rjson_0.2.21               
 [4] ggplot2_3.5.1               htmlwidgets_1.6.4           ggrepel_0.9.6              
 [7] Biobase_2.64.0              lattice_0.22-6              vctrs_0.6.5                
[10] tools_4.4.1                 generics_0.1.3              parallel_4.4.1             
[13] stats4_4.4.1                tibble_3.2.1                fansi_1.0.6                
[16] colorRamp2_0.1.0            pkgconfig_2.0.3             dbMatrix_0.0.0.9023        
[19] Matrix_1.7-0                data.table_1.16.2           checkmate_2.3.2            
[22] S4Vectors_0.42.0            lifecycle_1.0.4             GenomeInfoDbData_1.2.12    
[25] compiler_4.4.1              GiottoUtils_0.2.4           munsell_0.5.1              
[28] terra_1.7-78                codetools_0.2-20            scattermore_1.2            
[31] GenomeInfoDb_1.40.0         htmltools_0.5.8.1           lazyeval_0.2.2             
[34] plotly_4.10.4               tidyr_1.3.1                 pillar_1.9.0               
[37] crayon_1.5.3                SingleCellExperiment_1.26.0 DelayedArray_0.30.0        
[40] magick_2.8.5                abind_1.4-8                 gtools_3.9.5               
[43] tidyselect_1.2.1            digest_0.6.37               purrr_1.0.2                
[46] dplyr_1.1.4                 cowplot_1.1.3               fastmap_1.2.0              
[49] grid_4.4.1                  colorspace_2.1-1            cli_3.6.3                  
[52] SparseArray_1.4.1           magrittr_2.0.3              S4Arrays_1.4.0             
[55] utf8_1.2.4                  withr_3.0.2                 scales_1.3.0               
[58] UCSC.utils_1.0.0            backports_1.5.0             XVector_0.44.0             
[61] httr_1.4.7                  matrixStats_1.4.1           igraph_2.1.1               
[64] reticulate_1.39.0           png_0.1-8                   GiottoVisuals_0.2.12       
[67] SpatialExperiment_1.14.0    GenomicRanges_1.56.0        IRanges_2.38.0             
[70] viridisLite_0.4.2           rlang_1.1.4                 Rcpp_1.0.13-1              
[73] glue_1.8.0                  BiocGenerics_0.50.0         rstudioapi_0.16.0          
[76] jsonlite_1.8.9              R6_2.5.1                    MatrixGenerics_1.16.0      
[79] zlibbioc_1.50.0  

@rbutleriii
Copy link
Author

This is brand new for me, actually, wondering if it is related to terra 1.8. I had to load GEOS/3.11.1 as well to build as it was not catching new GEOS declarations. rspatial/terra#1754

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

No branches or pull requests

2 participants