[Rd] Intermittent crashes with inset `[<-` command
Serguei Sokol
@oko| @end|ng |rom |n@@-tou|ou@e@|r
Wed Feb 27 09:46:48 CET 2019
On 26/02/2019 05:18, Brian Montgomery via R-devel wrote:
> The following code crashes after about 300 iterations on my x86_64-w64-mingw32 machine on R 3.5.2 --vanilla.
> Others have duplicated this (see https://github.com/tidyverse/magrittr/issues/190 if necessary), but I don't know how machine/OS-dependent it may be.
It crashes too on my Mageia6 (RPM based Linux distribution):
184 185 186 187
*** caught segfault ***
address 0x700000002, cause 'memory not mapped'
Possible actions:
1: abort (with core dump, if enabled)
2: normal R exit
3: exit R without saving workspace
4: exit R saving workspace
The crash can happen at different moments, sometimes after i=187 like in
the example above, sometimes after i=915. The error is not always
segfault. It can also be
915 Error in `[<-`(x, y == "a", x[y == "b"]) : replacement has length zero
or
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 Error in
`[<-`(x, y == "a", x[y == "b"]) :
types (de raw a integer) incompatibles dans l'ajustement
d'affectation de type
(sorry, this crash was in french locale)
Hoping this helps.
Serguei.
> sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Mageia 6
Matrix products: default
BLAS/LAPACK: /home/opt/OpenBLAS/lib/libopenblas_sandybridge-r0.3.3.so
locale:
[1] C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
loaded via a namespace (and not attached):
[1] compiler_3.5.2
> If it doesn't crash for you, please try increasing the length of the x vector.
>
> Substituting the commented-out line for the one below it works correctly (prints out 1:1000 and ends normally) every time.
>
> x <- 1:200000
> y <- rep(letters[1:5], length(x) / 5L)
> for (i in 1:1000) {
> # x[y == 'a'] <- x[y == 'b']
> x <- `[<-`(x, y == 'a', x[y == 'b'])
> cat(i, '')
> }
> cat('\n')
>
> The point of using this syntax is to make it work better with pipes, but the errors occur without pipes or magrittr.
>
> Thank you for your help!
>
> ______________________________________________
> R-devel using r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>
More information about the R-devel
mailing list