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

gml4410@ggr.co.uk gml4410 at ggr.co.uk
Tue Nov 8 15:50:35 CET 2005


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($|_)



More information about the R-devel mailing list