Skip to content

fcase() may trigger segfaults in certain cases #4378

@fredguinog

Description

@fredguinog

I'm using data.table 1.12.9, the most recent development version

Minimal reproducible example

qtty_row_table <- 1000000L

a <- data.table::data.table(
  V1 = rnorm(qtty_row_table),
  V2 = rnorm(qtty_row_table),
  V3 = rnorm(qtty_row_table)
)

a[, v0 := data.table::fcase(
  V1 > 0 & V2 <= 1 & V3 > 1, V2 * 100L,
  V1 > 1 & V2 <= 0 & V3 > 0, V3 * 100L,
  V1 > -1 & V2 <= 2 & V3 > 1, V1 * 100L,
  V1 > 1 & V2 <= 0 & V3 > 2, 300,
  V1 > 0 & V2 <= 1 & V3 > 1, 100,
  V1 > -1 & V2 <= 0 & V3 > -1, V1 * 100L,
  default = 0
)]

Output of sessionInfo()

R version 3.5.2 (2018-12-20)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 18363)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.1252  LC_CTYPE=English_United States.1252    LC_MONETARY=English_United States.1252
[4] LC_NUMERIC=C                           LC_TIME=English_United States.1252    

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

loaded via a namespace (and not attached):
[1] compiler_3.5.2 tools_3.5.2   

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions