[Rd] Regex Crashing R (perl = TRUE) (PR#7564)

From: <Robert.McGehee_at_geodecapital.com>
Date: Wed 26 Jan 2005 - 08:03:05 EST


R-developers,
I've encountered another perl library regex bug that causes a segmentation faults on my Linux/Windows R session. I reduced the script to the snippet below. (Apologies if this was fixed with bug 7479, but this bug seems quite different).

string <- paste(rep("=", 10000), collapse = " ") crash <- function(x) {

    for (i in 1:5) {

        x <- gsub("[^!]=", " == ", x, perl = TRUE)     }
    x
}
x <- crash(string)
## Segmentation fault (core dumped)

The above should cause a crash immediately, but if you reduce the size of the string, either you may get a delayed crash, such that R crashes after you try to access the "string" object again, or you might get the odd error:
Error in for (i in 1:5) { : bad for loop sequence

If you set perl = FALSE, then the script runs fine (albeit slowly).

As a side note, is there a good way of incorporating an uncompiled perl script into an R package to be invoked from a system call? Putting it in the /src directory seems like the obvious place, but I can't convince R to copy over the script uncompiled upon installation.

Thanks,
Robert

> version

         _
platform i686-pc-linux-gnu

arch     i686
os       linux-gnu

system i686, linux-gnu
status
major 2
minor 0.1
year 2004
month 11
day 15
language R

Robert McGehee
Geode Capital Management, LLC
53 State Street, 5th Floor | Boston, MA | 02109 Tel: 617/392-8396 Fax:617/476-6389
mailto:robert.mcgehee@geodecapital.com

This e-mail, and any attachments hereto, are intended for us...{{dropped}}



R-devel@stat.math.ethz.ch mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed Jan 26 07:18:01 2005

This archive was generated by hypermail 2.1.8 : Fri 18 Mar 2005 - 09:02:42 EST