Robert.McGehee@geodecapital.com
2005-Jan-25 22:03 UTC
[Rd] Regex Crashing R (perl = TRUE) (PR#7564)
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}}
A side response... On Jan 25, 2005, at 1:03 PM, Robert.McGehee@geodecapital.com wrote:> 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.That's what the inst/ directory of a package is for, I believe. Look for details in the Writing R Extensions manual. You might also want to look at system.file() which can help you locate files in an installed package. + seth