[Rd] PR#14008, R segfault in fgets from do_system under high memory use
atp at piskorski.com
atp at piskorski.com
Thu Oct 15 20:20:22 CEST 2009
On this issue:
http://bugs.r-project.org/cgi-bin/R/incoming?id=14008
Here's a small patch which fixes the problem:
$ svn diff src/main/sysutils.c src/unix/sys-unix.c
Index: src/main/sysutils.c
===================================================================
--- src/main/sysutils.c (revision 49961)
+++ src/main/sysutils.c (working copy)
@@ -260,6 +260,9 @@
#else
fp = popen(command, type);
#endif
+ if (NULL == fp) {
+ error(_("popen failed with errno %i: %s"), errno, strerror(errno));
+ }
return fp;
}
#endif /* HAVE_POPEN */
Index: src/unix/sys-unix.c
===================================================================
--- src/unix/sys-unix.c (revision 49961)
+++ src/unix/sys-unix.c (working copy)
@@ -270,6 +270,11 @@
PROTECT(tlist);
fp = R_popen(translateChar(STRING_ELT(CAR(args), 0)), x);
+ if (NULL == fp) {
+ UNPROTECT(1);
+ errorcall(call, _("R_popen returned NULL."));
+ return R_NilValue;
+ }
for (i = 0; fgets(buf, INTERN_BUFSIZE, fp); i++) {
read = strlen(buf);
if(read >= INTERN_BUFSIZE - 1)
--
Andrew Piskorski <atp at piskorski.com>
http://www.piskorski.com/
More information about the R-devel
mailing list