From ru|pb@rr@d@@ @end|ng |rom @@po@pt  Mon Oct 11 08:41:51 2021
From: ru|pb@rr@d@@ @end|ng |rom @@po@pt (Rui Barradas)
Date: Mon, 11 Oct 2021 07:41:51 +0100
Subject: [Rd] Crash/bug when calling match on latin1 strings
In-Reply-To: <CAPLMX9FKNS2Hf9BNcArWL_GrEkggxOd04-b+rfHtEAceCpH9dA@mail.gmail.com>
References: <CAPLMX9FKNS2Hf9BNcArWL_GrEkggxOd04-b+rfHtEAceCpH9dA@mail.gmail.com>
Message-ID: <7bdc35a6-b3c1-88b7-8e82-61d4b5f4ae7a@sapo.pt>

Hello,

R 4.1.1 on Ubuntu 20.04.

I can reproduce this error but not ~90% of the time, only the 1st time I 
run the script.
If I run other (terminal) commands before rerunning the R script it 
sometimes segfaults again but once again very far from 90% of the time.


rui at rui:~/tmp$ R -q -f rhelp.R
 > sessionInfo()
R version 4.1.1 (2021-08-10)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: Ubuntu 20.04.3 LTS

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

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_4.1.1
 >
 > # A bunch of words in UTF8; replace *'s
 > words <- readLines("h****://pastebin.c**/raw/MFCQfhpY", encoding = 
"UTF-8")
 > words2 <- iconv(words, "utf-8", "latin1")
 > gctorture(TRUE)
 > y <- match(words2, words2)

  *** caught segfault ***
address 0x10, cause 'memory not mapped'
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation
*** recursive gc invocation

Traceback:
  1: match(words2, words2)
An irrecoverable exception occurred. R is aborting now ...
Falta de segmenta??o (n?cleo despejado)



This last line is Portuguese for

Segmentation fault (core dumped)

Hope this helps,

Rui Barradas


?s 06:05 de 11/10/21, Travers Ching escreveu:
> Here's a brief example:
> 
> # A bunch of words in UTF8; replace *'s
> words <- readLines("h****://pastebin.c**/raw/MFCQfhpY", encoding = "UTF-8")
> words2 <- iconv(words, "utf-8", "latin1")
> gctorture(TRUE)
> y <- match(words2, words2)
> <The program crashes / segfaults ~90% of the time>
> 
> I searched bugzilla but didn't see anything. Apologies if this is already
> reported.
> 
> The bug appears in both R-devel and the release, but doesn't seem to affect
> R 4.0.5.
> 
> 	[[alternative HTML version deleted]]
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
>



[Rd] Crash/bug when calling match on latin1 strings
Rui Barradas