Hello,

I can also reproduce this, R 3.5.2 on Ubuntu 18.04 LTS.


First run gives error after 148.

After 148:

Error in `[<-`(x, y == "a", x[y == "b"]) :
  substituto tem comprimento zero
Execução interrompida

Translation:

replacement has length zero
Execution stopped


Second run gives a different error, I changed the script to start with a sessionInfo() instruction, everything else is the same as in the OP.

After 180:

 *** caught segfault ***
address 0x700000002, cause 'memory not mapped'
An irrecoverable exception occurred. R is aborting now ...


Several runs with or without the sessionInfo() always give the two different errors above.

The sessionInfo() was the following.

sessionInfo()
R version 3.5.2 (2018-12-20)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 18.04.1 LTS

Matrix products: default
BLAS: /usr/lib/x86_64-linux-gnu/blas/libblas.so.3.7.1
LAPACK: /usr/lib/x86_64-linux-gnu/lapack/liblapack.so.3.7.1

locale:
 [1] LC_CTYPE=pt_PT.UTF-8       LC_NUMERIC=C
 [3] LC_TIME=pt_PT.UTF-8        LC_COLLATE=pt_PT.UTF-8
 [5] LC_MONETARY=pt_PT.UTF-8    LC_MESSAGES=pt_PT.UTF-8
 [7] LC_PAPER=pt_PT.UTF-8       LC_NAME=C
 [9] LC_ADDRESS=C               LC_TELEPHONE=C
[11] LC_MEASUREMENT=pt_PT.UTF-8 LC_IDENTIFICATION=C

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

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


Hope this helps,

Rui Barradas


Às 08:46 de 27/02/2019, Serguei Sokol escreveu:
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@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

______________________________________________
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel

Reply via email to