RGLab / flowWorkspace

flowWorkspace
GNU Affero General Public License v3.0
44 stars 21 forks source link

Seg fault in getData(x, y=node) #286

Closed MikeDMorgan closed 5 years ago

MikeDMorgan commented 5 years ago

Due to some vagaries of the flow cytometry data that I'm working with I need to make repeated subsets of my data, normalise (warp) the parameters across samples, and then reinstantiate a new GatingSet for each subset to continue with the definition of child nodes/gates. I then extract the per-cell per-parameter fluorescent intensities from each terminal node of the GatingSet hierarchy.

It is worth noting that if I only define and use a single GatingSet throughout then this issue does not arise.

This works in practise for the first subset, however, when extracting the second GatingSet using getData(gs, y=node) I received a seg fault:

caught segfault address 0x8, cause 'memory not mapped'

Traceback: 1: .cpp_getIndices(obj@pointer, sampleNames(obj), y) 2: .local(obj, y, ...) 3: FUN(gh, ...) 4: FUN(gh, ...) 5: FUN(X[[i]], ...) 6: lapply(X = X, FUN = FUN, ...) 7: sapply(sampleNames(X), function(thisSample, ...) { gh <- X[[thisSample]] FUN(gh, ...)}, simplify = FALSE, ...) 8: lapply(obj, getIndices, y) 9: lapply(obj, getIndices, y) 10: getData(P1.CD4.gs, y = node) 11: getData(P1.CD4.gs, y = node) An irrecoverable exception occurred. R is aborting now ... Segmentation fault: 11

The problem appears to come from a pointer to an object that has either been removed, or fallen out of scope.

sessionInfo() R version 3.5.3 (2019-03-11) Platform: x86_64-apple-darwin15.6.0 (64-bit) Running under: OS X El Capitan 10.11.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/3.5/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] ggcyto_1.10.2 ggplot2_3.1.0 flowViz_1.46.1 lattice_0.20-38 openCyto_1.20.2 flowStats_3.40.1 cluster_2.0.7-1
[8] flowWorkspace_3.30.2 ncdfFlow_2.28.1 BH_1.69.0-1 RcppArmadillo_0.9.200.7.1 flowCore_1.48.1

loaded via a namespace (and not attached): [1] Biobase_2.42.0 splines_3.5.3 R.utils_2.8.0 ellipse_0.4.1 gtools_3.8.1 assertthat_0.2.0 stats4_3.5.3 latticeExtra_0.6-28 RBGL_1.58.1 yaml_2.2.0
[11] robustbase_0.93-3 pillar_1.3.1 glue_1.3.1 RColorBrewer_1.1-2 colorspace_1.4-0 Matrix_1.2-16 R.oo_1.22.0 plyr_1.8.4 pcaPP_1.9-73 XML_3.98-1.19
[21] pkgconfig_2.0.2 fda_2.4.8 zlibbioc_1.28.0 purrr_0.3.1 corpcor_1.6.9 mvtnorm_1.0-10 scales_1.0.0 tibble_2.0.1 withr_2.1.2 BiocGenerics_0.28.0 [31] hexbin_1.27.2 lazyeval_0.2.1 mnormt_1.5-5 magrittr_1.5 crayon_1.3.4 IDPmisc_1.1.19 mclust_5.4.2 ks_1.11.4 R.methodsS3_1.7.1 MASS_7.3-51.1
[41] graph_1.60.0 tools_3.5.3 data.table_1.12.0 flowClust_3.20.1 matrixStats_0.54.0 stringr_1.4.0 munsell_0.5.0 compiler_3.5.3 rlang_0.3.1 grid_3.5.3
[51] rstudioapi_0.9.0 gtable_0.2.0 rrcov_1.4-7 R6_2.4.0 gridExtra_2.3 dplyr_0.8.0.1 clue_0.3-57 KernSmooth_2.23-15 Rgraphviz_2.26.0 stringi_1.4.3
[61] parallel_3.5.3 Rcpp_1.0.0 DEoptimR_1.0-8 tidyselect_0.2.5

gfinak commented 5 years ago

Can your provide a minimal reproducible code example of what your are doing that leads to the error?

MikeDMorgan commented 5 years ago

Hi @gfinak. In constructing a minimal reproducible example I found the source of the error <- I was making reference to a node without running recompute(gs). Then when trying to explicitly reference a node using getData(gs, y=node) it lead to the undefined pointer reference & seg fault error.

Would it be possible to add a conditional/tryCatch statement to prevent referencing to non-existent pointers, and give an informative error message in a future release?

mikejiang commented 5 years ago

It is now throwing the error instead of segfault. Thank you for reporting the issue!

> library(flowWorkspace)
> data(GvHD)
> gs <- GatingSet(GvHD[1])
> add(gs , rectangleGate(`FSC-H`= c(-Inf, Inf)), name = "L") 
> getData(gs, "L")  
Error in .cpp_getIndices(obj@pointer, sampleNames(obj), y) : 
  Event indicies are not available for the ungated non-boolean node: 'L'. 
 Please recompute it first!