Bioconductor / ShortRead

8 stars 6 forks source link

ShortRead can segfault #5

Closed HenrikBengtsson closed 3 years ago

HenrikBengtsson commented 3 years ago

Issue

ShortRead may segfault. See below for a minimal reproducible example. This may for instance happen when someone try to parallelize using some of the ShortRead helper objects, which then often result in a "silent" crash with little information to go by.

Wish

I understand why the following is not meant to work, but I'd argue an R package should never be able to core dump R. Instead, it should detect the problem and produce an informative run-time error.

Reproducible example

library(ShortRead)
sp <- SolexaPath(system.file("extdata", package="ShortRead"))
fl <- file.path(analysisPath(sp), "s_1_sequence.txt")
f <- FastqStreamer(fl, 50)
print(f)
close(f)
library(ShortRead)
f2 <- readRDS("f.rds")
print(f2)

results in a segfault:

class: FastqStreamer 
file: closed 

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

Traceback:
 1: .Call(.streamer_status, sampler)
 2: .self$status()
 3: object$show()
 4: (new("standardGeneric", .Data = function (object) standardGeneric("show"), generic = "show", package = "methods",     group = list(), valueClass = character(0), signature = "object",     default = new("derivedDefaultMethod", .Data = function (object)     showDefault(object), target = new("signature", .Data = "ANY",         names = "object", package = "methods"), defined = new("signature",         .Data = "ANY", names = "object", package = "methods"),         generic = "show"), skeleton = (new("derivedDefaultMethod",         .Data = function (object)         showDefault(object), target = new("signature", .Data = "ANY",             names = "object", package = "methods"), defined = new("signature",             .Data = "ANY", names = "object", package = "methods"),         generic = "show"))(object)))(new("FastqStreamer", .xData = <environment>))
 5: (new("standardGeneric", .Data = function (object) standardGeneric("show"), generic = "show", package = "methods",     group = list(), valueClass = character(0), signature = "object",     default = new("derivedDefaultMethod", .Data = function (object)     showDefault(object), target = new("signature", .Data = "ANY",         names = "object", package = "methods"), defined = new("signature",         .Data = "ANY", names = "object", package = "methods"),         generic = "show"), skeleton = (new("derivedDefaultMethod",         .Data = function (object)         showDefault(object), target = new("signature", .Data = "ANY",             names = "object", package = "methods"), defined = new("signature",             .Data = "ANY", names = "object", package = "methods"),         generic = "show"))(object)))(new("FastqStreamer", .xData = <environment>))
 6: print.default(f2)
 7: print(f2)

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: 

Session info

> sessionInfo()
R version 4.1.0 RC (2021-05-10 r80282)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.5 LTS

Matrix products: default
BLAS:   /home/hb/software/R-devel/R-4-1-branch/lib/R/lib/libRblas.so
LAPACK: /home/hb/software/R-devel/R-4-1-branch/lib/R/lib/libRlapack.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] stats4    parallel  stats     graphics  grDevices utils     datasets 
[8] methods   base     

other attached packages:
 [1] ShortRead_1.49.2            GenomicAlignments_1.27.2   
 [3] SummarizedExperiment_1.21.3 Biobase_2.51.0             
 [5] MatrixGenerics_1.3.1        matrixStats_0.58.0         
 [7] Rsamtools_2.7.2             GenomicRanges_1.43.4       
 [9] Biostrings_2.59.4           GenomeInfoDb_1.27.13       
[11] XVector_0.31.1              IRanges_2.25.11            
[13] S4Vectors_0.29.19           BiocParallel_1.25.5        
[15] BiocGenerics_0.37.6        

loaded via a namespace (and not attached):
 [1] rstudioapi_0.13        zlibbioc_1.37.0        lattice_0.20-44       
 [4] jpeg_0.1-8.1           hwriter_1.3.2          tools_4.1.0           
 [7] grid_4.1.0             png_0.1-7              latticeExtra_0.6-29   
[10] crayon_1.4.1           Matrix_1.3-3           GenomeInfoDbData_1.2.6
[13] RColorBrewer_1.1-2     bitops_1.0-7           RCurl_1.98-1.3        
[16] DelayedArray_0.17.13   compiler_4.1.0