Skip to content

Segfault on out-of-bound i and gforce #5312

@renkun-ken

Description

@renkun-ken

GForce functions like gmean(x) might crash R session if i is out of bound. Following is a minimal example:

library(data.table)

dt <- data.table(id = 1:10, x = rep(0, 10))
dt[16:20, .(
  xmean = mean(x)
), keyby = id]
 *** caught segfault ***
address 0x7fa218452f40, cause 'memory not mapped'

Traceback:
 1: gmean(x)
 2: gforce(thisEnv, jsub, o__, f__, len__, irows)
 3: `[.data.table`(dt, 16:20, .(xmean = mean(x)), keyby = id)
 4: dt[16:20, .(xmean = mean(x)), keyby = id]

Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
R version 4.1.2 (2021-11-01)
Platform: x86_64-apple-darwin17.0 (64-bit)
Running under: macOS Monterey 12.1

Matrix products: default
BLAS:   /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRblas.0.dylib
LAPACK: /Library/Frameworks/R.framework/Versions/4.1/Resources/lib/libRlapack.dylib

locale:
[1] en_US.UTF-8/en_US.UTF-8/en_US.UTF-8/C/en_US.UTF-8/en_US.UTF-8

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

other attached packages:
[1] data.table_1.14.2

loaded via a namespace (and not attached):
[1] compiler_4.1.2 jsonlite_1.7.2 rlang_0.4.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions