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

rebin_peaks: Segfault (memory not mapped) for R-devel v4.5.0 #155

Open
HDash opened this issue Jan 20, 2025 · 3 comments
Open

rebin_peaks: Segfault (memory not mapped) for R-devel v4.5.0 #155

HDash opened this issue Jan 20, 2025 · 3 comments
Assignees
Labels
bug Something isn't working

Comments

@HDash
Copy link
Collaborator

HDash commented Jan 20, 2025

1. Bug description

All functions which call for rebin_peaks fail under R-devel v4.5.0 (tested with 2025-01-19 r87600 and prior). Everything works as expected with the latest R-release.

2. Reproducible example

Running example for rebin_peaks

devtools::load_all()
#> ℹ Loading EpiCompare
#> Warning: replacing previous import 'Biostrings::pattern' by 'grid::pattern'
#> when loading 'genomation'

data("CnR_H3K27ac") 
data("CnT_H3K27ac")
peakfiles <- list(CnR_H3K27ac=CnR_H3K27ac, CnT_H3K27ac=CnT_H3K27ac) 

peakfiles_rebinned <- rebin_peaks(peakfiles = peakfiles,
                                 genome_build = "hg19",
                                  bin_size = 5000,
                                 workers = 1)
#> Standardising peak files in 647,114 bins of 5,000 bp.
#> Warning in apply_fun(FUN = FUN, X, ...): scheduled cores 1, 2 did not deliver
#> results, all values of the jobs will be affected
#> Merging data into matrix.
#> Error in `rownames<-`(`*tmp*`, value = c("chr1:1-5000", "chr1:5001-10000", : attempt to set 'rownames' on an object with no dimensions

Created on 2025-01-20 with reprex v2.1.1

Data

(Built-in)

3. Session info

utils::sessionInfo()
#> R Under development (unstable) (2025-01-19 r87600)
#> Platform: x86_64-pc-linux-gnu
#> Running under: Ubuntu 22.04.5 LTS
#> 
#> Matrix products: default
#> BLAS:   /home/hd423/downloads/R-devel/lib/libRblas.so 
#> LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.10.0  LAPACK version 3.10.0
#> 
#> locale:
#>  [1] LC_CTYPE=C.UTF-8       LC_NUMERIC=C           LC_TIME=C.UTF-8       
#>  [4] LC_COLLATE=C.UTF-8     LC_MONETARY=C.UTF-8    LC_MESSAGES=C.UTF-8   
#>  [7] LC_PAPER=C.UTF-8       LC_NAME=C              LC_ADDRESS=C          
#> [10] LC_TELEPHONE=C         LC_MEASUREMENT=C.UTF-8 LC_IDENTIFICATION=C   
#> 
#> time zone: Etc/UTC
#> tzcode source: system (glibc)
#> 
#> attached base packages:
#> [1] stats     graphics  grDevices utils     datasets  methods   base     
#> 
#> loaded via a namespace (and not attached):
#>  [1] compiler_4.5.0    fastmap_1.2.0     cli_3.6.3         tools_4.5.0      
#>  [5] htmltools_0.5.8.1 withr_3.0.2       fs_1.6.5          glue_1.8.0       
#>  [9] yaml_2.3.10       rmarkdown_2.29    knitr_1.49        reprex_2.1.1     
#> [13] xfun_0.50         digest_0.6.37     lifecycle_1.0.4   rlang_1.1.5      
#> [17] evaluate_1.0.3

Created on 2025-01-20 with reprex v2.1.1

@HDash HDash added the bug Something isn't working label Jan 20, 2025
@HDash HDash self-assigned this Jan 20, 2025
@HDash
Copy link
Collaborator Author

HDash commented Jan 20, 2025

Traceback

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

Traceback:
 1: .Call2("C_viewMeans_RleViews", trim(x), na.rm, PACKAGE = "IRanges")
 2: viewMeans(v, na.rm = na.rm)
 3: viewMeans(v, na.rm = na.rm)
 4: viewMeans2(v, na.rm = na.rm)
 5: FUN(X[[i]], ...)
 6: lapply(names(numvar), function(seqname) {    v <- Views(numvar[[seqname]], bins_per_chrom[[seqname]])    viewMeans2(v, na.rm = na.rm)})
 7: lapply(names(numvar), function(seqname) {    v <- Views(numvar[[seqname]], bins_per_chrom[[seqname]])    viewMeans2(v, na.rm = na.rm)})
 8: GenomicRanges::binnedAverage(bins = gr_windows, numvar = data_cov,     varname = "score", na.rm = FALSE)
 9: FUN(X[[i]], ...)
10: lapply(X = S, FUN = FUN, ...)
11: doTryCatch(return(expr), name, parentenv, handler)
12: tryCatchOne(expr, names, parentenv, handlers[[1L]])
13: tryCatchList(expr, classes, parentenv, handlers)
14: tryCatch(expr, error = function(e) {    call <- conditionCall(e)    if (!is.null(call)) {        if (identical(call[[1L]], quote(doTryCatch)))             call <- sys.call(-4L)        dcall <- deparse(call, nlines = 1L)        prefix <- paste("Error in", dcall, ": ")        LONG <- 75L        sm <- strsplit(conditionMessage(e), "\n")[[1L]]        w <- 14L + nchar(dcall, type = "w") + nchar(sm[1L], type = "w")        if (is.na(w))             w <- 14L + nchar(dcall, type = "b") + nchar(sm[1L],                 type = "b")        if (w > LONG)             prefix <- paste0(prefix, "\n  ")    }    else prefix <- "Error : "    msg <- paste0(prefix, conditionMessage(e), "\n")    .Internal(seterrmessage(msg[1L]))    if (!silent && isTRUE(getOption("show.error.messages"))) {        cat(msg, file = outFile)        .Internal(printDeferredWarnings())    }    invisible(structure(msg, class = "try-error", condition = e))})
15: try(lapply(X = S, FUN = FUN, ...), silent = TRUE)
16: sendMaster(try(lapply(X = S, FUN = FUN, ...), silent = TRUE))
17: FUN(X[[i]], ...)
18: lapply(seq_len(cores), inner.do)
19: apply_fun(FUN = FUN, X, ...)
20: bpplapply(X = peakfiles, workers = workers, FUN = function(gr) {    gr <- compute_percentiles(gr = gr, thresholding_cols = intensity_cols,         initial_threshold = 0)    gr_names <- names(GenomicRanges::mcols(gr))    intens_col <- gr_names[gr_names %in% paste(intensity_cols,         "percentile", sep = "_")][1]    data_cov <- GenomicRanges::coverage(gr, weight = intens_col)    rm(gr)    gr <- GenomicRanges::binnedAverage(bins = gr_windows, numvar = data_cov,         varname = "score", na.rm = FALSE)    return(gr$score)}, ...)
21: rebin_peaks(peakfiles = peakfiles, genome_build = "hg19", bin_size = 5000,     workers = 1)

@HDash
Copy link
Collaborator Author

HDash commented Jan 21, 2025

Issue persists with past commit c2719d6, which previously passed all checks on push.

@HDash
Copy link
Collaborator Author

HDash commented Jan 21, 2025

Segfault somewhere here

https://github.com/Bioconductor/IRanges/blob/4eff83a94e30320f225dacdea9654d37b623e99f/src/RleViews_utils.c#L377-L560

C code for ViewMeans() from IRanges package. However, this code has not been modified in over years.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant