[Rd] R-2.2.0: malloc probelm in regex code (PR#8287)

From: <gml4410_at_ggr.co.uk>
Date: Tue 08 Nov 2005 - 14:50:35 GMT


Full_Name: Gordon Lack
Version: 2.2.0
OS: OSF1/Tur64
Submission from: (NULL) (193.128.25.20)

R-2.2.0 fails to build on OSF1 systems.

.....

make[4]: Leaving directory `..../R-2.2.0/src/library/tools/src Error in list.files(path, pattern, all.files, full.names, recursive) :

        invalid 'pattern' regular expression Execution halted
make[3]: *** [all] Error 1
.....

I've tracked down the problem to change (somewhere) in 2.2.0 vs. 2.1.1 which has resulted in re_node_set_alloc() (in src/main/regex.c) being called with a size of 0. Whereas some system (Solaris, Linux, ...) return a valid pointer to a zero-size allocation, OSF1 returns a NULL pointer on a 0 allocation request (documented as such, and the Open Group Base Specifications Issue 6 documents that either may happen). The calling code treats a NULL return as a ESPACE error.

In R-2.1.1 this code was not asked to allocate 0 sizes, so I suspect that it shouldn't be happening here either.

A workaround is to add:

   if (size==0) size=1; /* OSF1 (at least) returns NULL on 0 alloc */

before the re_malloc (int, size) line in re_node_set_alloc(), which just means you allocate a small space (which shodul be free()d soon anyway).

The actual regex whcih triggers this during the build is:

 ^tools($|_)



R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Wed Nov 09 02:49:44 2005

This archive was generated by hypermail 2.1.8 : Mon 20 Feb 2006 - 03:21:33 GMT